RSS
 

Point lights

06 Oct

Got shadows for point lights working:

Had some issues getting it to work:

The errors in the shadows are noticeable in the areas in between the vertexes.

Initially, I thought the problem was that I was a pixel shader/vertex shader mismatch, since when I was creating the shadowmap, the vertex shader for it did most of the computation and the pixel shader was just a simple passthrough, and when I was “applying” the shadowmap, all the calculations were done in the pixel shader.

After I corrected that (passed most of the computations for the pixel shader on the shadow map phase), the problem persisted… I got pissed about that, and after much scrounging around I found the problem…

The issue had to do with the projection of the geometry in the shadowmap… As I’m using a dual-paraboloid map, I have to create a “fish-eye” perspective of sorts when generating the shadowmap. This works fine, but I didn’t take to account lowly tesselated geometry near the light source (because the perspective transformation is done at a vertex level):

So, originally we have a tesselated square… If we apply the spherical projection we need for the “fish-eye” effect, we should have something rounded like we see on the second picture… But, as we are only applying the math to the vertexes, we in fact get the red lines, instead of the rounded edges…

On a zoom:

In the middle of the object, that’s not a big problem… there will the wrongfully drawn shadows, but we won’t notice them… Problem is on the outer edges of the object, in which we would fetch texels outside of the “drawn area” of the shadowmap!

Thankfully, the solution for this problem is simple enough: just clear the shadowmap to the maximum distance, to insure that all the areas outside of the “drawn area” are never shadowed… this is potentially wrong, but it should be close enough to never be a problem…

Anyway, they look neat and are fast, which is the two main points in all of this… I’m thinking I’ll have probably two or three shadowmapped lightsources on screen at a time… Need to devise a way to reuse the shadowbuffers of lights that don’t need them at the moment (since I’m currently using 32 bit floating point shadowmaps, which are huge memory hogs!), but that shouldn’t be an issue…

Next step, directional lights!

 
 

Leave a Reply

 
*