Sign in to follow this  
ken2240

How implements Sun Shafts[S.T.A.L.K.E.R.: Clear Sky Method]

Recommended Posts

Hi, All

I know how to implement the Sun Shafts of screen space that is used in CryEngine.

However, this way is ineffective if the sun does not exist in a screen.

I want to implement a Sun Shafts that are used in the Stalker.

How does this method implement it?

If you may know some, please teach me.

I am glad when there are documents and source code.

Share this post


Link to post
Share on other sites
there are a few demos with full source code in google just search 'screen space god rays' or 'screen space sun-shafts' and look at results on first page. I have used those when making it in my engine.

Share this post


Link to post
Share on other sites
One technique to get volumetric shadows / godrays that are present even when the light source is not visible is marching through the shadowmap.
So for sun/directional light for example you would do a full screen pass, potentially downres-ed for performance reasons, where for each pixel you step through the scene from pixel pos to scene pos, sampling the shadow map at each step. This gives you the atmosphere amount in shadow.

Share this post


Link to post
Share on other sites
[URL=http://imageshack.us/photo/my-images/706/godrays.png/][IMG]http://img706.imageshack.us/img706/7858/godrays.png[/IMG][/URL]
Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]
You mean this? Ray marching is the way to go! It's not even that expensive compared to a radial blur as long as you use a small shadow map. You can even do it in half resolution and blur it like SSAO.

Share this post


Link to post
Share on other sites
Kenny Mitchell published an article in GPU Gems 3, called [url="http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html"]Volumetric Light Scattering as a Post-Process[/url].
There is also some code in this chapter.
Best regards

Share this post


Link to post
Share on other sites
I posted something similar on my blog some time ago:

[url="http://jcoluna.wordpress.com/2012/06/05/light-shafts-tone-mapping/"]jcoluna.wordpress.com/2012/06/05/light-shafts-tone-mapping/[/url]

The source code+assets are available for download, hope it helps.
-J.Coluna Edited by Coluna

Share this post


Link to post
Share on other sites
The problem with those techniques vs the marching through the SM is that you need a visible light source on screen / occluders on screen to get proper light shafts.
Using the shadow map information means they will be correct regardless of where the light source and occluders are. Your main issue becomes dealing with occluders which are not in the sm range. You can also use the ray marching pass to compute atmospheric scattering, which is a nice added bonus.

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