PixelGuys / Cubyz

Voxel sandbox game with a large render distance, procedurally generated content and some cool graphical effects.
GNU General Public License v3.0
420 stars 49 forks source link

Second bounce of light #288

Closed archbirdplus closed 5 months ago

archbirdplus commented 5 months ago

The current lighting algorithm as I understand it imitates a single, direct bounce of light. Each light source emits a light value that propagates and falls off depending on the transparency of the material.

The proposal here is to add perform this algorithm a second time. For each block/face that is illuminated, slash it by some reflectivity value and propagate (in all directions) that light a second time as if it came from a light source. This simulates a second bounce of light. This adds a small amount of realism in certain cases. Suppose you have a green wall by a white floor. The white floor would receive a small tint of green light from the wall. Not knowing the internals of the lighting algorithm, I am not sure whether this would cancel out existing ambient occlusion.

IntegratedQuantum commented 5 months ago

Cubyz uses floodfill lighting. It is a cheap algorithm that only accounts for the brightest light source at a given block.

It is a volumetric and direction independent algorithm. It does not simulate a single direct bounce of light. A better analogy would be saying that the room is filled with a thick white fog, which distributes light in all directions and around corners.

Adding a light source at each block would not make a difference because the algorithm only accounts for the brightest light source and the incoming light is brighter than the proposed secondary light source.