Actually use the background color from the scene file.
This commit is contained in:
parent
8cd445813a
commit
5bc97f69b8
|
@ -13,6 +13,7 @@ use math::Matrix4x4;
|
|||
use camera::Camera;
|
||||
use renderer::Renderer;
|
||||
use scene::Scene;
|
||||
use color::{XYZ, rec709e_to_xyz};
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum PsyParseError {
|
||||
|
@ -264,10 +265,9 @@ fn parse_camera(tree: &DataTree) -> Result<Camera, PsyParseError> {
|
|||
|
||||
|
||||
|
||||
fn parse_world(tree: &DataTree) -> Result<(f32, f32, f32), PsyParseError> {
|
||||
fn parse_world(tree: &DataTree) -> Result<XYZ, PsyParseError> {
|
||||
if tree.is_internal() {
|
||||
let mut found_background_color = false;
|
||||
let mut background_color = (0.0, 0.0, 0.0);
|
||||
let background_color;
|
||||
|
||||
// Parse background shader
|
||||
let bgs = {
|
||||
|
@ -296,8 +296,9 @@ fn parse_world(tree: &DataTree) -> Result<(f32, f32, f32), PsyParseError> {
|
|||
ws_f32,
|
||||
ws_f32))(contents.trim()
|
||||
.as_bytes()) {
|
||||
found_background_color = true;
|
||||
background_color = color;
|
||||
// TODO: proper color space management, not just assuming
|
||||
// rec.709.
|
||||
background_color = XYZ::from_tuple(rec709e_to_xyz(color));
|
||||
} else {
|
||||
return Err(PsyParseError::UnknownError);
|
||||
}
|
||||
|
|
|
@ -306,8 +306,8 @@ impl LightPath {
|
|||
}
|
||||
} else {
|
||||
// Didn't hit anything, so background color
|
||||
let xyz = XYZ::new(0.0, 0.0, 0.0);
|
||||
self.color += xyz.to_spectral_sample(self.wavelength);
|
||||
self.color += scene.background_color.to_spectral_sample(self.wavelength) *
|
||||
self.light_attenuation;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use camera::Camera;
|
||||
use assembly::Assembly;
|
||||
use color::XYZ;
|
||||
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Scene {
|
||||
pub name: Option<String>,
|
||||
pub background_color: (f32, f32, f32),
|
||||
pub background_color: XYZ,
|
||||
pub camera: Camera,
|
||||
pub root: Assembly,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user