Skip to content

Commit

Permalink
Add cornell scene
Browse files Browse the repository at this point in the history
This includes a bunch of variants on the standard cornell box, uploaded at https://github.com/jvm-graphics-labs/awesome-3d-meshes/tree/master/McGuire. I had to add a hack to the obj loader to start supporting reflective surfaces.
  • Loading branch information
banga committed Jan 29, 2024
1 parent 37e8156 commit faa2f52
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
33 changes: 33 additions & 0 deletions scenes/cornell.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
num_samples: 16,
max_depth: 8,
camera: Perspective {
origin: Point(0, 1, -2.8),
target: Point(0, 1, 0),
up: Vector(0, 1, 0),
fov: 60,
film: {
width: 400,
height: 400,
}
},
lights: [
],
materials: {
default: Matte { reflectance: Color(1, 1, 1), sigma: 0 }
},
shapes: {
},
primitives: [
// Source: https://github.com/jvm-graphics-labs/awesome-3d-meshes/
Mesh { file_name: 'objs/local/cornell/CornellBox-Original.obj', fallback_material: 'default' },
// Mesh { file_name: 'objs/local/cornell/CornellBox-Sphere.obj', fallback_material: 'default' },
// Mesh { file_name: 'objs/local/cornell/CornellBox-Empty-CO.obj', fallback_material: 'default' },
// Mesh { file_name: 'objs/local/cornell/CornellBox-Empty-RG.obj', fallback_material: 'default' },
// Mesh { file_name: 'objs/local/cornell/CornellBox-Empty-White.obj', fallback_material: 'default' },
// Mesh { file_name: 'objs/local/cornell/CornellBox-Glossy-Floor.obj', fallback_material: 'default' },
// Mesh { file_name: 'objs/local/cornell/CornellBox-Glossy.obj', fallback_material: 'default' },
// Mesh { file_name: 'objs/local/cornell/CornellBox-Mirror.obj', fallback_material: 'default' },
// Mesh { file_name: 'objs/local/cornell/CornellBox-Water.obj', fallback_material: 'default' },
]
}
7 changes: 6 additions & 1 deletion src/obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ pub fn load_obj(file_name: &str, fallback_material: Arc<Material>) -> Vec<Arc<Pr
let eta = m.optical_density.unwrap_or(1.0);
Arc::new(Material::new_glass(reflectance, transmittance, eta))
} else {
Arc::new(Material::new_plastic(diffuse, specular, roughness))
// This is a hacky way to support reflective surfaces. We should
// likely switch to glTF or something
match m.illumination_model {
Some(3 | 4 | 5 | 6 | 7 | 8 | 9) => Arc::new(Material::new_metal(diffuse, specular)),
_ => Arc::new(Material::new_plastic(diffuse, specular, roughness)),
}
};
debug!("\t{:?}", material);
materials.push(material);
Expand Down

0 comments on commit faa2f52

Please sign in to comment.