Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit61a33237e0

README.md

scene_proxy

The scene proxy's query surface, for shaders.

A shader that includes this gets spDistance (how far the nearest surface is from a world point), spNormal (which way it lies), spTrace (march a ray through the field) and spOccluded (can these two points see each other) — the four questions a lighting technique asks of geometry, answered from the distance grid instead of from triangles.

#include "@builtin::systems.sceneProxy.scene_proxy"

let g = spGridFrom(my_params[0], my_params[1]);
let d = spDistance(my_field, g, p);

The field is unsigned and reads ~0 at a surface, which is where the two points of a visibility query ordinarily sit. spOccluded therefore leaves the surface its first point rests on before it starts testing, and stops short of its second by hitAt — a shading point asking whether it can see a light is the query it is for, and both ends would otherwise occlude themselves.

The field is passed in as an argument rather than bound here, so this fixes no binding layout: bind the texture_3d<f32> under any name and hand it over. What it does fix is the grid convention — where a voxel sits in the world and what its stored number measures — so the build passes and every reader agree on one definition. sceneProxy.gridParams() packs the two vec4 spGridFrom reads.

proxy_probe.computeShader in this package is the smallest complete user of it.