This commit is contained in:
Jérôme Bousquié
2026-09-25 14:40:47 +02:00
parent 8ece89ccba
commit 54a482e354
12 changed files with 866 additions and 370 deletions
+6
View File
@@ -258,6 +258,7 @@ impl Renderer {
let identity_object = ObjectUniform {
model: glam::Mat4::IDENTITY,
emissive: glam::Vec4::ZERO,
pbr: glam::Vec4::ZERO,
};
queue.write_buffer(&object_buffer, 0, bytemuck::bytes_of(&identity_object));
let shared_object_bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
@@ -1220,6 +1221,7 @@ impl Renderer {
}
// Emissive (6.2): write per-slot into the matrix buffer padding (bytes 64-79).
// The compute pass only overwrites bytes 0-63 (the matrix), so the emissive persists.
// PBR (Étape 27): metallic/roughness at bytes 80-95 (always written for correctness).
for slot in scene.iter_slot_draws().filter(|s| s.active) {
let mat = slot
.mesh
@@ -1230,6 +1232,10 @@ impl Renderer {
let offset = (slot.slot_index as u64 * MAT_SLOT_SIZE + 64) as u64;
self.queue.write_buffer(&self.matrix_buffer, offset, bytemuck::cast_slice(&mat.emissive));
}
// PBR params (metallic, roughness) — always written (buffer init to 0 is wrong for PBR).
let pbr_data: [f32; 4] = [mat.metallic, mat.roughness, 0.0, 0.0];
let offset = (slot.slot_index as u64 * MAT_SLOT_SIZE + 80) as u64;
self.queue.write_buffer(&self.matrix_buffer, offset, bytemuck::cast_slice(&pbr_data));
}
// 8c. Étape 23: bloom passes (threshold → blur H → blur V → composite).