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.

dof.wgsl

Constants

COS_NEG_FRAC_PI_6

#
const COS_NEG_FRAC_PI_6: f32 = 0.8660254037844387

SIN_NEG_FRAC_PI_6

#
const SIN_NEG_FRAC_PI_6: f32 = -0.5

COS_NEG_FRAC_PI_5_6

#
const COS_NEG_FRAC_PI_5_6: f32 = -0.8660254037844387

SIN_NEG_FRAC_PI_5_6

#
const SIN_NEG_FRAC_PI_5_6: f32 = -0.5

Bindings

depth_texture

#

Shader defs requirments:

🟢 MULTISAMPLED

@group(0)
@binding(1)
var depth_texture: texture_depth_multisampled_2d

depth_texture

#

Shader defs requirments:

šŸ”“ MULTISAMPLED

@group(0)
@binding(1)
var depth_texture: texture_depth_2d

color_texture_a

#
@group(0)
@binding(2)
var color_texture_a: texture_2d<f32>

color_texture_b

#

Shader defs requirments:

🟢 DUAL_INPUT

@group(0)
@binding(3)
var color_texture_b: texture_2d<f32>

dof_params

#
@group(1)
@binding(0)
var<uniform> dof_params: DepthOfFieldParams

color_texture_sampler

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

Structures

DepthOfFieldParams

#

Parameters that control the depth of field effect. See bevy_core_pipeline::dof::DepthOfFieldUniforms for information on what these parameters mean.

struct DepthOfFieldParams {
focal_distance: f32 ,
focal_length: f32 ,
coc_scale_factor: f32 ,
max_circle_of_confusion_diameter: f32 ,
max_depth: f32 ,
pad_a: u32 ,
pad_b: u32 ,
pad_c: u32 ,
}

DualOutput

#

The first bokeh pass outputs to two render targets. We declare them here.

struct DualOutput {
@location(0)
output_0: vec4<f32> ,
@location(1)
output_1: vec4<f32> ,
}

Functions

calculate_circle_of_confusion

#
fn calculate_circle_of_confusion (
in_frag_coord: vec4<f32>
) -> f32

gaussian_blur

#

Returns the resulting color of the fragment.

fn gaussian_blur (
frag_coord: vec4<f32>
coc: f32
frag_offset: vec2<f32>
) -> vec4<f32>

box_blur_a

#
  • frag_offset is the vector, in screen-space units, from one sample to the next. This need not be horizontal or vertical.
fn box_blur_a (
frag_coord: vec4<f32>
coc: f32
frag_offset: vec2<f32>
) -> vec4<f32>

box_blur_b

#

Shader defs requirments:

🟢 DUAL_INPUT

fn box_blur_b (
frag_coord: vec4<f32>
coc: f32
frag_offset: vec2<f32>
) -> vec4<f32>

gaussian_horizontal

#
@fragment
Calculates the final color of each pixel on the screen

Calculates the horizontal component of the separable Gaussian blur.

fn gaussian_horizontal ( ) ->
@location(0)
vec4<f32>

gaussian_vertical

#
@fragment
Calculates the final color of each pixel on the screen

Calculates the vertical component of the separable Gaussian blur.

fn gaussian_vertical ( ) ->
@location(0)
vec4<f32>

bokeh_pass_0

#
@fragment
Calculates the final color of each pixel on the screen

╱ ╱ • │ │

fn bokeh_pass_0 ( ) -> DualOutput

bokeh_pass_1

#
@fragment
Calculates the final color of each pixel on the screen

Shader defs requirments:

🟢 DUAL_INPUT

fn bokeh_pass_1 ( ) ->
@location(0)
vec4<f32>