Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 Jul 2012
Offline Last Active Aug 11 2012 11:48 AM

Posts I've Made

In Topic: Geometry shaders and depth FBOs

30 July 2012 - 10:40 AM

Thanks for the suggestion. I went back to take another look. The issue seems to be that if I move the shadows back, then they will vanish entirely (the particles won't shadow themselves, but won't shadow anything else either).

http://i.imgur.com/NfHx7.png (screenshot - ignore the "particle" text, which is part of the HUD).

I suppose I could use two separate shadow maps - one for particles where the depth is offset slightly, and one for meshes where the depth remains the same.

In Topic: Geometry shaders and depth FBOs

28 July 2012 - 08:23 AM

I managed to fix the problem, but I have another issue.

The solution: the shadows weren't being drawn as I had enabled front face culling for the rendering of shadows. Changing the order of the vertices in the geometry shader fixed it.

New issue:
Because the depth of the shadow is essentially the same as the depth of the particle itself, every particle will be affected by its own shadow.

Image (ignore the "particle transparency" bit - it's part of the HUD)

I've tried applying a polygon offset through glPolygonOffset (for lines, points and fill) but it only seems to affect the shadows cast by the mesh objects (not built in a geometry shader). I've also tried messing about with the gl_FragDepth (so the particle fragments would be treated as closer to the camera, and the particle shadows would be treated as being further away), but that gave no change other than the particle or its shadow completely disappearing when the depth was outside of the 0 to 1 range.
I also tried changing the screen-space depth of the shadow vertices themselves. Lower offsets removed the self shadow but also displaced the positions of the shadows on other objects.


I then tried to draw the particles closer to the screen so that their screen-space depths would be lower than that of the shadows. Applying the offset before the projection transformation (but after applying the modelview matrix) displaced the particles according to the camera position but otherwise did not affect the shadows. Applying it after projection seemed to change the distance at which the particle could be seen but didn't change the shadow at all.

What am I doing wrong? Is this issue actually possible to solve?