+ Add normal-based coloring
This commit is contained in:
parent
74b3200230
commit
ffdc5db2c6
8
init.lua
8
init.lua
|
@ -63,7 +63,13 @@ local shade = function( origin, target, background_color )
|
||||||
local light = get_light( pointed_thing.above )
|
local light = get_light( pointed_thing.above )
|
||||||
local distance = vector.distance ( position, origin )
|
local distance = vector.distance ( position, origin )
|
||||||
local fog = get_fog( distance )
|
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(
|
color = math.floor(
|
||||||
l_color * ( 1 - fog ) +
|
l_color * ( 1 - fog ) +
|
||||||
background_color * fog
|
background_color * fog
|
||||||
|
|
Loading…
Reference in New Issue