Colours are now Vectors, added rainbow pigment.
[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             P.make_sphere(V.new{0,0,0}, 1,
22                           T.make_phong_texture(lights,
23                                                T.map_spherical(
24                                                   T.make_solid_pigment({0,1,0}),
25                                                   V.origin, 1, 1),
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.map_rectangular(
34                                               T.make_checkered_pigment({0.5,0,0.2}, {1,1,1}),
35                                               V.x, V.y),
36                                            0.2, 1.0, 0, 1))},
37                                
38    camera = {location = V.new{2,-5,1},
39              point_at = V.new{0,0,0},
40              right = V.x,
41              fov = 1}}
42
43 Render.render(scene, 1280, 960, "holy_sphere.ppm")