+ Add noise to nodes
This commit is contained in:
parent
bcba3312f2
commit
f3506c3544
20
init.lua
20
init.lua
|
@ -52,6 +52,10 @@ local get_fog = function( distance )
|
||||||
return clamp( math.pow ( distance / 128, 2 ), 0, 1 )
|
return clamp( math.pow ( distance / 128, 2 ), 0, 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local step = function( value, steps )
|
||||||
|
return math.floor( ( value - math.floor(value) ) * steps ) / steps
|
||||||
|
end
|
||||||
|
|
||||||
local shade = function( origin, target, background_color, liquids )
|
local shade = function( origin, target, background_color, liquids )
|
||||||
local ray = minetest.raycast( origin, target, false, liquids )
|
local ray = minetest.raycast( origin, target, false, liquids )
|
||||||
local color, hit_water
|
local color, hit_water
|
||||||
|
@ -69,7 +73,21 @@ local shade = function( origin, target, background_color, liquids )
|
||||||
pointed_thing.intersection_normal.y * 3 +
|
pointed_thing.intersection_normal.y * 3 +
|
||||||
pointed_thing.intersection_normal.z * 1
|
pointed_thing.intersection_normal.z * 1
|
||||||
) / 12
|
) / 12
|
||||||
local l_color = math.min( base_color * n * light, 255 )
|
local point = pointed_thing.intersection_point
|
||||||
|
local x = step( point.x, 8 )
|
||||||
|
local y = step( point.y, 8 )
|
||||||
|
local z = step( point.z, 8 )
|
||||||
|
local noise = math.floor(
|
||||||
|
(
|
||||||
|
( math.sin(x) * math.tan(z) ) * 65497 +
|
||||||
|
( math.sin(y) * math.tan(x) ) * 65519 +
|
||||||
|
( math.sin(z) * math.tan(y) ) * 65521
|
||||||
|
) / 3
|
||||||
|
) % 16
|
||||||
|
local l_color = math.min(
|
||||||
|
( base_color + noise ) * 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