Sign in to follow this  

Simple light shafts

This topic is 2840 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

I can't remember if I saw this somewhere before or not, but I was just thinking that shafts of light from windows would be a nice effect and I had (or remembered) an idea. The light shafts are convex objects and to draw them, first render the back faces and write the depth to a buffer, then render the front faces and the brightness would be some function of the difference between the two depths. Is this technique ever used, and if so, is it any good, and how would you handle cases where the camera is in the light volume?

Share this post


Link to post
Share on other sites
I've implemented this on the Wii and the performance was acceptable. We weren't using it for light-shafts in camera-accessible areas though, so we simply didn't bother dealing with cases where the camera can be inside the volume.
You could try fading out the effect as the camera gets close to it, and then not render the effect at all while the camera is inside the volume.

There's an alternative technique that was used in "STALKER: clear sky" -- I'll see if I can find a paper.

Share this post


Link to post
Share on other sites
Quote:
Original post by Hodgman
I've implemented this on the Wii and the performance was acceptable. We weren't using it for light-shafts in camera-accessible areas though, so we simply didn't bother dealing with cases where the camera can be inside the volume. You could try fading out the effect as the camera gets close to it, and then not render the effect at all while the camera is inside the volume.
Shouldn't you just switch to only rendering back-faces when the camera is inside, and taking the depth of the back face?

Conceptually, the brightness depends on the distance a ray from the eye travels through the light shaft, right? If the camera is outside the shaft, that distance is the difference between the distances to the front and back-faces in the shaft. If the camera is inside, it is just the distance to the back-face of the shaft.

Share this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder
Shouldn't you just switch to only rendering back-faces when the camera is inside, and taking the depth of the back face?
Yeah that makes perfect sense! We didn't go down this path though, because to even start on this you've got to be able to determine on the CPU-side if the camera is inside/outside the volume, which our engine didn't support (and the schedule was too tight to add it)... :( So we just used the effect in areas where the camera couldn't reach. The fade effect might have worked as we could've done a basic collision test (e.g. bounding sphere) instead of a precise collision check.

There might be some artefacts as the camera enters the volume though, as it can be half-in/half-out (like when you've got a full-screen water effect and have to switch it on/off when the camera transitions in/out of water). Some games deal with this by simply not allowing the camera to be half-in/half-out of a volume by pushing it a bit in either direction if it's on the border.

Share this post


Link to post
Share on other sites

This topic is 2840 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