Fun with light

Implementation

Light sources

In order to imitate the light of force field and laser beam, the new light sources needed to be implemented.

Spherical light

The easiest idea that could came into mind was to implement spherical light source, that returns a direction to the closest point on sphere a.k.a. a direction from point of sphere-line intersection between random point and it's center. With such an idea the area inside the sphere were meant to be lit too. Couple of minutes of coding... and we've got nice, but absolutely useless Disney magic light...

Playing with intensity doesn't work...

At some point I will open a portal to the hell...

Few moments later I decided to scale light intensity not with 1 / sqr(distance), but 1 / (sqr(distance) + 1)

And it was a right choice! Though, all lights can affect volumes, something need to be done with it...

Laser beam

Once we finished with spherical light, we can work with lasers. Just to be fair, an attempt to use super-sampling was done... Not very impressive... I promise to return here, if I need to simulate security lasers like in old spy movies... But we added a light mask to every volume, so different light sources won't mess each other's volume surroundings!

The previous tricks with shortest distance and 1 / (x * x + 1) were used again, and it worked very well. Nice interpolation between kernel and surface colors adds some charm. I will allow you to enjoy some more pictures below... The implementation of spherelight.h and raylight.h can be found in folder ../rt/light.

Some fun with light...

You can always get some funny images just playing around with your parameters, like creating too absorbing fog, setting color to negative values or watching memes too much...

Black laser... That is... fun...

I regret nothing...