Welcome to Fractal Forums

Fractal Software => Programming => Topic started by: eiffie on March 20, 2012, 06:26:43 PM




Title: fake emissive material
Post by: eiffie on March 20, 2012, 06:26:43 PM
I wanted a way to place lit objects in a scene rendered with GLSL but didn't want to do global illumination or slow down the scripts too much. I decided to try a hack and simply calculate the closest point of light and base the lighting calculations on that. You simply add another DE (distance estimation) function for the light. Call it "DEL". You can use this function to calculate the nearest light direction similar to calculating the surface normal, only use the distance to the light as the delta like this:

vec2 vt=vec2(DEL(ray),0.0);
lightDir=normalize(vec3(-DEL(ray-vt.xyy)+DEL(ray+vt.xyy),
   -DEL(ray-vt.yxy)+DEL(ray+vt.yxy),
   -DEL(ray-vt.yyx)+DEL(ray+vt.yyx)));

You then continue with lighting calculations as you normally would. You can also use this distance to determine light fall-off and bloom. The cons are unrealistic lighting in some circumstances particularly with long shadows but the pros are infinite fractal lighting with one set of lighting calculations :)

The video shows the worst case scenario (moving lights on both sides of objects casting shadows) and then how I want to use it by placing lights in fractal patterns.

http://www.youtube.com/watch?v=MHRyWjRp3rY

Since I don't see many examples of emissive light I would appreciate any input of ideas!


Title: Re: fake emissive material
Post by: cKleinhuis on March 20, 2012, 08:49:38 PM
would love to create a demo for a real-demo competition like breakpoint, as an collective effort of the forums ....
hybrid realtime fractals, emissive materials ... REALTIME!° that would be nice, you could also gather and create a nice ff wild entry ;)
dunno exactly where next demo party will be ...


Title: Re: fake emissive material
Post by: marius on March 21, 2012, 05:10:18 AM
The video shows the worst case scenario (moving lights on both sides of objects casting shadows) and then how I want to use it by placing lights in fractal patterns.

You'd have to define a DE per light or group of lights, no? Otherwise it's hard to see how you'd get multiple highlights or shadows.

How do you do the shadow using a single DE call? Or is that result of a full march towards the nearest light as usual?


Title: Re: fake emissive material
Post by: hobold on March 21, 2012, 01:24:55 PM
For a quick and dirty hack, this works much better than I would have expected. The first half of the test video is indeed a worst case (and even that works somewhat), but the second half looks convincing.


Title: Re: fake emissive material
Post by: eiffie on March 21, 2012, 04:27:21 PM
That would be a fun project!

The shadows are indeed ray-marched. By "single lighting calculation" I meant as if there was ONE light. If you had to ray-march to each of the lights even on a GPU it would takes days to render. That was the point of the hack and I was happy with the results and how easy it was to implement.

It would be nice if there was an easy way to do lighting as we do ambient occlusion. Head off in a few directions and average the results but direction is critical in lighting.