+ Add normal-based coloring

This commit is contained in:
Nils Dagsson Moskopp 2023-11-09 15:42:37 +01:00
parent 74b3200230
commit ffdc5db2c6
Signed by: erle
GPG Key ID: A3BC671C35191080
1 changed files with 7 additions and 1 deletions

View File

@ -63,7 +63,13 @@ local shade = function( origin, target, background_color )
local light = get_light( pointed_thing.above )
local distance = vector.distance ( position, origin )
local fog = get_fog( distance )
local l_color = base_color * light
-- TODO: proper lighting based on sun position (LOL)
local n = 1 + (
pointed_thing.intersection_normal.x +
pointed_thing.intersection_normal.y * 3 +
pointed_thing.intersection_normal.z * 1
) / 12
local l_color = math.min( base_color * n * light, 255 )
color = math.floor(
l_color * ( 1 - fog ) +
background_color * fog