diff --git a/Cargo.toml b/Cargo.toml index 6ab8955f..1f8aaf6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ gltf = { version = "1.1", default-features = false } log = "0.4" mint = "0.5" #TODO: switch to crates -naga = { git = "https://github.com/gfx-rs/wgpu", features = ["wgsl-in"], rev = "425526828f738c95ec50b016c6a761bc00d2fb25" } +naga = { git = "https://github.com/gfx-rs/wgpu", features = ["wgsl-in"], rev = "f44f52a85ddb3e7b93fe195fb98a8990b05575d8" } profiling = "1" slab = "0.4" strum = { version = "0.25", features = ["derive"] } diff --git a/blade-render/code/ray-trace.wgsl b/blade-render/code/ray-trace.wgsl index 5adf97dc..b27b1065 100644 --- a/blade-render/code/ray-trace.wgsl +++ b/blade-render/code/ray-trace.wgsl @@ -41,6 +41,7 @@ var prev_camera: CameraParams; var parameters: MainParams; var debug: DebugParams; var acc_struct: acceleration_structure; +var prev_acc_struct: acceleration_structure; var env_map: texture_2d; var sampler_linear: sampler; var sampler_nearest: sampler; @@ -223,10 +224,10 @@ fn evaluate_brdf(surface: Surface, dir: vec3) -> f32 { return lambert_brdf * max(0.0, lambert_term); } -fn check_ray_occluded(position: vec3, direction: vec3, debug_len: f32) -> bool { +fn check_ray_occluded(acs: acceleration_structure, position: vec3, direction: vec3, debug_len: f32) -> bool { var rq: ray_query; let flags = RAY_FLAG_TERMINATE_ON_FIRST_HIT | RAY_FLAG_CULL_NO_OPAQUE; - rayQueryInitialize(&rq, acc_struct, + rayQueryInitialize(&rq, acs, RayDesc(flags, 0xFFu, parameters.t_start, camera.depth, position, direction) ); rayQueryProceed(&rq); @@ -273,7 +274,7 @@ fn make_target_score(color: vec3) -> TargetScore { } fn estimate_target_score_with_occlusion( - surface: Surface, position: vec3, light_index: u32, light_uv: vec2, debug_len: f32 + surface: Surface, position: vec3, light_index: u32, light_uv: vec2, acs: acceleration_structure, debug_len: f32 ) -> TargetScore { if (light_index != 0u) { return TargetScore(); @@ -287,7 +288,7 @@ fn estimate_target_score_with_occlusion( return TargetScore(); } - if (check_ray_occluded(position, direction, debug_len)) { + if (check_ray_occluded(acs, position, direction, debug_len)) { return TargetScore(); } else { //Note: same as `evaluate_reflected_light` @@ -312,7 +313,7 @@ fn evaluate_sample(ls: LightSample, surface: Surface, start_pos: vec3, debu return 0.0; } - if (check_ray_occluded(start_pos, dir, debug_len)) { + if (check_ray_occluded(acc_struct, start_pos, dir, debug_len)) { return 0.0; } @@ -435,7 +436,7 @@ fn compute_restir(surface: Surface, pixel: vec2, rng: ptr, rng: ptr