Crepuscular rays/Volumetric light scattering

Started by
13 comments, last by Krokhin 15 years ago
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
Advertisement
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
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
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.
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]
Would you like to share mentioned technique?
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.
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
"
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]
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

This topic is closed to new replies.

Advertisement