Skip to content

Commit

Permalink
Relax tangent checks, update bevy-mikktspace
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Dec 17, 2023
1 parent 6f95da0 commit 53d8e88
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion blade-render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exr = { version = "1.6", optional = true }
gltf = { workspace = true, features = ["names", "utils"], optional = true }
glam = { workspace = true }
log = { workspace = true }
mikktspace = { package = "bevy_mikktspace", version = "0.10", optional = true }
mikktspace = { package = "bevy_mikktspace", version = "0.12", optional = true }
mint = { workspace = true }
profiling = { workspace = true }
slab = { workspace = true, optional = true }
Expand Down
9 changes: 2 additions & 7 deletions blade-render/src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ fn pack4x8snorm(v: [f32; 4]) -> u32 {
}

fn encode_normal(v: [f32; 3]) -> u32 {
let raw = pack4x8snorm([v[0], v[1], v[2], 0.0]);
assert_ne!(raw, 0, "Zero normal detected");
raw
pack4x8snorm([v[0], v[1], v[2], 0.0])
}

pub struct Geometry {
Expand Down Expand Up @@ -258,6 +256,7 @@ impl CookedModel<'_> {
);
for (v, normal) in pre_vertices.iter_mut().zip(iter) {
v.normal = normal;
assert_ne!(encode_normal(normal), 0);
}
} else {
log::warn!("No normals in {name}");
Expand Down Expand Up @@ -589,10 +588,6 @@ impl blade_asset::Baker for Baker {
if meta.generate_tangents {
let ok = mikktspace::generate_tangents(&mut fg);
assert!(ok, "MikkTSpace failed");
} else {
for v in fg.0.iter_mut() {
v.tangent = [1.0, 0.0, 0.0, 0.0];
}
}
let (indices, vertices) = fg.reconstruct_indices();
let mut model = model_clone.lock().unwrap();
Expand Down

0 comments on commit 53d8e88

Please sign in to comment.