Documentation / scene / DrawContext
Interface: DrawContext
Defined in: libs/scene/src/render/drawable.ts:46
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:48
Render device used for issuing GPU commands.
renderWidth
readonlyrenderWidth:number
Defined in: libs/scene/src/render/drawable.ts:50
Framebuffer width for rendering (in pixels).
renderHeight
readonlyrenderHeight:number
Defined in: libs/scene/src/render/drawable.ts:52
Framebuffer height for rendering (in pixels).
globalBindGroupAllocator
readonlyglobalBindGroupAllocator:GlobalBindGroupAllocator
Defined in: libs/scene/src/render/drawable.ts:54
Allocator for global (frame/pass) bind groups and descriptor resources.
camera
readonlycamera:Camera
Defined in: libs/scene/src/render/drawable.ts:56
The camera associated with the current drawing task (may differ from primaryCamera).
oit
oit:
OIT
Defined in: libs/scene/src/render/drawable.ts:58
Order-Independent Transparency interface for transparent passes.
motionVectors
readonlymotionVectors:boolean
Defined in: libs/scene/src/render/drawable.ts:60
Whether motion vectors are being written this pass (used by TAA/MotionBlur).
motionVectorTexture?
optionalmotionVectorTexture?:Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:62
Motion vector texture target when motion vectors are active.
HiZ
readonlyHiZ:boolean
Defined in: libs/scene/src/render/drawable.ts:64
Whether hierarchical depth (Hi-Z) is enabled for the current pass.
HiZTexture
HiZTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:66
Hi-Z (hierarchical Z) depth texture, when generated.
screenSpaceShadowMask
readonlyscreenSpaceShadowMask:boolean
Defined in: libs/scene/src/render/drawable.ts:73
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:80
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:88
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.
scene
readonlyscene:Scene
Defined in: libs/scene/src/render/drawable.ts:90
The scene currently being drawn.
renderPass
renderPass:
RenderPass
Defined in: libs/scene/src/render/drawable.ts:92
The render pass to which this drawing task belongs.
renderPassHash
renderPassHash:
string
Defined in: libs/scene/src/render/drawable.ts:94
Stable hash for the current pass/draw state, for render bundle or pipeline cache.
flip
flip:
boolean
Defined in: libs/scene/src/render/drawable.ts:96
Whether the output orientation is flipped vertically (e.g., due to framebuffer conventions).
drawEnvLight
drawEnvLight:
boolean
Defined in: libs/scene/src/render/drawable.ts:98
Whether this is the base lighting pass that draws environment lighting.
env
env:
Environment
Defined in: libs/scene/src/render/drawable.ts:100
Scene environment (sky, IBL, exposure, etc.) used for shading.
queue
queue:
number
Defined in: libs/scene/src/render/drawable.ts:102
Current sub-queue index within the render queue (e.g., opaque, transparent).
lightBlending
lightBlending:
boolean
Defined in: libs/scene/src/render/drawable.ts:104
Whether the current lighting pass is blending light accumulations.
depthTexture?
optionaldepthTexture?:Texture2D
Defined in: libs/scene/src/render/drawable.ts:106
Scene (non-linear) depth texture bound for sampling.
linearDepthTexture?
optionallinearDepthTexture?:Texture2D
Defined in: libs/scene/src/render/drawable.ts:108
Linearized depth texture bound for sampling.
depthPrepassAttachment?
optionaldepthPrepassAttachment?:Texture2D
Defined in: libs/scene/src/render/drawable.ts:110
Depth attachment populated by the scene depth prepass, when current target reuses it.
sceneColorTexture?
optionalsceneColorTexture?:Texture2D
Defined in: libs/scene/src/render/drawable.ts:112
Scene color texture bound for sampling (previous pass or resolved color).
depthFormat
readonlydepthFormat:TextureFormat
Defined in: libs/scene/src/render/drawable.ts:114
Default depth buffer format for targets created in this pass.
colorFormat
readonlycolorFormat:TextureFormat
Defined in: libs/scene/src/render/drawable.ts:116
Default color buffer format for targets created in this pass.
instanceData?
optionalinstanceData?:InstanceData
Defined in: libs/scene/src/render/drawable.ts:118
Instance data buffer/metadata for the current drawing task (instanced rendering).
compositor?
optionalcompositor?:Compositor
Defined in: libs/scene/src/render/drawable.ts:120
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:126
Sun/directional light reference for passes that need it.
primaryDirectionalLight?
optionalprimaryDirectionalLight?:DirectionalLight
Defined in: libs/scene/src/render/drawable.ts:128
Primary directional light fallback when no explicit sun light is marked.
primaryTransmissionLight?
optionalprimaryTransmissionLight?:PunctualLight
Defined in: libs/scene/src/render/drawable.ts:130
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:132
Clustered light index/structure for lighting in forward+, clustered shading, etc.
materialFlags
materialFlags:
number
Defined in: libs/scene/src/render/drawable.ts:134
Material varying bit flags that influence shader selection.
forceCullMode?
optionalforceCullMode?:FaceMode
Defined in: libs/scene/src/render/drawable.ts:136
Force cull mode override for special passes (optional).
forceColorState?
optionalforceColorState?:ColorState
Defined in: libs/scene/src/render/drawable.ts:138
Force color mask state override for special passes (optional).
SSR
readonlySSR:boolean
Defined in: libs/scene/src/render/drawable.ts:140
Screen-space reflections are active this frame/pass.
SSS
SSS:
boolean
Defined in: libs/scene/src/render/drawable.ts:142
Screen-space subsurface scattering is active this frame/pass.
SSRCalcThickness
SSRCalcThickness:
boolean
Defined in: libs/scene/src/render/drawable.ts:144
Whether SSR thickness should be computed dynamically in this pass.
SSRRoughnessTexture
SSRRoughnessTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:146
SSR roughness input texture.
SSRNormalTexture
SSRNormalTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:148
SSR normal input texture (usually view-space or world-space normals).
SSSProfileTexture
SSSProfileTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:150
SSS profile texture (rgb = scatter strength, a = transmission mask).
SSSParamTexture
SSSParamTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:152
SSS param texture (r = normalized profile slot, g = blur width).
SSSDiffuseTexture
SSSDiffuseTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:154
SSS diffuse-lighting texture used so scattering can preserve specular detail.
SSSTransmissionTexture
SSSTransmissionTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:156
SSS transmission-lighting texture used for thin-shell/backscatter contributions.
SkinSSSTexture
SkinSSSTexture:
Texture2D<unknown>
Defined in: libs/scene/src/render/drawable.ts:158
Skin-specific screen-space scattering source texture.
ssrSDFBoxBuffer
ssrSDFBoxBuffer:
GPUDataBuffer<unknown>
Defined in: libs/scene/src/render/drawable.ts:160
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:162
Number of valid SDF proxy boxes in ssrSDFBoxBuffer.
finalFramebuffer
finalFramebuffer:
FrameBuffer<unknown>
Defined in: libs/scene/src/render/drawable.ts:164
Final framebuffer target where the last stage renders.
intermediateFramebuffer
intermediateFramebuffer:
FrameBuffer<unknown>
Defined in: libs/scene/src/render/drawable.ts:166
Intermediate framebuffer used by the compositor or multi-pass pipelines.