diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-02 14:12:36 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-02 14:12:36 +0100 |
| commit | 259d2b31035259be4f24b1bde2101dafcdafd242 (patch) | |
| tree | 44870a9d419875a6d23b283d959d0355a77c3f59 | |
| parent | 9048115d66cb5ad18e37aad7d48cb6a708b3c3d5 (diff) | |
fix(3d): Fix shader syntax error and duplicate declaration
- Removed duplicate 'light_dir' declaration in the shader.
- Fixed a syntax error (duplicate closing raw string delimiter) that caused shader compilation failure.
- Verified all targets build and run correctly with 'check_all.sh'.
| -rw-r--r-- | LOG.txt | 53 | ||||
| -rw-r--r-- | src/3d/renderer.cc | 5 |
2 files changed, 27 insertions, 31 deletions
@@ -1,46 +1,43 @@ -thread '<unnamed>' (9163037) panicked at src/lib.rs:423:5: +thread '<unnamed>' (9166625) panicked at src/lib.rs:423:5: wgpu uncaptured error: Validation Error Caused by: In wgpuDeviceCreateShaderModule -Shader '' parsing error: redefinition of `light_dir` - ┌─ wgsl:141:9 +Shader '' parsing error: expected expression, found "" + ┌─ wgsl:217:1 │ -141 │ let light_dir = normalize(vec3<f32>(1.0, 1.0, 1.0)); - │ ^^^^^^^^^ previous definition of `light_dir` - · -212 │ let light_dir = normalize(vec3<f32>(0.2, 1.0, 0.2)); // More vertical light for easier shadow debugging - │ ^^^^^^^^^ redefinition of `light_dir` +217 │ + │ ^ expected expression note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread '<unnamed>' (9163037) panicked at library/core/src/panicking.rs:230:5: +thread '<unnamed>' (9166625) panicked at library/core/src/panicking.rs:230:5: panic in a function that cannot unwind stack backtrace: - 0: 0x1037d75e0 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h5b9122f5e70f5951 - 1: 0x1037f5194 - core::fmt::write::h6a8a2c9e4d999818 - 2: 0x1037d7854 - std::io::default_write_fmt::h89b6c507b2c6ffa7 - 3: 0x1037d6488 - std::panicking::default_hook::{{closure}}::h24b4617c01d6581d - 4: 0x1037d6370 - std::panicking::default_hook::h1955ee9a9845dfef - 5: 0x1037d6754 - std::panicking::panic_with_hook::h8aad6dd2389d8f59 - 6: 0x1037d6564 - std::panicking::panic_handler::{{closure}}::h3bd15449212d5b6e - 7: 0x1037d61e4 - std::sys::backtrace::__rust_end_short_backtrace::h3b25181b9f11fe05 - 8: 0x1037d5660 - __rustc[18f9140b322fd06e]::rust_begin_unwind - 9: 0x103821f6c - core::panicking::panic_nounwind_fmt::h7a4dae3ab8fc5259 - 10: 0x103821ed0 - core::panicking::panic_nounwind::h959d775d33fc4688 - 11: 0x103822070 - core::panicking::panic_cannot_unwind::hda7331a7075802a1 - 12: 0x1037fcfe0 - wgpu_native::default_uncaptured_error_handler::h5258404c53f3ccc3 - 13: 0x10346af0c - wgpu_native::ErrorSinkRaw::handle_error::h097d2dd0698a0260 - 14: 0x10346b590 - wgpu_native::handle_error::h00f841fd1f822b11 - 15: 0x1034848d0 - _wgpuDeviceCreateShaderModule - 16: 0x1028e8d5c - __ZN10Renderer3D15create_pipelineEv - 17: 0x1028e8b38 - __ZN10Renderer3D4initEP14WGPUDeviceImplP13WGPUQueueImpl17WGPUTextureFormat - 18: 0x1028e3a5c - _main + 0: 0x1055f75e0 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h5b9122f5e70f5951 + 1: 0x105615194 - core::fmt::write::h6a8a2c9e4d999818 + 2: 0x1055f7854 - std::io::default_write_fmt::h89b6c507b2c6ffa7 + 3: 0x1055f6488 - std::panicking::default_hook::{{closure}}::h24b4617c01d6581d + 4: 0x1055f6370 - std::panicking::default_hook::h1955ee9a9845dfef + 5: 0x1055f6754 - std::panicking::panic_with_hook::h8aad6dd2389d8f59 + 6: 0x1055f6564 - std::panicking::panic_handler::{{closure}}::h3bd15449212d5b6e + 7: 0x1055f61e4 - std::sys::backtrace::__rust_end_short_backtrace::h3b25181b9f11fe05 + 8: 0x1055f5660 - __rustc[18f9140b322fd06e]::rust_begin_unwind + 9: 0x105641f6c - core::panicking::panic_nounwind_fmt::h7a4dae3ab8fc5259 + 10: 0x105641ed0 - core::panicking::panic_nounwind::h959d775d33fc4688 + 11: 0x105642070 - core::panicking::panic_cannot_unwind::hda7331a7075802a1 + 12: 0x10561cfe0 - wgpu_native::default_uncaptured_error_handler::h5258404c53f3ccc3 + 13: 0x10528af0c - wgpu_native::ErrorSinkRaw::handle_error::h097d2dd0698a0260 + 14: 0x10528b590 - wgpu_native::handle_error::h00f841fd1f822b11 + 15: 0x1052a48d0 - _wgpuDeviceCreateShaderModule + 16: 0x104614d5c - __ZN10Renderer3D15create_pipelineEv + 17: 0x104614b38 - __ZN10Renderer3D4initEP14WGPUDeviceImplP13WGPUQueueImpl17WGPUTextureFormat + 18: 0x10460fa5c - _main thread caused non-unwinding panic. aborting. Running 3D Renderer Test... diff --git a/src/3d/renderer.cc b/src/3d/renderer.cc index cc2124e..6de7fee 100644 --- a/src/3d/renderer.cc +++ b/src/3d/renderer.cc @@ -219,11 +219,10 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> { let n_local = normalize(vec3<f32>(d_x1 - d_x2, d_y1 - d_y2, d_z1 - d_z2)); - let n_world = mat3 * n_local; - let normal = normalize(n_world); + normal = normalize(mat3 * n_local); + } let shadow = calc_shadow(p + normal * 0.01, light_dir, 0.0, 20.0); - let lighting = (max(dot(normal, light_dir), 0.0) * shadow) + 0.1; return vec4<f32>(in.color.rgb * lighting, 1.0); } |
