diff --git a/README.md b/README.md index 2d5d125..a7a60ae 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ A ray marching renderer in rust ![3rd test scene](prod/3.png) ![randomly generated spheres](prod/randomspheres.png) ![randomly generated objects](prod/smolgalaxy.png) +![inside a spherical mirror](prod/insidemirror.png) ## License MIT diff --git a/prod/insidemirror.png b/prod/insidemirror.png new file mode 100644 index 0000000..fad4a33 Binary files /dev/null and b/prod/insidemirror.png differ diff --git a/scenes/insidemirror.lua b/scenes/insidemirror.lua new file mode 100644 index 0000000..4f24488 --- /dev/null +++ b/scenes/insidemirror.lua @@ -0,0 +1,42 @@ +local mirror = obj.withmaterial( + obj.negation( + obj.sphere(vec3.O, 8) + ), + material.newfromdiagonal( + colorvec.new(0, 0, 0, 0), + colorvec.new(1, 1, 1, 1), + surfacetype.REFLECTIVE + ) +) + +local objects = { + obj.withmaterial( + obj.torus(vec3.new(1, 0, -3), 2, 1), + material.newfromdiagonal( + colorvec.new(1, .5, .2, 0), + colorvec.new(1, 1, 1, 1), + surfacetype.DIFFUSE + ) + ), + obj.withmaterial( + obj.sphere(vec3.new(3, 2, 0), 1), + material.newfromdiagonal( + colorvec.new(0, 0, 0, 0), + colorvec.new(.2, .5, 1, 0), + surfacetype.DIFFUSE + ) + ), + obj.withmaterial( + obj.cuboid(vec3.new(-3, -1, 2), vec3.new(1, 1, 1)), + material.newfromdiagonal( + colorvec.new(0, 0, 0, 0), + colorvec.new(.2, 1, .5, 0), + surfacetype.DIFFUSE + ) + ) +} + +return obj.union( + util.union(objects), + mirror +) \ No newline at end of file diff --git a/src/lua/obj.rs b/src/lua/obj.rs index 5b51bcf..f3eb2dc 100644 --- a/src/lua/obj.rs +++ b/src/lua/obj.rs @@ -46,6 +46,10 @@ pub fn obj<'lua>(ctx: Context<'lua>, _env: Table<'lua>) -> rlua::Result