Added SDF operations.
[raymarcher.git] / Operations.lua
1 -- Package of geometric operations on SDF objects
2
3 local function union(s1, s2)
4    return function (location)
5       local p1 = s1(location)
6       local p2 = s2(location)
7
8       if p1.dist < p2.dist then
9          return {dist = p1.dist, texture = p1.texture}
10       else
11          return {dist = p2.dist, texture = p2.texture}
12       end
13    end
14 end
15
16 Operations = {
17    union = union
18 }
19
20 return Operations