Fixed incorrect rendering angle.
The problem was in how the camera rays were generated.
This commit is contained in:
parent
1e93e53822
commit
56b5267b7a
|
@ -9,8 +9,8 @@ Scene $Scene_fr1 {
|
||||||
}
|
}
|
||||||
Camera {
|
Camera {
|
||||||
Fov [49.134342]
|
Fov [49.134342]
|
||||||
FocalDistance [0.000000]
|
FocalDistance [9.559999]
|
||||||
ApertureRadius [0.000000]
|
ApertureRadius [0.250000]
|
||||||
Transform [0.685881 0.727634 -0.010817 0.000000 -0.317370 0.312469 0.895343 0.000000 -0.654862 0.610666 -0.445245 0.000000 7.481132 -6.507640 5.343665 1.000000]
|
Transform [0.685881 0.727634 -0.010817 0.000000 -0.317370 0.312469 0.895343 0.000000 -0.654862 0.610666 -0.445245 0.000000 7.481132 -6.507640 5.343665 1.000000]
|
||||||
}
|
}
|
||||||
World {
|
World {
|
||||||
|
@ -24,6 +24,15 @@ Scene $Scene_fr1 {
|
||||||
Type [Lambert]
|
Type [Lambert]
|
||||||
Color [0.800000 0.800000 0.800000]
|
Color [0.800000 0.800000 0.800000]
|
||||||
}
|
}
|
||||||
|
MeshSurface $__Plane_ {
|
||||||
|
Vertices [-1.000000 -1.000000 0.000000 1.000000 -1.000000 0.000000 -1.000000 1.000000 0.000000 1.000000 1.000000 0.000000]
|
||||||
|
FaceVertCounts [4 ]
|
||||||
|
FaceVertIndices [0 1 3 2 ]
|
||||||
|
}
|
||||||
|
Instance {
|
||||||
|
Data [$__Plane_]
|
||||||
|
Transform [0.078868 -0.000000 0.000000 -0.000000 -0.000000 0.078868 -0.000000 0.000000 0.000000 -0.000000 0.078868 -0.000000 -0.000000 0.000000 -0.000000 1.000000]
|
||||||
|
}
|
||||||
MeshSurface $__Cube_ {
|
MeshSurface $__Cube_ {
|
||||||
Vertices [1.000000 1.000000 -1.000000 1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 1.000000 -1.000000 1.000000 0.999999 1.000000 0.999999 -1.000001 1.000000 -1.000000 -1.000000 1.000000 -1.000000 1.000000 1.000000 ]
|
Vertices [1.000000 1.000000 -1.000000 1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 1.000000 -1.000000 1.000000 0.999999 1.000000 0.999999 -1.000001 1.000000 -1.000000 -1.000000 1.000000 -1.000000 1.000000 1.000000 ]
|
||||||
FaceVertCounts [4 4 4 4 4 4 ]
|
FaceVertCounts [4 4 4 4 4 4 ]
|
||||||
|
@ -32,15 +41,15 @@ Scene $Scene_fr1 {
|
||||||
Instance {
|
Instance {
|
||||||
Data [$__Cube_]
|
Data [$__Cube_]
|
||||||
SurfaceShaderBind [$Material]
|
SurfaceShaderBind [$Material]
|
||||||
Transform [1.000000 -0.000000 0.000000 -0.000000 -0.000000 1.000000 -0.000000 0.000000 0.000000 -0.000000 1.000000 -0.000000 -0.000000 0.000000 -0.000000 1.000000]
|
Transform [1.000000 -0.000000 0.000000 -0.000000 -0.000000 1.000000 -0.000000 0.000000 0.000000 -0.000000 1.000000 -0.000000 -0.000000 0.000000 -1.000000 1.000000]
|
||||||
}
|
|
||||||
SphereLight $__Lamp {
|
|
||||||
Color [100.000000 100.000000 100.000000]
|
|
||||||
Radius [0.100000]
|
|
||||||
}
|
|
||||||
Instance {
|
|
||||||
Data [$__Lamp]
|
|
||||||
Transform [-0.290865 -0.771101 0.566393 -0.000000 0.955171 -0.199883 0.218391 -0.000000 -0.055189 0.604525 0.794672 -0.000000 0.551084 -0.224861 -7.219975 1.000000]
|
|
||||||
}
|
}
|
||||||
|
#SphereLight $__Lamp {
|
||||||
|
# Color [50.000000 50.000000 50.000000]
|
||||||
|
# Radius [0.100000]
|
||||||
|
#}
|
||||||
|
#Instance {
|
||||||
|
# Data [$__Lamp]
|
||||||
|
# Transform [0.019856 -0.060763 0.000000 -0.000000 0.015191 0.079422 -0.000000 0.000000 0.000000 -0.000000 1.000000 -0.000000 -0.026851 -0.125233 -4.432303 1.000000]
|
||||||
|
#}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,18 @@ impl Renderer {
|
||||||
let mut tracer = Tracer::from_assembly(&self.scene.root);
|
let mut tracer = Tracer::from_assembly(&self.scene.root);
|
||||||
let mut img = Image::new(self.resolution.0, self.resolution.1);
|
let mut img = Image::new(self.resolution.0, self.resolution.1);
|
||||||
|
|
||||||
// Render image of ray-traced triangle
|
// Pre-calculate some useful values related to the image plane
|
||||||
let cmpx = 1.0 / self.resolution.0 as f32;
|
let cmpx = 1.0 / self.resolution.0 as f32;
|
||||||
let cmpy = 1.0 / self.resolution.1 as f32;
|
let cmpy = 1.0 / self.resolution.1 as f32;
|
||||||
|
let min_x = -1.0;
|
||||||
|
let max_x = 1.0;
|
||||||
|
let min_y = -(self.resolution.1 as f32 / self.resolution.0 as f32);
|
||||||
|
let max_y = self.resolution.1 as f32 / self.resolution.0 as f32;
|
||||||
|
let x_extent = max_x - min_x;
|
||||||
|
let y_extent = max_y - min_y;
|
||||||
|
|
||||||
|
|
||||||
|
// Render
|
||||||
for y in 0..img.height() {
|
for y in 0..img.height() {
|
||||||
for x in 0..img.width() {
|
for x in 0..img.width() {
|
||||||
let offset = hash_u32(((x as u32) << 16) ^ (y as u32), 0);
|
let offset = hash_u32(((x as u32) << 16) ^ (y as u32), 0);
|
||||||
|
@ -35,10 +43,13 @@ impl Renderer {
|
||||||
rays.clear();
|
rays.clear();
|
||||||
for si in 0..self.spp {
|
for si in 0..self.spp {
|
||||||
let mut ray = {
|
let mut ray = {
|
||||||
let filter_x = fast_logit(halton::sample(3, offset + si as u32), 1.5);
|
let filter_x = fast_logit(halton::sample(3, offset + si as u32), 1.5) + 0.5;
|
||||||
let filter_y = fast_logit(halton::sample(4, offset + si as u32), 1.5);
|
let filter_y = fast_logit(halton::sample(4, offset + si as u32), 1.5) + 0.5;
|
||||||
self.scene.camera.generate_ray((x as f32 + filter_x) * cmpx - 0.5,
|
let samp_x = (filter_x + x as f32) * cmpx;
|
||||||
(y as f32 + filter_y) * cmpy - 0.5,
|
let samp_y = (filter_y + y as f32) * cmpy;
|
||||||
|
|
||||||
|
self.scene.camera.generate_ray((samp_x - 0.5) * x_extent,
|
||||||
|
(0.5 - samp_y) * y_extent,
|
||||||
halton::sample(0, offset + si as u32),
|
halton::sample(0, offset + si as u32),
|
||||||
halton::sample(1, offset + si as u32),
|
halton::sample(1, offset + si as u32),
|
||||||
halton::sample(2, offset + si as u32))
|
halton::sample(2, offset + si as u32))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user