Advanced search tips: use spaces to require multiple terms (AND), | for alternatives (OR), wrap phrases in quotes (="a b"), =term for exact match, 'term to include, !term to exclude, ^term to match prefix, !^term to exclude prefix, .ext$ to match suffix, and !.ext$ to exclude suffix.

preprocess_depth.wgsl

Bindings

input_depth

#
@group(0)
@binding(0)
var input_depth: texture_depth_2d

preprocessed_depth_mip0

#
@group(0)
@binding(1)
var preprocessed_depth_mip0: texture_storage_2d<r16float, write>

preprocessed_depth_mip1

#
@group(0)
@binding(2)
var preprocessed_depth_mip1: texture_storage_2d<r16float, write>

preprocessed_depth_mip2

#
@group(0)
@binding(3)
var preprocessed_depth_mip2: texture_storage_2d<r16float, write>

preprocessed_depth_mip3

#
@group(0)
@binding(4)
var preprocessed_depth_mip3: texture_storage_2d<r16float, write>

preprocessed_depth_mip4

#
@group(0)
@binding(5)
var preprocessed_depth_mip4: texture_storage_2d<r16float, write>

point_clamp_sampler

#
@group(1)
@binding(0)
var point_clamp_sampler: sampler

linear_clamp_sampler

#
@group(1)
@binding(1)
var linear_clamp_sampler: sampler

view

#
@group(1)
@binding(2)
var<uniform> view: View

Functions

weighted_average

#

Using 4 depths from the previous MIP, compute a weighted average for the depth of the current MIP

fn weighted_average (
depth0: f32
depth1: f32
depth2: f32
depth3: f32
) -> f32

preprocess_depth

#
@compute
Runs custom parallel code on the GPU, not limited to graphics
@workgroup_size(8, 8, 1)
Defines the size of a thread group. One to three numbers: width (x), height (y), and depth (z). Missing values default to 1
fn preprocess_depth (
@builtin(global_invocation_id)
global_id: vec3<u32>
@builtin(local_invocation_id)
local_id: vec3<u32>
)