Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

pbr_shading

The physically-based shading library a surface shader opts into: a PbrSurface describing the material at one pixel, and the forward light loop that shades it against the frame's sun, point and spot lights, shadows and environment.

zero_pbr_default_surface(input) builds a neutral surface from the fragment; set the fields the material cares about and hand it to zero_pbr_shade, which returns the lit colour. The low-level zpbr_* terms are pure math for a shader that wants to assemble its own BRDF instead.

// @domain: surface
#include "@builtin::shaderModules.pbr_shading"

fn fragment(input: FragmentData) -> vec4<f32> {
    var s = zero_pbr_default_surface(input);
    s.albedo = material.base_color.rgb;
    return vec4<f32>(zero_pbr_shade(input, s), 1.0);
}