SceneUpload Module
Shader-agnostic scene-data upload: resolves uniform names on any Shader.
What is uploaded (when the uniform is present on the target shader; absent locations are
skipped — raylib returns -1 from GetShaderLocation): matrices
(matModel/viewProj/normalMatrix/cameraPos), material
(albedoColor, texture0..4, roughness/metallic/emissionColor/
opacity/tiling/useNormalMap), lights (ambient + 1 directional + N point +
M spot, including per-light shadow indices), shadows (the atlas + shadowViewProjs[]/
shadowUVOffsets[]/shadowBiases[]/dirLightCastsShadows, when the frame has a
ShadowResult), and bones
(boneMatrices, only when supplied).
Shadows are opt-in by declaration. A user shader that wants shadow sampling declares the
shadow uniforms (shadowViewProjs[], shadowUVOffsets[], shadowBiases[],
dirLightCastsShadows, pointLightShadowIdx[], spotLightShadowIdx[]) and a
shadowAtlas sampler; when the frame's shadow pass produced an atlas, those uniforms are
uploaded by name and the atlas is bound to sampler slot 15. A shader that declares none of them
renders unshadowed — no cost, no sampling. When the frame has no shadow-casting light,
dirLightCastsShadows is set to 0 and nothing else shadow-related is uploaded.
Functions and values
| Function or value |
Description
|
Full Usage:
uploadToShader (shader, view, projection, cameraPos, world, normalMatrix, lights, shadows, bones, material, time)
Parameters:
Shader
-
The target shader (user-owned).
view : Matrix4x4
-
Active camera view matrix.
projection : Matrix4x4
-
Active camera projection matrix.
cameraPos : Vector3
-
Active camera world position.
world : Matrix4x4
-
The draw's world/model matrix.
normalMatrix : Matrix4x4
-
transpose(inverse(world)).
lights : LightBuffers
-
The frame's accumulated lights.
shadows : ShadowResult voption
-
The frame's shadow pass output (ValueNone when no shadow-casting light).
bones : Matrix4x4[] voption
-
Bone palette (ValueSome for skinned draws; ValueNone otherwise).
material : Material3D
-
The draw's material.
time : float32
-
Total elapsed game time, in seconds — the time uniform for animated shaders.
|
Uploads the full scene-data contract to shader by resolving each uniform
by name. Absent uniforms are skipped (raylib returns -1). Uploads matrices (matModel/viewProj/
normalMatrix/cameraPos), the
|
Mibo