Sign in to follow this  

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

This topic is 2661 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 2661 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this