From 2c4b3668cdd1f6d3f562c15a968b528308d19720 Mon Sep 17 00:00:00 2001 From: roudy16 Date: Sun, 6 Mar 2022 18:51:37 +0000 Subject: [PATCH] address review comment --- code/intermediate/tutorial11-normals/src/model.rs | 9 ++++----- code/intermediate/tutorial12-camera/src/model.rs | 9 ++++----- code/intermediate/tutorial13-threading/src/model.rs | 9 ++++----- docs/intermediate/tutorial11-normals/README.md | 9 ++++----- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/code/intermediate/tutorial11-normals/src/model.rs b/code/intermediate/tutorial11-normals/src/model.rs index 5ec1bdd9..0a4f7b7a 100644 --- a/code/intermediate/tutorial11-normals/src/model.rs +++ b/code/intermediate/tutorial11-normals/src/model.rs @@ -219,10 +219,9 @@ impl Model { // the solution! let r = 1.0 / (delta_uv1.x * delta_uv2.y - delta_uv1.y * delta_uv2.x); let tangent = (delta_pos1 * delta_uv2.y - delta_pos2 * delta_uv1.y) * r; - let bitangent = (delta_pos2 * delta_uv1.x - delta_pos1 * delta_uv2.x) * r; // We flip the bitangent to enable right-handed normal // maps with wgpu texture coordinate system - let flipped_bitangent = bitangent * -1.0; + let bitangent = (delta_pos2 * delta_uv1.x - delta_pos1 * delta_uv2.x) * -r; // We'll use the same tangent/bitangent for each vertex in the triangle vertices[c[0] as usize].tangent = @@ -232,11 +231,11 @@ impl Model { vertices[c[2] as usize].tangent = (tangent + cgmath::Vector3::from(vertices[c[2] as usize].tangent)).into(); vertices[c[0] as usize].bitangent = - (flipped_bitangent + cgmath::Vector3::from(vertices[c[0] as usize].bitangent)).into(); + (bitangent + cgmath::Vector3::from(vertices[c[0] as usize].bitangent)).into(); vertices[c[1] as usize].bitangent = - (flipped_bitangent + cgmath::Vector3::from(vertices[c[1] as usize].bitangent)).into(); + (bitangent + cgmath::Vector3::from(vertices[c[1] as usize].bitangent)).into(); vertices[c[2] as usize].bitangent = - (flipped_bitangent + cgmath::Vector3::from(vertices[c[2] as usize].bitangent)).into(); + (bitangent + cgmath::Vector3::from(vertices[c[2] as usize].bitangent)).into(); // Used to average the tangents/bitangents triangles_included[c[0] as usize] += 1; diff --git a/code/intermediate/tutorial12-camera/src/model.rs b/code/intermediate/tutorial12-camera/src/model.rs index 5ec1bdd9..0a4f7b7a 100644 --- a/code/intermediate/tutorial12-camera/src/model.rs +++ b/code/intermediate/tutorial12-camera/src/model.rs @@ -219,10 +219,9 @@ impl Model { // the solution! let r = 1.0 / (delta_uv1.x * delta_uv2.y - delta_uv1.y * delta_uv2.x); let tangent = (delta_pos1 * delta_uv2.y - delta_pos2 * delta_uv1.y) * r; - let bitangent = (delta_pos2 * delta_uv1.x - delta_pos1 * delta_uv2.x) * r; // We flip the bitangent to enable right-handed normal // maps with wgpu texture coordinate system - let flipped_bitangent = bitangent * -1.0; + let bitangent = (delta_pos2 * delta_uv1.x - delta_pos1 * delta_uv2.x) * -r; // We'll use the same tangent/bitangent for each vertex in the triangle vertices[c[0] as usize].tangent = @@ -232,11 +231,11 @@ impl Model { vertices[c[2] as usize].tangent = (tangent + cgmath::Vector3::from(vertices[c[2] as usize].tangent)).into(); vertices[c[0] as usize].bitangent = - (flipped_bitangent + cgmath::Vector3::from(vertices[c[0] as usize].bitangent)).into(); + (bitangent + cgmath::Vector3::from(vertices[c[0] as usize].bitangent)).into(); vertices[c[1] as usize].bitangent = - (flipped_bitangent + cgmath::Vector3::from(vertices[c[1] as usize].bitangent)).into(); + (bitangent + cgmath::Vector3::from(vertices[c[1] as usize].bitangent)).into(); vertices[c[2] as usize].bitangent = - (flipped_bitangent + cgmath::Vector3::from(vertices[c[2] as usize].bitangent)).into(); + (bitangent + cgmath::Vector3::from(vertices[c[2] as usize].bitangent)).into(); // Used to average the tangents/bitangents triangles_included[c[0] as usize] += 1; diff --git a/code/intermediate/tutorial13-threading/src/model.rs b/code/intermediate/tutorial13-threading/src/model.rs index 32e64ec1..290558bf 100644 --- a/code/intermediate/tutorial13-threading/src/model.rs +++ b/code/intermediate/tutorial13-threading/src/model.rs @@ -219,10 +219,9 @@ impl Model { // the solution! let r = 1.0 / (delta_uv1.x * delta_uv2.y - delta_uv1.y * delta_uv2.x); let tangent = (delta_pos1 * delta_uv2.y - delta_pos2 * delta_uv1.y) * r; - let bitangent = (delta_pos2 * delta_uv1.x - delta_pos1 * delta_uv2.x) * r; // We flip the bitangent to enable right-handed normal // maps with wgpu texture coordinate system - let flipped_bitangent = bitangent * -1.0; + let bitangent = (delta_pos2 * delta_uv1.x - delta_pos1 * delta_uv2.x) * -r; // We'll use the same tangent/bitangent for each vertex in the triangle vertices[c[0] as usize].tangent = @@ -232,11 +231,11 @@ impl Model { vertices[c[2] as usize].tangent = (tangent + cgmath::Vector3::from(vertices[c[2] as usize].tangent)).into(); vertices[c[0] as usize].bitangent = - (flipped_bitangent + cgmath::Vector3::from(vertices[c[0] as usize].bitangent)).into(); + (bitangent + cgmath::Vector3::from(vertices[c[0] as usize].bitangent)).into(); vertices[c[1] as usize].bitangent = - (flipped_bitangent + cgmath::Vector3::from(vertices[c[1] as usize].bitangent)).into(); + (bitangent + cgmath::Vector3::from(vertices[c[1] as usize].bitangent)).into(); vertices[c[2] as usize].bitangent = - (flipped_bitangent + cgmath::Vector3::from(vertices[c[2] as usize].bitangent)).into(); + (bitangent + cgmath::Vector3::from(vertices[c[2] as usize].bitangent)).into(); // Used to average the tangents/bitangents triangles_included[c[0] as usize] += 1; diff --git a/docs/intermediate/tutorial11-normals/README.md b/docs/intermediate/tutorial11-normals/README.md index 7b49a2c4..089d8098 100644 --- a/docs/intermediate/tutorial11-normals/README.md +++ b/docs/intermediate/tutorial11-normals/README.md @@ -278,10 +278,9 @@ impl Model { // the solution! let r = 1.0 / (delta_uv1.x * delta_uv2.y - delta_uv1.y * delta_uv2.x); let tangent = (delta_pos1 * delta_uv2.y - delta_pos2 * delta_uv1.y) * r; - let bitangent = (delta_pos2 * delta_uv1.x - delta_pos1 * delta_uv2.x) * r; // We flip the bitangent to enable right-handed normal // maps with wgpu texture coordinate system - let flipped_bitangent = bitangent * -1.0; + let bitangent = (delta_pos2 * delta_uv1.x - delta_pos1 * delta_uv2.x) * -r; // We'll use the same tangent/bitangent for each vertex in the triangle vertices[c[0] as usize].tangent = @@ -291,11 +290,11 @@ impl Model { vertices[c[2] as usize].tangent = (tangent + cgmath::Vector3::from(vertices[c[2] as usize].tangent)).into(); vertices[c[0] as usize].bitangent = - (flipped_bitangent + cgmath::Vector3::from(vertices[c[0] as usize].bitangent)).into(); + (bitangent + cgmath::Vector3::from(vertices[c[0] as usize].bitangent)).into(); vertices[c[1] as usize].bitangent = - (flipped_bitangent + cgmath::Vector3::from(vertices[c[1] as usize].bitangent)).into(); + (bitangent + cgmath::Vector3::from(vertices[c[1] as usize].bitangent)).into(); vertices[c[2] as usize].bitangent = - (flipped_bitangent + cgmath::Vector3::from(vertices[c[2] as usize].bitangent)).into(); + (bitangent + cgmath::Vector3::from(vertices[c[2] as usize].bitangent)).into(); // Used to average the tangents/bitangents triangles_included[c[0] as usize] += 1;