Post by Jamis on Nov 24, 2018 0:35:41 GMT
Following is the scene description for the image at the start of chapter 12, "Cubes". It renders the following picture, constructed entirely of cubes:

As with the other scenes I've shared here, it described in YAML format, which is hopefully self-explanatory, but if something doesn't make sense, please let me know. Also, note that the cube labeled "glass cube" (the yellow one in the middle of the table) employs an optional feature: it casts no shadow, by opting out of the shadow tests. If you have not implemented this optional feature in your own ray tracer, just ignore the "shadow: false" line in the scene description, below.

As with the other scenes I've shared here, it described in YAML format, which is hopefully self-explanatory, but if something doesn't make sense, please let me know. Also, note that the cube labeled "glass cube" (the yellow one in the middle of the table) employs an optional feature: it casts no shadow, by opting out of the shadow tests. If you have not implemented this optional feature in your own ray tracer, just ignore the "shadow: false" line in the scene description, below.
# ======================================================
# table.yml
#
# This file describes the scene illustrated at the start
# of chapter 12, "Cubes", in "The Ray Tracer Challenge"
#
# by Jamis Buck <[email protected]>
# ======================================================
# ======================================================
# the camera
# ======================================================
- add: camera
width: 400
height: 200
field-of-view: 0.785
from: [8, 6, -8]
to: [0, 3, 0]
up: [0, 1, 0]
# ======================================================
# light sources
# ======================================================
- add: light
at: [0, 6.9, -5]
intensity: [1, 1, 0.9]
# ======================================================
# describe the elements of the scene
# ======================================================
# floor/ceiling
- add: cube
transform:
- [ translate, 0, 1, 0 ]
- [ scale, 20, 7, 20 ]
material:
pattern:
type: checkers
colors:
- [0, 0, 0]
- [0.25, 0.25, 0.25]
transform:
- [ scale, 0.07, 0.07, 0.07 ]
ambient: 0.25
diffuse: 0.7
specular: 0.9
shininess: 300
reflective: 0.1
# walls
- add: cube
transform:
- [ scale, 10, 10, 10 ]
material:
pattern:
type: checkers
colors:
- [ 0.4863, 0.3765, 0.2941 ]
- [ 0.3725, 0.2902, 0.2275 ]
transform:
- [ scale, 0.05, 20, 0.05 ]
ambient: 0.1
diffuse: 0.7
specular: 0.9
shininess: 300
reflective: 0.1
# table top
- add: cube
transform:
- [ scale, 3, 0.1, 2 ]
- [ translate, 0, 3.1, 0 ]
material:
pattern:
type: stripes
colors:
- [ 0.5529, 0.4235, 0.3255 ]
- [ 0.6588, 0.5098, 0.4000 ]
transform:
- [ rotate-y, 0.1 ]
- [ scale, 0.05, 0.05, 0.05 ]
ambient: 0.1
diffuse: 0.7
specular: 0.9
shininess: 300
reflective: 0.2
# leg #1
- add: cube
transform:
- [ scale, 0.1, 1.5, 0.1 ]
- [ translate, 2.7, 1.5, -1.7 ]
material:
color: [ 0.5529, 0.4235, 0.3255 ]
ambient: 0.2
diffuse: 0.7
# leg #2
- add: cube
transform:
- [ scale, 0.1, 1.5, 0.1 ]
- [ translate, 2.7, 1.5, 1.7 ]
material:
color: [ 0.5529, 0.4235, 0.3255 ]
ambient: 0.2
diffuse: 0.7
# leg #3
- add: cube
transform:
- [ scale, 0.1, 1.5, 0.1 ]
- [ translate, -2.7, 1.5, -1.7 ]
material:
color: [ 0.5529, 0.4235, 0.3255 ]
ambient: 0.2
diffuse: 0.7
# leg #4
- add: cube
transform:
- [ scale, 0.1, 1.5, 0.1 ]
- [ translate, -2.7, 1.5, 1.7 ]
material:
color: [ 0.5529, 0.4235, 0.3255 ]
ambient: 0.2
diffuse: 0.7
# glass cube
- add: cube
transform:
- [ scale, 0.25, 0.25, 0.25 ]
- [ rotate-y, 0.2 ]
- [ translate, 0, 3.45001, 0 ]
shadow: false
material:
color: [1, 1, 0.8]
ambient: 0
diffuse: 0.3
specular: 0.9
shininess: 300
reflective: 0.7
transparency: 0.7
refractive-index: 1.5
# little cube #1
- add: cube
transform:
- [ scale, 0.15, 0.15, 0.15 ]
- [ rotate-y, -0.4 ]
- [ translate, 1, 3.35, -0.9 ]
material:
color: [1, 0.5, 0.5]
reflective: 0.6
diffuse: 0.4
# little cube #2
- add: cube
transform:
- [ scale, 0.15, 0.07, 0.15 ]
- [ rotate-y, 0.4 ]
- [ translate, -1.5, 3.27, 0.3 ]
material:
color: [1, 1, 0.5]
# little cube #3
- add: cube
transform:
- [ scale, 0.2, 0.05, 0.05 ]
- [ rotate-y, 0.4 ]
- [ translate, 0, 3.25, 1 ]
material:
color: [0.5, 1, 0.5]
# little cube #4
- add: cube
transform:
- [ scale, 0.05, 0.2, 0.05 ]
- [ rotate-y, 0.8 ]
- [ translate, -0.6, 3.4, -1 ]
material:
color: [0.5, 0.5, 1]
# little cube #5
- add: cube
transform:
- [ scale, 0.05, 0.2, 0.05 ]
- [ rotate-y, 0.8 ]
- [ translate, 2, 3.4, 1 ]
material:
color: [0.5, 1, 1]
# frame #1
- add: cube
transform:
- [ scale, 0.05, 1, 1 ]
- [ translate, -10, 4, 1 ]
material:
color: [ 0.7098, 0.2471, 0.2196 ]
diffuse: 0.6
# frame #2
- add: cube
transform:
- [ scale, 0.05, 0.4, 0.4 ]
- [ translate, -10, 3.4, 2.7 ]
material:
color: [ 0.2667, 0.2706, 0.6902 ]
diffuse: 0.6
# frame #3
- add: cube
transform:
- [ scale, 0.05, 0.4, 0.4 ]
- [ translate, -10, 4.6, 2.7 ]
material:
color: [ 0.3098, 0.5961, 0.3098 ]
diffuse: 0.6
# mirror frame
- add: cube
transform:
- [ scale, 5, 1.5, 0.05 ]
- [ translate, -2, 3.5, 9.95 ]
material:
color: [ 0.3882, 0.2627, 0.1882 ]
diffuse: 0.7
# mirror
- add: cube
transform:
- [ scale, 4.8, 1.4, 0.06 ]
- [ translate, -2, 3.5, 9.95 ]
material:
color: [0, 0, 0]
diffuse: 0
ambient: 0
specular: 1
shininess: 300
reflective: 1