commit for stack exchange

This commit is contained in:
CDaut 2023-11-22 23:28:21 +01:00
parent 8657806aba
commit 053a69e5b7
7 changed files with 25 additions and 34 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

Before After
Before After

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -109,7 +109,7 @@
},
{
"mesh":4,
"name":"Suzanne",
"name":"Cube.004",
"translation":[
-10,
10,
@ -174,11 +174,11 @@
},
{
"doubleSided":true,
"name":"Material.002",
"name":"Material.004",
"pbrMetallicRoughness":{
"baseColorFactor":[
0.008347976952791214,
0.8001724481582642,
0.0012476131087169051,
0.8003553152084351,
0,
1
],
@ -245,7 +245,7 @@
]
},
{
"name":"Suzanne",
"name":"Cube.004",
"primitives":[
{
"attributes":{
@ -253,7 +253,7 @@
"NORMAL":15,
"TEXCOORD_0":16
},
"indices":17,
"indices":10,
"material":3
}
]
@ -387,36 +387,30 @@
{
"bufferView":14,
"componentType":5126,
"count":555,
"count":14,
"max":[
1.3671875,
0.984375,
0.8515625
1,
1,
1
],
"min":[
-1.3671875,
-0.984375,
-0.8515625
-1,
-1,
-1
],
"type":"VEC3"
},
{
"bufferView":15,
"componentType":5126,
"count":555,
"count":14,
"type":"VEC3"
},
{
"bufferView":16,
"componentType":5126,
"count":555,
"count":14,
"type":"VEC2"
},
{
"bufferView":17,
"componentType":5123,
"count":2904,
"type":"SCALAR"
}
],
"bufferViews":[
@ -506,32 +500,26 @@
},
{
"buffer":0,
"byteLength":6660,
"byteLength":168,
"byteOffset":1936,
"target":34962
},
{
"buffer":0,
"byteLength":6660,
"byteOffset":8596,
"byteLength":168,
"byteOffset":2104,
"target":34962
},
{
"buffer":0,
"byteLength":4440,
"byteOffset":15256,
"byteLength":112,
"byteOffset":2272,
"target":34962
},
{
"buffer":0,
"byteLength":5808,
"byteOffset":19696,
"target":34963
}
],
"buffers":[
{
"byteLength":25504,
"byteLength":2384,
"uri":"cube_on_plane.bin"
}
]

View file

@ -31,6 +31,8 @@ pub fn construct_primary_rays(camera: &Camera,
panic!("Non invertible transform Matrix. giving up.")
);
dbg!(camera.transform);
//TODO: take ray multiplier per pixel into account here
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> =
Vector4::new(u as f32 - (image_width as f32 / 2.0),
v as f32 - (image_height as f32 / 2.0),
-focal_length,
focal_length,
0.0);
//TODO: Rotation is fucked
//x rotation has sign wrong, y and z are flipped

View file

@ -75,6 +75,7 @@ fn raytrace(ray: &Ray, scene: &Scene) -> Rgba<u8> {
// a new closer Point is found
if t < smallest_t {
smallest_t = t;
//TODO: lighting model is not at all considered. Just a debug hack.
clostest_intersection_point = Option::from(isec);
let color_vec = model.material().get_base_color_alpha(
Vector2::new(0.0, 0.0)