Shadow mapping for point lights demo

I’ve written a demo of shadowmapping for point lights (source is available). One of my better demos IMO.
Will run on Radeon 8500/9700.

It’s available on my website:
http://humus2.campus.luth.se/~humus/
(Note, only temporary address, will be back to esprit.campus.luth.se in a week or so)

Meget flot, Humus .

Runs smoothly on my 8500 ( looks very good too ). Definitely one of your best.

looks good (i cant run it though on my gf2mx)
so can i/we have a few states please
average fps -
windowsize -
number of lights -
number of polygons -

cheers zed

On my Radeon 8500 I get 70-80fps in 1024x768x32 fullscreen. There’s two lights, and uhm 20 quads (not particularily complex geometry ). This can be compared to my stencil shadows demo which runs at 65-75fps in the same res, also uses two lights but only 8 quads of which only two casts shadow valumes as I know on beforehand that they are the only ones that will cast shadows.

Also, this method is more scaleable, you can use a smaller cubemap for better performance, going down to 128x128 (instead of current 256x256) boosts performance about 20fps, even though quality is worse of course, but still acceptable except on closeups.

Edit: 20 quads, not 14

[This message has been edited by Humus (edited 09-22-2002).]

Really interesting! planned to write using ARB_fragment_prg some day? :wink:

Well, depends on how soon I get my hands on hardware and drivers supporting it.

Got around 90-100 fps. Pretty good demo, except it’s limited to a simple scene with a small light radius. I’d be more interested in a moderately complex scene (5k tris) with a big radius (like 50 to 100m)… Granted, it’s more work…:slight_smile:

Y.

You’re demo is looking great from the screenshot but I have problems here with my Radeon 9000…There is no shadow and no perpixellighting visible…Only some sort of ambient (with textures) seems to be visible…
When I click debug from the menu it says “invalid window handle” (tanslated from german error message)

LaBasX2

Originally posted by Ysaneya:
[b]Got around 90-100 fps. Pretty good demo, except it’s limited to a simple scene with a small light radius. I’d be more interested in a moderately complex scene (5k tris) with a big radius (like 50 to 100m)… Granted, it’s more work…

Y.[/b]

This is more of a prototype application. I’m working on a larger project with much more complex geometry. Now that I’ve found the technique works I can implement it in this larger project.

Originally posted by LaBasX2:
[b]You’re demo is looking great from the screenshot but I have problems here with my Radeon 9000…There is no shadow and no perpixellighting visible…Only some sort of ambient (with textures) seems to be visible…
When I click debug from the menu it says “invalid window handle” (tanslated from german error message)

LaBasX2[/b]

This error occures for everyone, even for me and everyone else the demo works for. I’m not sure why, but I’ve tracked down this error to the wglMakeCurrent(hPdc, hPrc) call. I’m pretty sure all parameters are correct, and I’ve checked that I do everything correct … and after all, it works. So I don’t know really …

There seams to be problems with this demo on Radeon 9700 for some reason though, but for the 9000 was unexpected as it’s very similar to the 8500, for which it works.

Just updated my drivers from 7.73 to the very new 7.76 and now it’s working

Looking amazing, great work Humus!

[This message has been edited by LaBasX2 (edited 09-22-2002).]

There seams to be problems with this demo on Radeon 9700 for some reason though, but for the 9000 was unexpected as it’s very similar to the 8500, for which it works.

I have problems with the 9700 and ATI_fragment_shader too ( with my own shaders ) ? I don’t get any bumpmapping.

I have after request tried to make an implementation of it with register combiners. If someone with a GF3 or higher want to try would be nice. Chances of it working would be like 10% though I suppose as I don’t have any hardware to test it on.

Humus, you are using a 3d texture for the radial distance. So you have a maximum of 8 bit precision. Usually that isn’t enough for normal shadow mapping and so there will probably be many shadow artifacts in larger scenes, right?

Thanks
LaBasX2

Yup, that’s right, if the light has a large radius. The size of the scene isn’t too important though, but geometric detail may be.

I hope to get my Radeon 9700 soon so I can implement the distance calculation as pure math instead of texture lookup in the pixel shader, plus having 16bit/channel textures to render to.

Wouldn’t it be possible to use the distance to the near plane instead ? Then, all you need to do is a DP4 operation to calculate the distance… but well, i’ve never implemented shadow maps so i don’t know…?

Y.

glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 5 /*instead of 6*/);
(...)
/*replace 4th stage with this: */
glCombinerInputNV(GL_COMBINER4_NV,  GL_RGB, GL_VARIABLE_A_NV, GL_ZERO,         GL_SIGNED_IDENTITY_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER4_NV,  GL_RGB, GL_VARIABLE_B_NV, GL_ZERO,         GL_SIGNED_IDENTITY_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER4_NV,  GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE0_ARB, GL_SIGNED_IDENTITY_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER4_NV,  GL_RGB, GL_VARIABLE_D_NV, GL_ZERO,         GL_UNSIGNED_INVERT_NV, GL_RGB);
glCombinerOutputNV(GL_COMBINER4_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV,
   GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_TRUE);

At first run yor app exited reporting lack of WGL_ARB_render_texture. In your Framework when you query for WGL_EXT/ARB_extensions_string you should check whether wglGetProcAddress(“wglGetExtensionsStringARB”) returns non-NULL, rathen then scan extensions string (spec says that, BTW).

After these patches it runs nicely on my machine (20 fps, GF3 + 40.41 + AthlonXP 1700)

I don’t know how exactly your program works yet, I just made NV RC do the same work as ATI FS

[This message has been edited by MZ (edited 09-22-2002).]

Originally posted by Ysaneya:
[b]Wouldn’t it be possible to use the distance to the near plane instead ? Then, all you need to do is a DP4 operation to calculate the distance… but well, i’ve never implemented shadow maps so i don’t know…?

Y.[/b]

Well, you’ll then have a different distance calculation for each cubemap face, something that will singificantly complicate the problem when you do the compare with the stored value.

Originally posted by MZ:
[b]At first run yor app exited reporting lack of WGL_ARB_render_texture. In your Framework when you query for WGL_EXT/ARB_extensions_string you should check whether wglGetProcAddress(“wglGetExtensionsStringARB”) returns non-NULL, rathen then scan extensions string (spec says that, BTW).

After these patches it runs nicely on my machine (20 fps, GF3 + 40.41 + AthlonXP 1700)

I don’t know how exactly your program works yet, I just made NV RC do the same work as ATI FS [/b]

Hmm … seams like that note in the spec has passed me by completely. The first thing that springs to mind is, “why?”. I’ve yet to understand the purpose of the WGL_ARB_extension_string at all btw. Anyway, I’ve fixed that code now though.

Updated with your fixed RC code, the “6” was just a silly cut’n’paste error

20fps sounds a little low though, what resolution is that?

maximized window on 1162 x 864 desktop: 20 fps
fullscreen 640 x 480: 30 fps