address review comment

This commit is contained in:
roudy16 2022-03-06 18:51:37 +00:00
parent 212da09b15
commit 2c4b3668cd
4 changed files with 16 additions and 20 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;