Question about light diffraction

Hi,

i have couple questions about light itself in the game. To be exact i mean light source blocks like gleams, lanterns, torches.

Ive noticed that if u place a light source for example on the wall, then in front of it u will build another wall lets say 5x5 (size doesnt matter) and u make a one block whole in the middle then light from the back wall will strangly iuminate all blocks of the front wall while it should illuminate only inner sides of the blocks in the whole. front side of the front wall shouudnt be illuminated, or at least not so much as it is now. it seems like solid blocks let light pass through them if there is hole nearby.

If my example is confusing ill explain in some other way :slight_smile:

@james @lucadeltodecso

Can you please explain how game engine process light? Thanks in advance :slight_smile:
as a addition ill post some nice effect i managed to get:

8 Likes

Block lighting is performed via a flood-fill (so will bend around corners and even go full 180 degrees if you were to consider just a single block light) that populates each block-position with a block-lighting colour with no directional information when the chunk mesh is created. This is done for all the block lights at the same time effectively, not 1 light at a time.

We do try to infer some degree of directional data from the “result” of all the flood-fills (based on luminance gradients) to provide some hints for normal mapping to avoid indoor environments looking flat, but can never be accurate enough to not allow what you show in the screenshots. Eg the face of your wall is lit because the block-positions infront of the face have green-block-light.

Lighting is already one of the most expensive parts of the mesh creation process, its unlikely it will get changed much in future.

7 Likes

so it is different process then global lightning from “sun” in the game cause light from sun as in otherr games light everything but is shaded and dimmed from the “north” side and i know that shadows are completly different thing. but it would be nice if it would work the same with light source blocks ( i mean the light occlusion and intensity changes.

1 Like

The sun light is a hybrid, the intensity is flood-filled as though any position unblocked vertically to the sky is a ‘sun light block’ , but colour/direction comes from the day night cycle dynamic in-shader.

They can never work exactly the same as block lights are static in colour and unbounded in number, but sun is dynamic in colour but singular in count. (Not saying it’s impossible to improve, just impossible to do the exact same way)

4 Likes

I see. But will you ever think of changing the flood-fill argorythm to any other? from what i recall it is heavy for engine, cause very often it calculates same pixels many times.

1 Like