Global illumination?

BlitzMax Forums/BlitzMax Programming/Global illumination?

JoshK(Posted 2007) [#1]
If I understand correctly, this is how to do GI:

-Render direct lighting using a raytracer.
-Render the scene from the view of each luxel, and take the average pixel color from that...

Then what? If I add that value, bright areas of the map become twice as bright. If I scale it to lessen the value, dark areas don't get lit much. The results I am getting just don't look right, and it creates many strange artifacts.

It seems like rendering from the luxel position doesn't really account for the way light bounces off surfaces.




Gabriel(Posted 2007) [#2]
I use it as the ambient factor. Set a global ambient which you then multiply by your global illumination pass, and use the result as the ambient in your traditional lightmapping/lighting equation.


JoshK(Posted 2007) [#3]
It seems like the mathematically correct way to do this would be to bounce the rays off surfaces and add them to wherever they hit. I don't think rendering the scene from the luxel position is even close to realistic.


AramusM(Posted 2007) [#4]
If you bounced rays off a surface and added them to whatever they hit wouldnt you want an attenuation factor taking into account the distance from the reflecting texel and the receiving luxel? The attenuation factor being based on the emissivity and specularity of the surface?

I could be talking out my arse, its been many years since I looked at raytracing back on my old Amiga.


JoshK(Posted 2007) [#5]
I think the primary problem would be your rays would scatter, and you would get dots of light.

I'll put this away for now and maybe take another try later.


fredborg(Posted 2007) [#6]
You need render a hemi-cube (half a cubemap) from each texel, and then weight each pixels acording to the angle between the texel normal and the view direction (dot product). Then just add the result back to the texel (lightmap for instance) color. You may want to wait with updating your lightmap until all the rendering is completed to avoid the render pass to self-influence.

It's very simple, and can be written in around 50 lines of code.

You can find a good introduction to this method here:
http://freespace.virgin.net/hugo.elias/radiosity/radiosity.htm


JoshK(Posted 2007) [#7]
What do you do, just use a really low camera zoom? The paraballoid rendering they show won't work without highly tesselated geometry.


fredborg(Posted 2007) [#8]
Try scrolling down the page a bit :)


JoshK(Posted 2007) [#9]
Thanks for the tips.

The big problem I was seeing was that GI would cause bright areas to get uncontrollably bright. So I added a threshold value above which GI would no longer be calculated. Here, only luxels darker than 64 will be brightened with GI. It makes the dark areas get new lighting and shadows, and keeps the bright areas the same:

Global illumination:


Direct lighting only:



ImaginaryHuman(Posted 2007) [#10]
If my vague understanding is correct, and I have never coded this whatsoever, lighting is more of a holographic system. The light at each point in space is the total contribution from every other point in space including all light that is reflected off of or filtered through everything else. Ie the light which is `everywhere` is in the `part` and vice versa. It is also necessary that every single point in space be calculated simultaneously in order for there to be a global accumulation of light. Anything less than that is an approximation and achieving that accuracy/correctness is probably not feasible with any computer.

You are slightly aided by time, in that light rays seem to take time to travel a distance rather than be everywhere instantly, which partly `localizes` their influence. Maybe you can play on that.

How to do this technically in an approximate or visually pleasant and fast enough way seems to be an erea of considerable ongoing research at the moment. Good luck with it.


North(Posted 2007) [#11]
Hey Josh,

i don't think this strategy is playing out well. Looking at your last screenshots you lost visual quality due to a much lesser tonal range in the image - this seems to be a direct result of brightening darker areas with GI only. Especially look at edges and into the distance. The areas with normally high occlusion of light get overly exposed now.

Infact your initial screenshot looks the best in this regard. Are you in some way applying the techniques found in the paper on radiosity linked above? I think the parts about Lambert's Cosine Law are an interesting approach.

I hope you find a smart way of applying GI lighting - Loved your first screeny :)