Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.

Constants

LAYER_BASE

#
const LAYER_BASE: u32 = 0

LAYER_CLEARCOAT

#
const LAYER_CLEARCOAT: u32 = 1

CUBEMAP_TYPE_CROSS_VERTICAL

#
const CUBEMAP_TYPE_CROSS_VERTICAL: u32 = 0

CUBEMAP_TYPE_CROSS_HORIZONTAL

#
const CUBEMAP_TYPE_CROSS_HORIZONTAL: u32 = 1

CUBEMAP_TYPE_SEQUENCE_VERTICAL

#
const CUBEMAP_TYPE_SEQUENCE_VERTICAL: u32 = 2

CUBEMAP_TYPE_SEQUENCE_HORIZONTAL

#
const CUBEMAP_TYPE_SEQUENCE_HORIZONTAL: u32 = 3

X_PLUS

#
const X_PLUS: u32 = 0

X_MINUS

#
const X_MINUS: u32 = 1

Y_PLUS

#
const Y_PLUS: u32 = 2

Y_MINUS

#
const Y_MINUS: u32 = 3

Z_MINUS

#
const Z_MINUS: u32 = 4

Z_PLUS

#
const Z_PLUS: u32 = 5

Structures

LayerLightingInput

#

Input to a lighting function for a single layer (either the base layer or the clearcoat layer).

struct LayerLightingInput {
N: vec3<f32> ,
R: vec3<f32> ,
NdotV: f32 ,
perceptual_roughness: f32 ,
roughness: f32 ,
}

LightingInput

#

Input to a lighting function (point_light, spot_light, directional_light).

struct LightingInput {
@if(STANDARD_MATERIAL_CLEARCOAT)
layers: array<LayerLightingInput, 2> ,
@else()
layers: array<LayerLightingInput, 1> ,
P: vec3<f32> ,
V: vec3<f32> ,
diffuse_color: vec3<f32> ,
metallic: f32 ,
F0_dielectric: vec3<f32> ,
F0_metallic: vec3<f32> ,
F_ab: vec2<f32> ,
@if(STANDARD_MATERIAL_CLEARCOAT)
clearcoat_strength: f32 ,
@if(STANDARD_MATERIAL_ANISOTROPY)
anisotropy: f32 ,
@if(STANDARD_MATERIAL_ANISOTROPY)
Ta: vec3<f32> ,
@if(STANDARD_MATERIAL_ANISOTROPY)
Ba: vec3<f32> ,
}

DerivedLightingInput

#

Values derived from the LightingInput for both diffuse and specular lights.

struct DerivedLightingInput {
H: vec3<f32> ,
NdotL: f32 ,
NdotH: f32 ,
LdotH: f32 ,
}

Functions

getDistanceAttenuation

#

light radius is a non-physical construct for efficiency purposes, because otherwise every light affects every fragment in the scene

fn getDistanceAttenuation (
distanceSquare: f32
, 
inverseRangeSquared: f32
) -> f32

getRangeFalloff

#

Falloff without the distance attenuation, for lights that have it baked-in (eg LTC lights)

fn getRangeFalloff (
distanceSquare: f32
, 
inverseRangeSquared: f32
) -> f32

D_GGX

#

Simple implementation, has precision problems when using fp16 instead of fp32 see https://google.github.io/filament/Filament.md.html#listing_speculardfp16

fn D_GGX (
roughness: f32
, 
NdotH: f32
) -> f32

D_GGX_anisotropic

#
fn D_GGX_anisotropic (
at: f32
, 
ab: f32
, 
NdotH: f32
, 
TdotH: f32
, 
BdotH: f32
) -> f32

V_SmithGGXCorrelated

#

Visibility function (Specular G) V(v,l,a) = G(v,l,α) / { 4 (n⋅v) (n⋅l) } such that f_r becomes f_r(v,l) = D(h,α) V(v,l,α) F(v,h,f0) where V(v,l,α) = 0.5 / { n⋅l sqrt((n⋅v)^2 (1−α2) + α2) + n⋅v sqrt((n⋅l)^2 (1−α2) + α2) } Note the two sqrt’s, that may be slow on mobile, see https://google.github.io/filament/Filament.md.html#listing_approximatedspecularv

fn V_SmithGGXCorrelated (
roughness: f32
, 
NdotV: f32
, 
NdotL: f32
) -> f32

V_GGX_anisotropic

#

The visibility function, anisotropic variant.

fn V_GGX_anisotropic (
at: f32
, 
ab: f32
, 
NdotL: f32
, 
NdotV: f32
, 
BdotV: f32
, 
TdotV: f32
, 
TdotL: f32
, 
BdotL: f32
) -> f32

ggx_vndf_pdf

#

Probability-density function that matches the bounded VNDF sampler https://gpuopen.com/download/Bounded_VNDF_Sampling_for_Smith-GGX_Reflections.pdf (Listing 2)

fn ggx_vndf_pdf (
i: vec3<f32>
, 
NdotH: f32
, 
roughness: f32
) -> f32

sample_visible_ggx

#
fn sample_visible_ggx (
xi: vec2<f32>
, 
roughness: f32
, 
normal: vec3<f32>
, 
view: vec3<f32>
) -> vec3<f32>

G_Smith

#

Smith geometric shadowing function

fn G_Smith (
NdotV: f32
, 
NdotL: f32
, 
roughness: f32
) -> f32

V_Kelemen

#

F_Schlick_vec

#

Fresnel function see https://google.github.io/filament/Filament.md.html#citation-schlick94 F_Schlick(v,h,f_0,f_90) = f_0 + (f_90 − f_0) (1 − v⋅h)^5

fn F_Schlick_vec (
f0: vec3<f32>
, 
f90: f32
, 
VdotH: f32
) -> vec3<f32>

F_Schlick

#

Fresnel function see https://google.github.io/filament/Filament.md.html#citation-schlick94 F_Schlick(v,h,f_0,f_90) = f_0 + (f_90 − f_0) (1 − v⋅h)^5

fn F_Schlick (
f0: f32
, 
f90: f32
, 
VdotH: f32
) -> f32

fresnel

#
fn fresnel (
f0: vec3<f32>
, 
LdotH: f32
) -> vec3<f32>

specular_multiscatter

#
fn specular_multiscatter (
D: f32
, 
V: f32
, 
F: vec3<f32>
, 
F0: vec3<f32>
, 
F_ab: vec2<f32>
, 
specular_intensity: f32
) -> vec3<f32>

derive_lighting_input

#

N, V, and L must all be normalized.

fn derive_lighting_input (
N: vec3<f32>
, 
V: vec3<f32>
, 
L: vec3<f32>
) -> DerivedLightingInput

compute_specular_layer_values_for_point_light

#

Returns L in the xyz components and the modified roughness in the w component.

fn compute_specular_layer_values_for_point_light (
input: ptr<function, LightingInput>
, 
layer: u32
, 
V: vec3<f32>
, 
light_to_frag: vec3<f32>
, 
light_radius: f32
, 
distance: f32
) -> vec4<f32>

specular

#

Cook-Torrance approximation of the microfacet model integration using Fresnel law F to model f_m f_r(v,l) = { D(h,α) G(v,l,α) F(v,h,f0) } / { 4 (n⋅v) (n⋅l) }

fn specular (
input: ptr<function, LightingInput>
, 
derived_input: ptr<function, DerivedLightingInput>
, 
roughness: f32
, 
specular_intensity: f32
) -> vec3<f32>

specular_clearcoat

#
fn specular_clearcoat (
input: ptr<function, LightingInput>
, 
derived_input: ptr<function, DerivedLightingInput>
, 
clearcoat_strength: f32
, 
roughness: f32
, 
specular_intensity: f32
) -> vec2<f32>

specular_anisotropy

#
fn specular_anisotropy (
input: ptr<function, LightingInput>
, 
derived_input: ptr<function, DerivedLightingInput>
, 
L: vec3<f32>
, 
roughness: f32
, 
specular_intensity: f32
) -> vec3<f32>

Fd_Burley

#

Disney approximation See https://google.github.io/filament/Filament.md.html#citation-burley12 minimal quality difference

fn Fd_Burley (
input: ptr<function, LightingInput>
, 
derived_input: ptr<function, DerivedLightingInput>
) -> f32

F_AB

#

Scale/bias approximation

fn F_AB (
perceptual_roughness: f32
, 
NdotV: f32
) -> vec2<f32>

EnvBRDFApprox

#
fn EnvBRDFApprox (
F0: vec3<f32>
, 
F_ab: vec2<f32>
) -> vec3<f32>

perceptualRoughnessToRoughness

#
fn perceptualRoughnessToRoughness (
perceptualRoughness: f32
) -> f32

cubemap_uv

#
fn cubemap_uv (
direction: vec3<f32>
, 
cubemap_type: u32
) -> vec2<f32>

specular_fix_remap

#

The ideal solution is to switch to Linearly Transformed Cosines, which is more accurate in all cases, and a popular choice for realtime.

fn specular_fix_remap (
a: f32
) -> f32

point_light

#
fn point_light (
light_id: u32
, 
input: ptr<function, LightingInput>
, 
enable_diffuse: bool
, 
enable_texture: bool
) -> vec3<f32>

spot_light

#
fn spot_light (
light_id: u32
, 
input: ptr<function, LightingInput>
, 
enable_diffuse: bool
) -> vec3<f32>

directional_light

#
fn directional_light (
light_id: u32
, 
input: ptr<function, LightingInput>
, 
enable_diffuse: bool
) -> vec3<f32>

ltc_integrate_edge

#

Integrate one edge of the spherical polygon formed by the LTC-transformed quad. Implements Eq. 11 using a polynomial approximation based on https://advances.realtimerendering.com/s2016/s2016_ltc_rnd.pdf Using the equation as-is produces visible artifacts.

fn ltc_integrate_edge (
v1: vec3<f32>
, 
v2: vec3<f32>
) -> f32

ltc_integrate_quad

#
fn ltc_integrate_quad (
N: vec3<f32>
, 
V: vec3<f32>
, 
P: vec3<f32>
, 
Minv: mat3x3<f32>
, 
points: array<vec3<f32>, 4>
) -> f32

unpack_clustered_rect_light

#

Decodes a rect light packed into a ClusteredLight (see GpuClusteredLight in bevy_pbr/src/cluster/mod.rs).

fn unpack_clustered_rect_light (
light_id: u32
) -> RectLight

rect_light

#
fn rect_light (
light: ptr<function, RectLight>
, 
input: ptr<function, LightingInput>
, 
enable_diffuse: bool
) -> vec3<f32>

sample_transmittance_lut

#
fn sample_transmittance_lut (
r: f32
, 
mu: f32
) -> vec3<f32>
Contents