Sign in to follow this  
ak-73

Crepuscular rays/Volumetric light scattering

Recommended Posts

Okay, so I have actually managed to get a pretty decent corona effect through volumetric light scattering, even if it takes plenty of samples and therefore drains performance a lot to make the effect smoothly... (from: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html) Here's my question: the god's ray effect is based the basic sun being rendered to texture and then being post-processed. As a result -with my current naive implementation- the sun rays are only visible when the sun itself is in view. But some of the rays should be visible *long* before the sun itself enters the frustrum. Is there a simple solution to this problem? The naive response would be to also render the scene with 180 degree fov and light-scatter it, then project the viewable parts of this render onto the actual camera. But that doesn't sound efficient and it doesn't sound as if the output would be necessarily visually pleasing either, especially at high angles. Any thoughts? Thanks, Alex

Share this post


Link to post
Share on other sites
Did you took into acount this remark?
"1 When facing away from the light source, the sample ray is consequently inverted to create the appearance of anti-crepuscular rays."

There are no solution to this issue if you use this technique, something similar was used in Crysis and you dont have any rays when powered EdotL is not strong enought. To get effect that you want you need to look at other techniques based on shadow maps, some of them are mentioned in the first part of the article. But be aware that they are less performance efficient and can produce ugly aliazing.
From other side, this effect should be subtle and even with this "limited" implementation gives pretty nice feelling of volumetric atmosphere. Crytek used similar technique in Crysis, take a look:
http://www.crytek.com/fileadmin/user_upload/inside/presentations/gdc2008/GDC08_SousaT_CrysisEffects.ppt
starting at slide 62

Share this post


Link to post
Share on other sites
Quote:
Original post by Viik
Did you took into acount this remark?
"1 When facing away from the light source, the sample ray is consequently inverted to create the appearance of anti-crepuscular rays."


No - and unless my web browser's search functionality is dysfunctional, the reprint on the nVidia webpage does not contain this, what I believe to be, footnote.

Quote:

There are no solution to this issue if you use this technique, something similar was used in Crysis and you dont have any rays when powered EdotL is not strong enought. To get effect that you want you need to look at other techniques based on shadow maps, some of them are mentioned in the first part of the article. But be aware that they are less performance efficient and can produce ugly aliazing.
From other side, this effect should be subtle and even with this "limited" implementation gives pretty nice feelling of volumetric atmosphere. Crytek used similar technique in Crysis, take a look:
http://www.crytek.com/fileadmin/user_upload/inside/presentations/gdc2008/GDC08_SousaT_CrysisEffects.ppt
starting at slide 62



Perhaps the effect I'd like to achieve not that difficult. I writing a simple space game demo and the technique presented works pretty well while the sun falls into the view frustrum. The only thing I need to get working is to have the first rays render on-screen while the sun is *somewhat* near the frustrum. To that end I have been considering, rendering the sun with rays centered into a texture and put a billboard into the scene instead of the actual thing. The only great difficulty is then any objects between the eyepoint and the lightsource/sun... I am not so sure whether the effect they have on the sun's crepuscular rays will be perspective-correct enough, especially when scaling of the billboard is involved. I guess I'll have to just try it and study the results.

Thanks,
Alex

Share this post


Link to post
Share on other sites
At the end of this sentence:
"Given the initial image, sample coordinates are generated along a ray cast from the pixel location to the screen-space light position."
click on - [1]

I have doubts about volumetric scatering in space, scatering happens mainly because of the aerozols and small particles in atmosphere. In space there are some particles but their density for sure is not enought to produce distinguishing light scatering over a range where objects smaller than planets would be visible. To summarize - simple bilboard should be enought, it's more art realted issue than technical one.

Share this post


Link to post
Share on other sites
Quote:
Original post by ak-73
Any thoughts?

You can render a some area around the sun in separate texture,that's all.As to me,there is a simple inplementation without shaders which allows to see "sun beams" when sun is situated behind camera.

[Edited by - Krokhin on March 21, 2009 6:34:44 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Viik
Would you like to share mentioned technique?

This technique not exist as a paper.I was going to write an article before crysis,but now I don't know.I already mentioned main idea before -rendering a some area around the sun and "stretching" rays to visible area.

Share this post


Link to post
Share on other sites
In Crysis you can see rays only when angle between camera direction and sun is very small, so you dont's see any rays when you dont see a sun itself.
http://www.crytek.com/fileadmin/user_upload/inside/presentations/gdc2008/GDC08_SousaT_CrysisEffects.ppt
Comments on slide 65
"Works reasonably well if sun onscreen or nearby
Screen edges problematic:
- to minimize strength is attenuated based on view angle with sun direction
- additionally could attenuate edges
"

Share this post


Link to post
Share on other sites
Quote:
Original post by Viik
In Crysis you can see rays only when angle between camera direction and sun is very small, so you dont's see any rays when you dont see a sun itself.
"

Yes,because of complexity limitations (one pass) it's "clear" screen post process effect.This approach seems right because in real nature we never observe rays in points which has angle relatively the sun more than 90*.It happens mostly because of pecularityes of light scattering.Actually,this scattering always produce lightshafts, but they are "merged".Clouds and terrain objects-simply a volume shadow casters,like in this case.

[Edited by - Krokhin on March 22, 2009 4:21:56 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Viik
At the end of this sentence:
"Given the initial image, sample coordinates are generated along a ray cast from the pixel location to the screen-space light position."
click on - [1]


My bad, thanks for the hint. :)

Quote:

I have doubts about volumetric scatering in space, scatering happens mainly because of the aerozols and small particles in atmosphere. In space there are some particles but their density for sure is not enought to produce distinguishing light scatering over a range where objects smaller than planets would be visible. To summarize - simple bilboard should be enought, it's more art realted issue than technical one.


Well, I am not trying to create a space sim, so I am drawing a bit on artistic license there... :) Secondly, evidently, the sunlight does leave some rays/artifacts on cameras in space, so I consider using the god rays effect fair enough.

Quote:
Original post by Krokhin
Quote:
Original post by ak-73
Any thoughts?

You can render a some area around the sun in separate texture,that's all.As to me,there is a simple inplementation without shaders which allows to see "sun beams" when sun is situated behind camera.


It's sufficient if there's some effect if the sun is in the camera's front hemisphere. I have been considering using not just a billboard quad but projecting the god-rayed sun onto an otherwise transparent fron hemisphere geometry to make the rays actually wrap a bit around the camera but I don't if that's going to look as desired so I guess I'll have to experiment with it. :)

thanks everyone,
Alex

Share this post


Link to post
Share on other sites
Quote:
Original post by Krokhin
Quote:
Original post by Viik
In Crysis you can see rays only when angle between camera direction and sun is very small, so you dont's see any rays when you dont see a sun itself.
"

Yes,because of complexity limitations (one pass) it's "clear" screen post process effect.This approach seems right because in real nature we never observe rays in points which has angle relatively the sun more than 90*.It happens mostly because of pecularityes of light scattering.Actually,this scattering always produce lightshafts, but they are "merged".Clouds and terrain objects-simply a volume shadow casters,like in this case.


I'm pretty sure that the angle between the sun and the forward vector of the "camera" has no effect on the appearance of crepuscular/anti-crepuscular rays in the real world.

Share this post


Link to post
Share on other sites
Quote:
Original post by Fingers_
Quote:
Original post by Krokhin
Quote:
Original post by Viik
In Crysis you can see rays only when angle between camera direction and sun is very small, so you dont's see any rays when you dont see a sun itself.
"

Yes,because of complexity limitations (one pass) it's "clear" screen post process effect.This approach seems right because in real nature we never observe rays in points which has angle relatively the sun more than 90*.It happens mostly because of pecularityes of light scattering.Actually,this scattering always produce lightshafts, but they are "merged".Clouds and terrain objects-simply a volume shadow casters,like in this case.


I'm pretty sure that the angle between the sun and the forward vector of the "camera" has no effect on the appearance of crepuscular/anti-crepuscular rays in the real world.

If you mean philosophical sense-of couse,they exist,but not visible.Imho in reality happens something like that (see picture):
A: close, has enough beam thickness (red color in the picture),but visible worse at lighten hase background
B: close,thick,background is blue sky & dark clouds bottom -best visibility
C,D: close,but relatively thin,visible mostly at dark clouds bottom background
E,F: relatively far-i.e. we look through haze,thin because of angle,and at lighten hase background -as a usual,no chance to see it.
------
"Open your eyes,look up to the skies and see"(c)[smile]

[Edited by - Krokhin on March 25, 2009 2:18:28 AM]

Share this post


Link to post
Share on other sites
Quote:
I'm pretty sure that the angle between the sun and the forward vector of the "camera" has no effect on the appearance of crepuscular/anti-crepuscular rays in the real world.

But it makes sence in terms of approximation technique discussed here.
Real world behaviour simulation is quite complex to simulate effeciently, as you know, otherway this topic wouldn't make any sence.

Share this post


Link to post
Share on other sites
Quote:
Original post by ak-73

Okay, so I have actually managed to get a pretty decent corona effect through volumetric light scattering, even if it takes plenty of samples and therefore drains performance a lot to make the effect smoothly...


You can take a page from Crytek's book and get an effective 64-sample blur by doing an 8-sample blur over an 8-sample blur. I've tried the technique, and it works pretty well. In fact, their crepsecular ray effect does just this, albeit 3 times total :)

Share this post


Link to post
Share on other sites
Quote:
Original post by InvalidPointer
Quote:
Original post by ak-73

Okay, so I have actually managed to get a pretty decent corona effect through volumetric light scattering, even if it takes plenty of samples and therefore drains performance a lot to make the effect smoothly...


You can take a page from Crytek's book and get an effective 64-sample blur by doing an 8-sample blur over an 8-sample blur. I've tried the technique, and it works pretty well. In fact, their crepsecular ray effect does just this, albeit 3 times total :)

Right,just cascade cloning of blured images,it's evidently.~256 effective samples usually enough to stretch rays through the whole sky.

Share this post


Link to post
Share on other sites

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