commit for stack exchange
This commit is contained in:
parent
8657806aba
commit
053a69e5b7
7 changed files with 25 additions and 34 deletions
BIN
result_image.png
BIN
result_image.png
Binary file not shown.
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.3 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -109,7 +109,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mesh":4,
|
"mesh":4,
|
||||||
"name":"Suzanne",
|
"name":"Cube.004",
|
||||||
"translation":[
|
"translation":[
|
||||||
-10,
|
-10,
|
||||||
10,
|
10,
|
||||||
|
|
@ -174,11 +174,11 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doubleSided":true,
|
"doubleSided":true,
|
||||||
"name":"Material.002",
|
"name":"Material.004",
|
||||||
"pbrMetallicRoughness":{
|
"pbrMetallicRoughness":{
|
||||||
"baseColorFactor":[
|
"baseColorFactor":[
|
||||||
0.008347976952791214,
|
0.0012476131087169051,
|
||||||
0.8001724481582642,
|
0.8003553152084351,
|
||||||
0,
|
0,
|
||||||
1
|
1
|
||||||
],
|
],
|
||||||
|
|
@ -245,7 +245,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"Suzanne",
|
"name":"Cube.004",
|
||||||
"primitives":[
|
"primitives":[
|
||||||
{
|
{
|
||||||
"attributes":{
|
"attributes":{
|
||||||
|
|
@ -253,7 +253,7 @@
|
||||||
"NORMAL":15,
|
"NORMAL":15,
|
||||||
"TEXCOORD_0":16
|
"TEXCOORD_0":16
|
||||||
},
|
},
|
||||||
"indices":17,
|
"indices":10,
|
||||||
"material":3
|
"material":3
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -387,36 +387,30 @@
|
||||||
{
|
{
|
||||||
"bufferView":14,
|
"bufferView":14,
|
||||||
"componentType":5126,
|
"componentType":5126,
|
||||||
"count":555,
|
"count":14,
|
||||||
"max":[
|
"max":[
|
||||||
1.3671875,
|
1,
|
||||||
0.984375,
|
1,
|
||||||
0.8515625
|
1
|
||||||
],
|
],
|
||||||
"min":[
|
"min":[
|
||||||
-1.3671875,
|
-1,
|
||||||
-0.984375,
|
-1,
|
||||||
-0.8515625
|
-1
|
||||||
],
|
],
|
||||||
"type":"VEC3"
|
"type":"VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView":15,
|
"bufferView":15,
|
||||||
"componentType":5126,
|
"componentType":5126,
|
||||||
"count":555,
|
"count":14,
|
||||||
"type":"VEC3"
|
"type":"VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView":16,
|
"bufferView":16,
|
||||||
"componentType":5126,
|
"componentType":5126,
|
||||||
"count":555,
|
"count":14,
|
||||||
"type":"VEC2"
|
"type":"VEC2"
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView":17,
|
|
||||||
"componentType":5123,
|
|
||||||
"count":2904,
|
|
||||||
"type":"SCALAR"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bufferViews":[
|
"bufferViews":[
|
||||||
|
|
@ -506,32 +500,26 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer":0,
|
"buffer":0,
|
||||||
"byteLength":6660,
|
"byteLength":168,
|
||||||
"byteOffset":1936,
|
"byteOffset":1936,
|
||||||
"target":34962
|
"target":34962
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer":0,
|
"buffer":0,
|
||||||
"byteLength":6660,
|
"byteLength":168,
|
||||||
"byteOffset":8596,
|
"byteOffset":2104,
|
||||||
"target":34962
|
"target":34962
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer":0,
|
"buffer":0,
|
||||||
"byteLength":4440,
|
"byteLength":112,
|
||||||
"byteOffset":15256,
|
"byteOffset":2272,
|
||||||
"target":34962
|
"target":34962
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer":0,
|
|
||||||
"byteLength":5808,
|
|
||||||
"byteOffset":19696,
|
|
||||||
"target":34963
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"buffers":[
|
"buffers":[
|
||||||
{
|
{
|
||||||
"byteLength":25504,
|
"byteLength":2384,
|
||||||
"uri":"cube_on_plane.bin"
|
"uri":"cube_on_plane.bin"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ pub fn construct_primary_rays(camera: &Camera,
|
||||||
panic!("Non invertible transform Matrix. giving up.")
|
panic!("Non invertible transform Matrix. giving up.")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
dbg!(camera.transform);
|
||||||
|
|
||||||
//TODO: take ray multiplier per pixel into account here
|
//TODO: take ray multiplier per pixel into account here
|
||||||
let mut rays: Vec<Ray> = Vec::with_capacity(height * width);
|
let mut rays: Vec<Ray> = Vec::with_capacity(height * width);
|
||||||
|
|
||||||
|
|
@ -59,7 +61,7 @@ fn generate_single_primary_ray(image_width: usize,
|
||||||
let direction_view_space: Vector4<f32> =
|
let direction_view_space: Vector4<f32> =
|
||||||
Vector4::new(u as f32 - (image_width as f32 / 2.0),
|
Vector4::new(u as f32 - (image_width as f32 / 2.0),
|
||||||
v as f32 - (image_height as f32 / 2.0),
|
v as f32 - (image_height as f32 / 2.0),
|
||||||
-focal_length,
|
focal_length,
|
||||||
0.0);
|
0.0);
|
||||||
//TODO: Rotation is fucked
|
//TODO: Rotation is fucked
|
||||||
//x rotation has sign wrong, y and z are flipped
|
//x rotation has sign wrong, y and z are flipped
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ fn raytrace(ray: &Ray, scene: &Scene) -> Rgba<u8> {
|
||||||
// a new closer Point is found
|
// a new closer Point is found
|
||||||
if t < smallest_t {
|
if t < smallest_t {
|
||||||
smallest_t = t;
|
smallest_t = t;
|
||||||
|
//TODO: lighting model is not at all considered. Just a debug hack.
|
||||||
clostest_intersection_point = Option::from(isec);
|
clostest_intersection_point = Option::from(isec);
|
||||||
let color_vec = model.material().get_base_color_alpha(
|
let color_vec = model.material().get_base_color_alpha(
|
||||||
Vector2::new(0.0, 0.0)
|
Vector2::new(0.0, 0.0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue