Skip to content

Commit

Permalink
Fix something I guess
Browse files Browse the repository at this point in the history
  • Loading branch information
Miou-zora committed May 7, 2024
1 parent e38842d commit aad76c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub const Config = struct {
if (item.transforms) |trs| {
conf.objects[i] = Object{
.plane = .{
.origin = .{ item.origin.x, item.origin.y, item.origin.z, 1 },
.origin = .{ item.origin.x, item.origin.y, item.origin.z, 0 },
.normal = .{ item.normal.x, item.normal.y, item.normal.z, 0 },
.material = proxy.materials[item.material],
.transform = transform_proxy_to_transform(trs),
Expand All @@ -184,7 +184,7 @@ pub const Config = struct {
} else {
conf.objects[i] = Object{
.plane = .{
.origin = .{ item.origin.x, item.origin.y, item.origin.z, 1 },
.origin = .{ item.origin.x, item.origin.y, item.origin.z, 0 },
.normal = .{ item.normal.x, item.normal.y, item.normal.z, 0 },
.material = proxy.materials[item.material],
},
Expand All @@ -194,7 +194,7 @@ pub const Config = struct {
if (item.transforms) |trs| {
conf.objects[i] = Object{
.cylinder = .{
.origin = .{ item.origin.x, item.origin.y, item.origin.z, 1 },
.origin = .{ item.origin.x, item.origin.y, item.origin.z, 0 },
.radius = item.radius,
.material = proxy.materials[item.material],
.transform = transform_proxy_to_transform(trs),
Expand All @@ -203,7 +203,7 @@ pub const Config = struct {
} else {
conf.objects[i] = Object{
.cylinder = .{
.origin = .{ item.origin.x, item.origin.y, item.origin.z, 1 },
.origin = .{ item.origin.x, item.origin.y, item.origin.z, 0 },
.radius = item.radius,
.material = proxy.materials[item.material],
},
Expand All @@ -213,15 +213,15 @@ pub const Config = struct {
if (item.transforms) |trs| {
conf.objects[i] = Object{ .triangle = .{
.va = .{
.position = .{ item.va.position.x, item.va.position.y, item.va.position.z, 1 },
.position = .{ item.va.position.x, item.va.position.y, item.va.position.z, 0 },
.texCoord = item.va.texCoord,
},
.vb = .{
.position = .{ item.vb.position.x, item.vb.position.y, item.vb.position.z, 1 },
.position = .{ item.vb.position.x, item.vb.position.y, item.vb.position.z, 0 },
.texCoord = item.vb.texCoord,
},
.vc = .{
.position = .{ item.vc.position.x, item.vc.position.y, item.vc.position.z, 1 },
.position = .{ item.vc.position.x, item.vc.position.y, item.vc.position.z, 0 },
.texCoord = item.vc.texCoord,
},
.text = &conf.assets[item.textIdx],
Expand All @@ -230,15 +230,15 @@ pub const Config = struct {
} else {
conf.objects[i] = Object{ .triangle = .{
.va = .{
.position = .{ item.va.position.x, item.va.position.y, item.va.position.z, 1 },
.position = .{ item.va.position.x, item.va.position.y, item.va.position.z, 0 },
.texCoord = item.va.texCoord,
},
.vb = .{
.position = .{ item.vb.position.x, item.vb.position.y, item.vb.position.z, 1 },
.position = .{ item.vb.position.x, item.vb.position.y, item.vb.position.z, 0 },
.texCoord = item.vb.texCoord,
},
.vc = .{
.position = .{ item.vc.position.x, item.vc.position.y, item.vc.position.z, 1 },
.position = .{ item.vc.position.x, item.vc.position.y, item.vc.position.z, 0 },
.texCoord = item.vc.texCoord,
},
.text = &conf.assets[item.textIdx],
Expand All @@ -253,7 +253,7 @@ pub const Config = struct {
conf.lights[i] = Light{ .point_light = .{
.color = item.color,
.intensity = item.intensity,
.position = .{ item.position.x, item.position.y, item.position.z, 1 },
.position = .{ item.position.x, item.position.y, item.position.z, 0 },
} };
} else if (obj.ambient) |item| {
conf.lights[i] = Light{ .ambient_light = .{
Expand Down
1 change: 0 additions & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn compute_lighting(intersection: Vec3, normal: Vec3, scene: *Scene.Scene, r
const V = zmath.normalize3(-ray.direction);
const r_dot_v = @reduce(.Add, R * V);
if (r_dot_v > 0) {
// const i = item.intensity * std.math.pow(f32, r_dot_v / (R.length() * V.length()), material.specular);
const i = item.intensity * std.math.pow(f32, r_dot_v / (zmath.length3(R) * zmath.length3(V))[0], material.specular);
lighting.b += item.color.b * i;
lighting.g += item.color.g * i;
Expand Down

0 comments on commit aad76c7

Please sign in to comment.