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).
This commit is contained in:
robtfm 2023-11-22 18:54:45 +00:00 committed by Carter Anderson
parent 100767560f
commit 3cf377c490

View File

@ -53,10 +53,11 @@ fn specular_transmissive_light(world_position: vec4<f32>, frag_coord: vec3<f32>,
}
fn fetch_transmissive_background_non_rough(offset_position: vec2<f32>, frag_coord: vec3<f32>) -> vec4<f32> {
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<f32>, frag_coord: vec3<f3
let modified_offset_position = offset_position + rotated_spiral_offset * blur_intensity * (1.0 - f32(pixel_checkboard) * 0.1);
// Sample the view transmission texture at the offset position + noise offset, to get the background color
var sample = textureSample(
var sample = textureSampleLevel(
view_bindings::view_transmission_texture,
view_bindings::view_transmission_sampler,
modified_offset_position,
0.0
);
#ifdef DEPTH_PREPASS