pouët.net

[Ray Marking] Cheap/Fake Global Illumination

category: code [glöplog]
 
Just wanted to post a hack I made, I couldn't find anything while searching the boards on this so I hope its something new, hopefully someone can expand it further.

Images of a very basic implementation:

BB Image

BB Image

BB Image

The concept is really simple and builds off the well known AO hack:

Code: float ambientOcclusion(vec3 p, vec3 n) { float ao = 0.0, d; for (float i = 1.0; i <= samples; i++) { d= stepDistance * i; ao += (dist - map(p + n * dist, returnColor)) / i; } return ao; }


modified to become the following:

Code: vec3 globalIllumination(vec3 p, vec3 n) { vec3 g = vec3(0.0); float dist; for (float i = 1.0; i <= samples; i++) { dist = stepDistance * i; float d = vec3(dist - map(p + n * dist, returnColor)); g += returnColor*d/ i; } return g; }


returnColor is set in your scene/map function

The rest of the vars should be self explanatory.

Then you just add the calculated GI term (clamp/scale/modify) to your lighting and voila! Fake GI that looks nice sometimes and its no more expensive than an AO pass. (Note, this is only single bounce, no reflection pass)

Enjoy!

-tz
added on the 2012-10-26 04:48:22 by tz tz
yep. Auld and I played with this idea three or four years ago. We did it by multipliying by 1 - gatherColor, though. Also, there's the extension of SSAO to screen space color bleeding (http://www.mpi-inf.mpg.de/~ritschel/Papers/SSDO.pdf), which is another idea to use whatever cheap AO technique you have to gather color info and do color bleeding. That being said, I don't know if any 4k intro has used it yet (i haven't myself in any demo/intro)
added on the 2012-10-26 07:20:35 by iq iq
you really should be more concerned about some interresting scenery :)
added on the 2012-10-26 08:46:22 by maytz maytz
Anyone has some hours of time to try this proposal on slisesix? :) would love to see the results!
added on the 2012-10-26 12:04:37 by xTr1m xTr1m
I'd suggest changing strategy of setting returnCollor in the map function. Currently you return whatever color of the nearest object is. If you did a proportional lerp it would help reduce the artifacts - especially the one seen as sharp transition between red wall and blue brick.
added on the 2012-10-26 12:41:04 by KK KK
neat idea, but I think it looks like ass :)
added on the 2012-10-26 13:14:25 by ferris ferris
yes, doesn't look that good, at least on the test scene.
added on the 2012-10-26 13:23:37 by xernobyl xernobyl
Not only auld and IQ played with that idea. ;)

It just looks not very convincing. Maybe with some more samples over a hemisphere this could be way better. Maybe even some kind of mixing this with some stochastic sampling and some screen space post blur/low pass filtering could do a way better job. Maybe what KK recommends could also help it a lot (also take the second closest object color into account and lerp or something).

Try it all and post screenshots of it - we are interested ;)
added on the 2012-10-26 14:52:41 by las las
No GL
BB Image

w/ mild lerp
BB Image

The issue with any interpolation is that you end up sampling from objects that may not be in visible to current position in the raymarch, e.g. the left wall sampling the sphere when the box is in the way.
added on the 2012-10-26 21:15:59 by tz tz
threshold with a max influence radius using smoothstep.
added on the 2012-10-26 21:20:42 by las las
I think whatever you do with this method, there are going to be artefacts. You'll need multiple rays to get a 'decent' effect that correctly accounts for multiple objects, occlusion etc.

If that's not practical, you can probably get away with even the first method, careful scene design, and turning the effect down a bit. You want a strong effect when you're testing like this, but something more subtle tends to look better - and hides the defects :)

Btw, for this particular test scene a simple raytrace would be much faster and would probably let you use multiple rays in realtime for a couple of light bounces :)
added on the 2012-10-27 00:00:16 by psonice psonice
LGTM
added on the 2012-10-27 00:17:15 by mrdoob mrdoob
Yeah, that looks much nicer now :)
added on the 2012-10-27 00:21:35 by raizor raizor
LGTBW.

("Looks Good To Be WebGL" :)
added on the 2012-10-27 12:06:24 by gloom gloom
Btw: unless my mind just messes with my memory, this demo is filled to the brim with fake SSAO-based light emission stuff, as well as some raytracing in places.
added on the 2012-10-27 12:08:07 by gloom gloom
looks good (the last one especially). if it's as cheap as an SSAO pass, thumb up!
Also, is it compatible with a polygon render, or only with raymarching ?
added on the 2012-10-28 06:48:41 by BarZoule BarZoule
... its not SS as it uses color information gathered during raymarch from away from the normal.

This works well if you can get away with using simple colors. With procedural textures you have to gather object contribution to color rather than the actual color at each step then compute the GI color after the march. But then this means you'd have to compute potentially many procedural textures at every pixel (so average color should rather be used instead if the textures are expensive).
added on the 2012-10-28 21:20:15 by tz tz

login