Scattering Light in Unity3d

Started by
7 comments, last by Willywill 9 years, 4 months ago

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

Advertisement

You could use something like reflective shadow mapping. http://www.vis.uni-stuttgart.de/~dachsbcn/download/rsm.pdf

Do you need this to be dynamic (e.g. need to be able to move that light source)?

AFAIK, you can do this for non-dynamic scenes in Unity already, by using their light-probes system.

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.

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

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.

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

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

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

This topic is closed to new replies.

Advertisement