Skip to content

Built-in Shader Uniforms

To use built-in shader variables, you need to include the corresponding chunks first. All currently available built-in uniforms, grouped by the chunks they are located:

cc-local.chunk

NameTypeInfo
cc_matWorldmat4model to world transform matrix
cc_matWorldITmat4inverse-transpose of model to world transform matrix

cc-global.chunk

NameTypeInfo
cc_timevec4x: seconds since engine started
cc_screenSizevec4xy: shading screen size
zw: reciprocal of shading screen size
cc_screenScalevec4xy: screen scale
zw: reciprocal of screen scale
cc_nativeSizevec4xy: canvas size
zw: reciprocal of canvas size
cc_matViewmat4view transform matrix
cc_matViewInvmat4inverse view matrix
cc_matProjmat4projection transform matrix
cc_matProjInvmat4inverse projection transform matrix
cc_matViewProjmat4view-projection transform matrix
cc_matViewProjInvmat4inverse view-projection transform matrix
cc_cameraPosvec4xyz: camera position
cc_exposurevec4x: camera exposure
y: reciprocal of camera exposure
z: is HDR enabled w: HDR-LDR scaling factor
cc_mainLitDirvec4xyz: direction of the main directional light
cc_mainLitColorvec4xyz: color of the main directional light
w: intensity
cc_ambientSkyvec4xyz: ambient sky color
w: intensity
cc_ambientGroundvec4xyz: ambient ground color

cc-environment.chunk

NameTypeInfo
cc_environmentsamplerCubeIBL environment map

cc-forward-light.chunk

NameTypeInfo
cc_sphereLitPos[MAX_LIGHTS]vec4xyz: position of spherical lights
cc_sphereLitSizeRange[MAX_LIGHTS]vec4x: size of spherical lights
y: range of spherical lights
cc_sphereLitColor[MAX_LIGHTS]vec4xyz: color of spherical lights
w: intensity
cc_spotLitPos[MAX_LIGHTS]vec4xyz: position of spotlights
cc_spotLitSizeRangeAngle[MAX_LIGHTS]vec4x: size of spotlights
y: range of spotlights
z: angle of spotlights
cc_spotLitDir[MAX_LIGHTS]vec4xyz: direction of spotlights
cc_spotLitColor[MAX_LIGHTS]vec4xyz: color of spotlights
w: intensity

cc-shadow.chunk

NameTypeInfo
cc_matLightPlaneProjmat4planar shadow transform matrix
cc_shadowColorvec4shadow color