Documentation / scene / DrawContext
Interface: DrawContext
Defined in: libs/scene/src/render/drawable.ts:48
Context object passed to draw calls and render helpers.
It aggregates all per-frame, per-pass, and per-draw state derived from the engine and renderer, including device handles, textures, passes, flags, and post-processing links.
Notes:
- Not all textures/fields are present for every pass; check for undefined when optional.
- Values like
HiZ,TAA,SSRsignal features the renderer has activated for the current pass.
Properties
device
readonlydevice:AbstractDevice
Defined in: libs/scene/src/render/drawable.ts:50
Render device used for issuing GPU commands.
renderWidth
readonlyrenderWidth:number
Defined in: libs/scene/src/render/drawable.ts:52
Framebuffer width for rendering (in pixels).
renderHeight
readonlyrenderHeight:number
Defined in: libs/scene/src/render/drawable.ts:54
Framebuffer height for rendering (in pixels).
globalBindGroupAllocator
readonlyglobalBindGroupAllocator:GlobalBindGroupAllocator
Defined in: libs/scene/src/render/drawable.ts:56
Allocator for global (frame/pass) bind groups and descriptor resources.
camera
readonlycamera:Camera
Defined in: libs/scene/src/render/drawable.ts:58
The camera associated with the current drawing task (may differ from primaryCamera).
oit
oit:
OIT
Defined in: libs/scene/src/render/drawable.ts:60
Order-Independent Transparency interface for transparent passes.
motionVectors
motionVectors:
boolean
Defined in: libs/scene/src/render/drawable.ts:62
Whether motion vectors are being written this pass (used by TAA/MotionBlur).
motionVectorTexture?
optionalmotionVectorTexture?:Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:64
Motion vector texture target when motion vectors are active.
HiZ
HiZ:
boolean
Defined in: libs/scene/src/render/drawable.ts:66
Whether hierarchical depth (Hi-Z) is enabled for the current pass.
HiZTexture
HiZTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:68
Hi-Z (hierarchical Z) depth texture, when generated.
screenSpaceShadowMask
screenSpaceShadowMask:
boolean
Defined in: libs/scene/src/render/drawable.ts:75
Whether the screen-space shadow mask path is active for this pass. When true, shadow-casting lights occupy the head of the clustered light buffer and are shaded through the clustered pass sampling a pre-rendered shadow mask, rather than via per-light additive passes.
shadowMaskTexture?
optionalshadowMaskTexture?:Texture2DArray<unknown>
Defined in: libs/scene/src/render/drawable.ts:82
Screen-space shadow mask array, produced by the ShadowMaskPass when DrawContext.screenSpaceShadowMask is active. Each RGBA8 layer packs four shadow lights (one per channel); a clustered light at buffer index i (1..N) samples layer = (i-1) >> 2, channel = (i-1) & 3.
shadowMaskClusterSample?
optionalshadowMaskClusterSample?:boolean
Defined in: libs/scene/src/render/drawable.ts:90
Whether the current clustered light pass should sample the opaque shadow mask for shadow-casting lights. True for the opaque queue; false for transparent queues (e.g. OIT hair), where shadow lights are instead lit inline by the additive passes because the opaque-depth mask does not represent transparent surfaces. Only meaningful while DrawContext.screenSpaceShadowMask is on.
waterCaustics
waterCaustics:
boolean
Defined in: libs/scene/src/render/drawable.ts:96
Whether a water caustic map was produced this frame and should modulate the caustic light. Keyed into the light pass shader/bind group hashes, so the declared and bound global layouts always agree.
waterCausticLight?
optionalwaterCausticLight?:PunctualLight
Defined in: libs/scene/src/render/drawable.ts:101
The light whose additive shadow pass receives the caustics. Only that pass applies them; every other light is unaffected.
waterCausticTexture?
optionalwaterCausticTexture?:Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:103
Caustic map produced by the WaterCaustics pass.
waterCausticHeightTexture?
optionalwaterCausticHeightTexture?:Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:108
Displaced water surface height per water slot, on the same slice as DrawContext.waterCausticTexture. Produced alongside the map.
waterCausticUniforms?
optionalwaterCausticUniforms?:WaterCausticUniforms
Defined in: libs/scene/src/render/drawable.ts:110
Parameters describing the projection of DrawContext.waterCausticTexture.
underwater
underwater:
UnderwaterState
Defined in: libs/scene/src/render/drawable.ts:119
The body of water the camera is inside this frame, or null when it is above all of them.
Resolved once per frame before the graph is built, because it gates work as early as the light pass: atmospheric fog is suppressed while submerged, the medium being water rather than air.
scene
readonlyscene:Scene
Defined in: libs/scene/src/render/drawable.ts:121
The scene currently being drawn.
renderPass
renderPass:
RenderPass
Defined in: libs/scene/src/render/drawable.ts:123
The render pass to which this drawing task belongs.
renderPassHash
renderPassHash:
string
Defined in: libs/scene/src/render/drawable.ts:125
Resource-aware hash for the current pass/draw state, including runtime texture identities.
shaderVariantHash
shaderVariantHash:
string
Defined in: libs/scene/src/render/drawable.ts:127
Shader-only variant hash; excludes runtime resource identities when possible.
flip
flip:
boolean
Defined in: libs/scene/src/render/drawable.ts:129
Whether the output orientation is flipped vertically (e.g., due to framebuffer conventions).
drawEnvLight
drawEnvLight:
boolean
Defined in: libs/scene/src/render/drawable.ts:131
Whether this is the base lighting pass that draws environment lighting.
env
env:
Environment
Defined in: libs/scene/src/render/drawable.ts:133
Scene environment (sky, IBL, exposure, etc.) used for shading.
queue
queue:
number
Defined in: libs/scene/src/render/drawable.ts:135
Current sub-queue index within the render queue (e.g., opaque, transparent).
lightBlending
lightBlending:
boolean
Defined in: libs/scene/src/render/drawable.ts:137
Whether the current lighting pass is blending light accumulations.
depthTexture?
optionaldepthTexture?:Texture2D
Defined in: libs/scene/src/render/drawable.ts:139
Scene (non-linear) depth texture bound for sampling.
linearDepthTexture?
optionallinearDepthTexture?:Texture2D
Defined in: libs/scene/src/render/drawable.ts:141
Linearized depth texture bound for sampling.
depthPrepassAttachment?
optionaldepthPrepassAttachment?:Texture2D
Defined in: libs/scene/src/render/drawable.ts:143
Depth attachment populated by the scene depth prepass, when current target reuses it.
sceneColorTexture?
optionalsceneColorTexture?:Texture2D
Defined in: libs/scene/src/render/drawable.ts:145
Scene color texture bound for sampling (previous pass or resolved color).
depthFormat
readonlydepthFormat:TextureFormat
Defined in: libs/scene/src/render/drawable.ts:147
Default depth buffer format for targets created in this pass.
colorFormat
readonlycolorFormat:TextureFormat
Defined in: libs/scene/src/render/drawable.ts:149
Default color buffer format for targets created in this pass.
instanceData?
optionalinstanceData?:InstanceData
Defined in: libs/scene/src/render/drawable.ts:151
Instance data buffer/metadata for the current drawing task (instanced rendering).
compositor?
optionalcompositor?:Compositor
Defined in: libs/scene/src/render/drawable.ts:153
Compositor used to apply post-processing effects at the end of the frame/pass.
sunLight?
optionalsunLight?:DirectionalLight
Defined in: libs/scene/src/render/drawable.ts:159
Sun/directional light reference for passes that need it.
primaryDirectionalLight?
optionalprimaryDirectionalLight?:DirectionalLight
Defined in: libs/scene/src/render/drawable.ts:161
Primary directional light fallback when no explicit sun light is marked.
primaryTransmissionLight?
optionalprimaryTransmissionLight?:PunctualLight
Defined in: libs/scene/src/render/drawable.ts:163
Primary punctual light fallback used by effects that need a representative thin-transmission light.
clusteredLight?
optionalclusteredLight?:ClusteredLight
Defined in: libs/scene/src/render/drawable.ts:165
Clustered light index/structure for lighting in forward+, clustered shading, etc.
materialFlags
materialFlags:
number
Defined in: libs/scene/src/render/drawable.ts:167
Material varying bit flags that influence shader selection.
forceCullMode?
optionalforceCullMode?:FaceMode
Defined in: libs/scene/src/render/drawable.ts:169
Force cull mode override for special passes (optional).
forceColorState?
optionalforceColorState?:ColorState
Defined in: libs/scene/src/render/drawable.ts:171
Force color mask state override for special passes (optional).
SSR
readonlySSR:boolean
Defined in: libs/scene/src/render/drawable.ts:173
Screen-space reflections are active this frame/pass.
SSGI
SSGI:
boolean
Defined in: libs/scene/src/render/drawable.ts:175
Screen-space diffuse global illumination is active for this frame.
SSGIIrradianceHistoryTexture
SSGIIrradianceHistoryTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:177
Previous denoised SSGI irradiance, scoped to the opaque light pass.
SSGISurfaceHistoryTexture
SSGISurfaceHistoryTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:179
Previous SSGI normal/depth surface data, scoped to the opaque light pass.
SSS
SSS:
boolean
Defined in: libs/scene/src/render/drawable.ts:181
Screen-space subsurface scattering is active this frame/pass.
SSRCalcThickness
SSRCalcThickness:
boolean
Defined in: libs/scene/src/render/drawable.ts:183
Whether SSR thickness should be computed dynamically in this pass.
SceneRoughnessTexture
SceneRoughnessTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:185
Per-pixel perceptual roughness and reflection data for opaque scene surfaces.
SceneNormalTexture
SceneNormalTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:187
Encoded world-space normal for opaque scene surfaces.
SSSProfileTexture
SSSProfileTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:189
SSS profile texture (rgb = scatter strength, a = transmission mask).
SSSParamTexture
SSSParamTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:191
SSS param texture (r = normalized profile slot, g = blur width).
SSSDiffuseTexture
SSSDiffuseTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:193
SSS diffuse-lighting texture used so scattering can preserve specular detail.
SSSTransmissionTexture
SSSTransmissionTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:195
SSS transmission-lighting texture used for thin-shell/backscatter contributions.
SkinSSSTexture
SkinSSSTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:197
Skin-specific screen-space scattering source texture.
ssrSDFBoxBuffer
ssrSDFBoxBuffer:
GPUDataBuffer<unknown>
Defined in: libs/scene/src/render/drawable.ts:199
SSR SDF proxy uniform buffer (pair of vec4: min.xyz / max.xyz for each box).
ssrSDFBoxCount
ssrSDFBoxCount:
number
Defined in: libs/scene/src/render/drawable.ts:201
Number of valid SDF proxy boxes in ssrSDFBoxBuffer.
finalFramebuffer
finalFramebuffer:
FrameBuffer<unknown>
Defined in: libs/scene/src/render/drawable.ts:203
Final framebuffer target where the last stage renders.
intermediateFramebuffer
intermediateFramebuffer:
FrameBuffer<unknown>
Defined in: libs/scene/src/render/drawable.ts:205
Intermediate framebuffer used by the compositor or multi-pass pipelines.