Simple Global Illumination

I’ve read many global illumination techniques and they all seems complicated even thought they are pretty simple. It’s all about bouncing. And doesn’t unity support bouncing physics? Yeah it does.

So, create ultralow poly version of your map (based on few cubes or planes) and you assign a cube collider with bouncy material.

Then , create a light source. A script should instantiate a bunch of balls (spheres) which will be pushed to the light direction. When the ball collides with something , it carries it’s color (using rays and texture position) and shines with it with the next bounces. As there are more bounces , the importance of the sphere / the intensity gets lower.

Of course , there is 15 fps drop :frowning: .

When I finish this technique i will release it. I downloaded some small room scene and tested:

You can see , at 50 bounces there are so much spheres , that the ones that collide near the fireplace can lit up really far (check the ground plane)

Looks interesting. With 10 bounces it already looks decent.

The bounces only define the precision , you could adjust the brightness so you have few points but they are bright and the scene will be ok.

At the moment the cons are:

  • can’t work with terrain
  • you must check readable for all your textures if you want the proper lighting color
  • it’s not very performance cheap , even though it might make awful results in some scenes

Does each bounce reduce the brightness of the ball? Does the ball know the brightness of the material it bounces on? A black wall would absorb most of the light and could eliminate the simulation of that ball as its brightness would all be taken up by the material.

Even 5 bounces would work I think, it would add a decent effect.

Would there be an option to thread the process?

How exactly do you “paint” the final color onto the texture? I get the picking up texture color/bouncing part, but how do you apply the final result, exactly?

It has no idea about the brightness of the material :frowning:

And it does the painting using RayCastHit.textureCoord and a shader.

Are the balls really necessary? Wouldn’t it be much faster to just do a Physics.Raycast from the light source, then for each ray (and for each number of bounces) shoot another ray from the hit point, towards the reflected direction (Found using Vector3.Reflect)?

Each ray would carry its intensity and color, and as it bounces, it would leave some intensity and carry off some color.

It’s about the same thing, only sans balls. :wink:

Cheers

I didn’t know about Vector3.Reflect… I thought I must do the math myself. By using .Reflect that’s even easier.

please nead test !

The math itself isn’t that bad either, to reflect a vector, you just rotate it 180° along the normal, like this:

reflectedVector = Quaternion.AngleAxis(180f, surfaceNormal) * inboundVector;

Cheers

Hoping for source

please share some source code :slight_smile:

look great