Skip to content

Instantly share code, notes, and snippets.

@snogglethorpe
Last active December 23, 2015 16:49
Show Gist options
  • Save snogglethorpe/6665072 to your computer and use it in GitHub Desktop.
Save snogglethorpe/6665072 to your computer and use it in GitHub Desktop.
Lua intro scene for snogray renderer
-- Lua intro scene for snogray renderer
-- Make some materials
--
matte_grey = material.lambert (0.5)
shiny_blue = material.cook_torrance{ d = {.01, .01, .5}, s = .3, m = .01 }
shiny_red = material.cook_torrance{ d = {.5, .01, .01}, s = .3, m = .01 }
shiny_yellow = material.cook_torrance{ d = {.5, .5, .01}, s = .3, m = .01 }
-- Make some surfaces
--
sphere1 = surface.sphere (shiny_blue, pos (0, 2, 0), 2)
sphere2 = surface.sphere (shiny_red, pos (3, 1, 4), 1)
cyl = surface.solid_cylinder (shiny_yellow, pos (6, 0, 3), vec (0, 3, 0), 1.5)
plane = surface.rectangle (matte_grey, pos (-10, 0, -10),
vec (20, 0, 0), vec (0, 0, 20))
-- Add it all to the scene
--
scene:add (sphere1)
scene:add (sphere2)
scene:add (cyl)
scene:add (plane)
-- Add a light too
--
globe_light = surface.sphere (material.glow (65), pos (-3, 10, -2), 2)
scene:add (globe_light)
-- Setup the camera position
--
camera:move (pos (-15, 10, -2))
camera:point (pos (0, 2, 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment