From 3cf377c490b4a26dc96f9c96e09799bd0f257f18 Mon Sep 17 00:00:00 2001 From: robtfm <50659922+robtfm@users.noreply.github.com> Date: Wed, 22 Nov 2023 18:54:45 +0000 Subject: [PATCH] Non uniform transmission samples (#10674) # Objective fix webgpu+chrome(119) textureSample in non-uniform control flow error ## Solution modify view transmission texture sampling to use textureSampleLevel. there are no mips for the view transmission texture, so this doesn't change the result, but it removes the need for the samples to be in uniform control flow. note: in future we may add a mipchain to the transmission texture to improve the blur effect. if uniformity analysis hasn't improved, this would require switching to manual derivative calculations (which is something we plan to do anyway). --- crates/bevy_pbr/src/render/pbr_transmission.wgsl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/bevy_pbr/src/render/pbr_transmission.wgsl b/crates/bevy_pbr/src/render/pbr_transmission.wgsl index 14b1e67d0d..f13e09920d 100644 --- a/crates/bevy_pbr/src/render/pbr_transmission.wgsl +++ b/crates/bevy_pbr/src/render/pbr_transmission.wgsl @@ -53,10 +53,11 @@ fn specular_transmissive_light(world_position: vec4, frag_coord: vec3, } fn fetch_transmissive_background_non_rough(offset_position: vec2, frag_coord: vec3) -> vec4 { - var background_color = textureSample( + var background_color = textureSampleLevel( view_bindings::view_transmission_texture, view_bindings::view_transmission_sampler, offset_position, + 0.0 ); #ifdef DEPTH_PREPASS @@ -152,10 +153,11 @@ fn fetch_transmissive_background(offset_position: vec2, frag_coord: vec3