Sign in to follow this  

Scattering Light in Unity3d

This topic is 1108 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 guys, Im attempting to do a Global Illumination like technique (not really Global Illumination, but something I wanted to try out)

 

Method

026fda645b.png

 

Problem

 

Yet not being a shader genius but with intermediate knowledge, I'm not sure where to start. I believe what I'm supposed to do is if a normal or vertex has an attenuation or intensity more than 0.01 (or a controllable value) create a ray and perform a ray march from that point and until it hits another normal, subtract the scattering intensity by 0.1 (or a controllable variable) until it becomes 0.

 

However, using a pixel shader Im not sure how to convert all of that meat generated thoughts into code.

 

EDIT:
I should note in unity3d, you cannot access shadow maps

Edited by Frostbite23

Share this post


Link to post
Share on other sites

Hi, Hodgman

I forgot to state that I need this to be dynamic.

 

kalle_h

Ive Known about reflective shadow maps but If I were to do that I would need to create my own renderer which for being a minor intermediate shader artist I have no idea on how to do that.

Edited by Frostbite23

Share this post


Link to post
Share on other sites

Hi,

 

I don't think what you are trying to do can be accomplished by a pixel shader only.

 

To do what you want you would have to be able to perform a scatter write (ie write output to multiple pixels from a single pixel shader run), and you would need access to the full rendergraph (all triangles and their materials) to be able to perform the ray marching.

 

In a pixel shader you can only do a gather write, so you would have to trace backwards from the pixel you want to shader. And for that you still need access to the rendergraph.

 

The closest solution I can think of is to somehow expand the Screen Space Ambient Occlusion algorithm to do multiple bounces when tracing. But I think the results will be too affected by the missing offscreen info.

 

Henning

Share this post


Link to post
Share on other sites

 

The closest solution I can think of is to somehow expand the Screen Space Ambient Occlusion algorithm to do multiple bounces when tracing. But I think the results will be too affected by the missing offscreen info.

 

Henning

 

What about this solution? It's funny because I'm actually working on raymarched screen space reflections as some of you may have seen, but this could be a decent solution if the light bleeding and noise issues can be resolved.

Share this post


Link to post
Share on other sites

I still believe such a solution will be too unstable as soon as the camera starts to move. I've seen other implementations of screen space GI, but lighting starts flickering quite badly as soon as the camera moves.

 

But then again this might be tolerable/controllable depending on what requirements Frostbite23 has to the scene.

 

Henning

Share this post


Link to post
Share on other sites

Bart Wronski demostrate temporal supersampling with ssao here.

 

http://bartwronski.com/2014/04/27/temporal-supersampling-pt-2-ssao-demonstration/

 

This also work great on screenspace bounce light. In our early access game Hardland we use this kind of technique and its does not even need spatial blurring and its stable. But all screenspace techniques are limited to quite low range.(we use about 2m) so the effect is pretty local even in the best case.

 

https://www.dropbox.com/s/nnn5amo3edbpbxf/ScreenspaceOcclusion.png?dl=0

https://www.dropbox.com/s/8fdoy3d729o05jd/ScreenspaceOcclusionWithBounceLight.png?dl=0

Edited by kalle_h

Share this post


Link to post
Share on other sites

 

Bart Wronski demostrate temporal supersampling with ssao here.

 

http://bartwronski.com/2014/04/27/temporal-supersampling-pt-2-ssao-demonstration/

 

This also work great on screenspace bounce light. In our early access game Hardland we use this kind of technique and its does not even need spatial blurring and its stable. But all screenspace techniques are limited to quite low range.(we use about 2m) so the effect is pretty local even in the best case.

 

https://www.dropbox.com/s/nnn5amo3edbpbxf/ScreenspaceOcclusion.png?dl=0

https://www.dropbox.com/s/8fdoy3d729o05jd/ScreenspaceOcclusionWithBounceLight.png?dl=0

 

 

Wow, looks pretty good and is easy to integrate. I might even use this idea, thanks! :D

Share this post


Link to post
Share on other sites

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