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.

pbr_functions.wgsl

Import path

Structures

SampleBias

#

Biasing info needed to sample from a texture. How this is done depends on whether we’re rendering meshlets or regular meshes.

struct SampleBias {
ddx_uv: vec2<f32> , 🟢 MESHLET_MESH_MATERIAL_PASS
ddy_uv: vec2<f32> , 🟢 MESHLET_MESH_MATERIAL_PASS
mip_bias: f32 , šŸ”“ MESHLET_MESH_MATERIAL_PASS
}

Functions

visibility_range_dither

#

Shader defs requirments:

🟢 VISIBILITY_RANGE_DITHER

fn visibility_range_dither (
frag_coord: vec4<f32>
dither: i32
)

alpha_discard

#
fn alpha_discard (
material: pbr_types
output_color: vec4<f32>
) -> vec4<f32>

prepare_world_normal

#
fn prepare_world_normal (
world_normal: vec3<f32>
double_sided: bool
is_front: bool
) -> vec3<f32>

calculate_tbn_mikktspace

#
fn calculate_tbn_mikktspace (
world_normal: vec3<f32>
world_tangent: vec4<f32>
) -> mat3x3<f32>

apply_normal_mapping

#
fn apply_normal_mapping (
standard_material_flags: u32
double_sided: bool
is_front: bool
) -> vec3<f32>

bend_normal_for_anisotropy

#

Shader defs requirments:

🟢 STANDARD_MATERIAL_ANISOTROPY

This follows the suggested implementation in the KHR_materials_anisotropy specification: https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_anisotropy/README.md#image-based-lighting

fn bend_normal_for_anisotropy ( )

calculate_view

#

NOTE: Correctly calculates the view vector depending on whether the projection is orthographic or perspective.

fn calculate_view (
world_position: vec4<f32>
is_orthographic: bool
) -> vec3<f32>

calculate_diffuse_color

#

Diffuse strength is inversely related to metallicity, specular and diffuse transmission

fn calculate_diffuse_color (
base_color: vec3<f32>
metallic: f32
specular_transmission: f32
diffuse_transmission: f32
) -> vec3<f32>

calculate_F0

#
fn calculate_F0 (
base_color: vec3<f32>
metallic: f32
reflectance: vec3<f32>
) -> vec3<f32>

apply_pbr_lighting

#
fn apply_pbr_lighting ( ) -> vec4<f32>

apply_fog

#

Shader defs requirments:

🟢 DISTANCE_FOG

fn apply_fog (
input_color: vec4<f32>
fragment_world_position: vec3<f32>
view_world_position: vec3<f32>
) -> vec4<f32>

premultiply_alpha

#

Shader defs requirments:

🟢 PREMULTIPLY_ALPHA

fn premultiply_alpha (
standard_material_flags: u32
) -> vec4<f32>

main_pass_post_lighting_processing

#

fog, alpha premultiply for non-hdr cameras, tonemapping and debanding

fn main_pass_post_lighting_processing (
pbr_input: pbr_types
input_color: vec4<f32>
) -> vec4<f32>