require "Textures"
local T = Textures
-local eps = 0.01
+local eps = 0.001
local max_dist2 = 30^2
local bg_col = {0.1,0.1,0.1}
local function calculate_normal(sdf, l)
- local delta = 1e-3;
+ local delta = eps/10
return V.new{sdf(l+V.x*delta).dist-sdf(l-V.x*delta).dist,
sdf(l+V.y*delta).dist-sdf(l-V.y*delta).dist,
sdf(l+V.z*delta).dist-sdf(l-V.z*delta).dist}/(2*delta)
local normalize = V.normalize -- optimization
for y=1,height do
-
if y % math.floor(height/10) == 0 then
print(y/math.floor(height/10) * 10 .. "%")
end
local light_dir = (light-location)/light_dist
local vis = light_visibility(location + light_dir*eps, light_dir, eps, light_dist, 1, sdf)
+ -- local vis = 1.0
local Idiff = math.max(normal*light_dir, 0)
local Ispec = math.pow(math.max(light_dir*reflected_ray,0),shiny)