Render is now its own package.
[raymarcher.git] / holy_sphere.lua
1 require "Vector"
2 local V = Vector
3
4 require "Primitives"
5 local P = Primitives
6
7 require "Operations"
8 local O = Operations
9
10 require "Textures"
11 local T = Textures
12
13 require "Render"
14
15 local lights = {V.new{3,-3,1}}
16
17 local scene = {
18    sdf =
19       O.union(
20          O.diff(
21             O.diff(
22                O.diff(
23                   P.make_sphere(V.new{0,0,0}, 1,
24                                 T.make_phong_texture(lights,
25                                                      T.make_solid_pigment({0,1,0}),
26                                                      0.2, 0.7, 1.0, 100)),
27                   P.make_sphere(V.new{0,0,0}, 0.8)),
28                P.make_pipe(V.new{0,0,0}, 0.5, V.new{0,1,0})),
29             P.make_pipe(V.new{0,0,0}, 0.5, V.new{1,0,0})),
30
31          P.make_plane(V.new{0,0,-1.0}, V.new{0,0,1},
32                       T.make_phong_texture(lights,
33                          T.make_checkered_pigment({0.5,0,0.2}, {1,1,1}),
34                          0.2, 1.0, 0, 1))),
35                                
36    camera = {location = V.new{2,-5,1},
37              point_at = V.new{0,0,0},
38              right = V.x,
39              fov = 1}}
40
41 Render.render(scene, 1280, 960, "holy_sphere.ppm")