Why would I have to do that with my Light-Spheres?

Started by
3 comments, last by mind in a box 13 years, 8 months ago
Hi,
I've been looking over this tutorial to see if I missed something in my Point-Light implementation. And I found this part:

Quote:
Since we are using geometry to render the lighting, we need to handle the case when the camera is inside the light volume. Here we change the CullMode render state so that it either culls interior faces when the camera is outside the object, or it culls exterior faces when the camera is inside the object. Normally this would be set to Counter-Clockwise, which remains our default when outside the object.

Simply detect when the camera is inside the object and set the CullMode to Clockwise to handle the other case.

Another issue you may notice with this is when the camera is entering a light volume, especially the point light sphere. At this point, part of the screen is inside the object, and the rest is outside, so we need to set CullMode to None here to handle both cases without creating visual glitches.


Why would I have to do this? I just set the CullMode to "Front" and it works fine for me, since it's a sphere for a point-light.

Now I'm not sure if I get any issues when I do it this way... I just want to make sure that I don't get problems because of this later, so I'm asking here if someone knows the difference.
Advertisement
Quote:Original post by mind in a box
Hi,
I've been looking over this tutorial to see if I missed something in my Point-Light implementation. And I found this part:

Quote:
Since we are using geometry to render the lighting, we need to handle the case when the camera is inside the light volume. Here we change the CullMode render state so that it either culls interior faces when the camera is outside the object, or it culls exterior faces when the camera is inside the object. Normally this would be set to Counter-Clockwise, which remains our default when outside the object.

Simply detect when the camera is inside the object and set the CullMode to Clockwise to handle the other case.

Another issue you may notice with this is when the camera is entering a light volume, especially the point light sphere. At this point, part of the screen is inside the object, and the rest is outside, so we need to set CullMode to None here to handle both cases without creating visual glitches.


Why would I have to do this? I just set the CullMode to "Front" and it works fine for me, since it's a sphere for a point-light.

Now I'm not sure if I get any issues when I do it this way... I just want to make sure that I don't get problems because of this later, so I'm asking here if someone knows the difference.


Try making sure your light influences a surface, then move the camera inside the sphere. If you set this up correctly, the light should now not influence the original surface wherever the light volume intersects the near plane-- the culprit is the clipping operation. By moving over to front face culling, we still can guarantee that the light volume will still have visible triangles and can shade.

EDIT: Fixed a typo.
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.
Quote:
Try making sure your light influences a surface, then move the camera inside the sphere. If you set this up correctly, the light should now not influence the original surface wherever the light volume intersects the near plane-- the culprit is the clipping operation. By moving over to front face culling, we still can guarantee that the light volume will still have visible triangles and can shade.


When I set the cull-mode to "Back", then the lighting disappears from th surface when I move the camera inside it, indeed.

But when I render the sphere with Cull-mode "Front" all the time (Backfaces are turned to new front faces, old front faces turn to back faces and get culled, AFAIK), the lighting stays on the surface, just as it should.
Setting the Cull-Mode to none results in rendering the light twice when the camera is outside of the sphere.

I made two shots to proof that it works:




As you see, it seems to work (Did I miss something? Do you see something wired?) without checking if the camera is inside the sphere or not. And since that, I'm a bit confused why someone would want to write this into a tutorial...
Quote:Original post by mind in a box
Quote:
Try making sure your light influences a surface, then move the camera inside the sphere. If you set this up correctly, the light should now not influence the original surface wherever the light volume intersects the near plane-- the culprit is the clipping operation. By moving over to front face culling, we still can guarantee that the light volume will still have visible triangles and can shade.


When I set the cull-mode to "Back", then the lighting disappears from th surface when I move the camera inside it, indeed.

But when I render the sphere with Cull-mode "Front" all the time (Backfaces are turned to new front faces, old front faces turn to back faces and get culled, AFAIK), the lighting stays on the surface, just as it should.
Setting the Cull-Mode to none results in rendering the light twice when the camera is outside of the sphere.

I made two shots to proof that it works:




As you see, it seems to work (Did I miss something? Do you see something wired?) without checking if the camera is inside the sphere or not. And since that, I'm a bit confused why someone would want to write this into a tutorial...


Sounds like your winding order is reversed, then :) As mentioned, the math works out; the only way it wouldn't is if the cull mode winding orders aren't the same between the two implementations.

Also, are you enabling depth tests for the lights? This is a pretty important fill/ALU optimization.
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.
No, I turned depth testing off for the moment. As you asked me this, I took a deeper look into that optimization technique. I guess when I go for it I will have to change the behavior of the culling anyways...

This topic is closed to new replies.

Advertisement