punctual_light
The engine's punctual-light response in Luau, for a suite that reads a rendered pixel and has to say what light a point light should have put there.
A case that asserts a rendered value against another platform's rendered value can only report that two pictures differ. A case that asserts it against a number the shading model predicts fails on the platform that is wrong, on its own, and names what it expected.
local PunctualLight = require("@builtin::tests.fixtures.punctual_light")
local radiance = PunctualLight.radiance({ 1.0, 0.6, 0.3 }, 4.0, 2.0, 8.0)
local light = PunctualLight.normalIncidenceResponse(
{ albedo = { 1, 1, 1 }, roughness = 0.5, metallic = 0 }, radiance)
-- … compare `light` against the pixel the capture returned, through
-- `@builtin::tests.fixtures.display_curve` …
falloff is zero_punctual_falloff in
src/lua/lib/shaderModules/engine_bindings.shaderModule/module.wgsl — the one
curve every reader of a light's reach answers from, so a case predicting a
light's arrival at a distance answers from the same curve the frame did.
normalIncidenceResponse is zpbr_direct_full in
src/lua/lib/shaderModules/pbr_shading.shaderModule/module.wgsl, evaluated
where the surface normal, the direction to the camera and the direction to the
light coincide. There the half-vector is the normal and every angular term is
1, so the Fresnel term is F0, the GGX distribution is α²/(π·α⁴) and the Smith
visibility is 1 — the whole BRDF becomes two constants of the surface. That is
the geometry a case has to arrange to state its expected light as a number, and
arranging it is what analyticPlaneFixture in the lighting_golden suite's
own fixtures does.
The response covers the diffuse and specular lobes a plain metallic-roughness surface has. A material declaring clearcoat, sheen, fibre, anisotropy or iridescence adds lobes on top of them, and a case reading such a surface is reading more light than this predicts.
Scoped to this part · feeds back into the world's score.