Skip to content

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, SSR signal features the renderer has activated for the current pass.

Properties

device

readonly device: AbstractDevice

Defined in: libs/scene/src/render/drawable.ts:50

Render device used for issuing GPU commands.


renderWidth

readonly renderWidth: number

Defined in: libs/scene/src/render/drawable.ts:52

Framebuffer width for rendering (in pixels).


renderHeight

readonly renderHeight: number

Defined in: libs/scene/src/render/drawable.ts:54

Framebuffer height for rendering (in pixels).


globalBindGroupAllocator

readonly globalBindGroupAllocator: GlobalBindGroupAllocator

Defined in: libs/scene/src/render/drawable.ts:56

Allocator for global (frame/pass) bind groups and descriptor resources.


camera

readonly camera: 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?

optional motionVectorTexture?: 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?

optional shadowMaskTexture?: 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?

optional shadowMaskClusterSample?: 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?

optional waterCausticLight?: 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?

optional waterCausticTexture?: Texture2D<unknown>

Defined in: libs/scene/src/render/drawable.ts:103

Caustic map produced by the WaterCaustics pass.


waterCausticHeightTexture?

optional waterCausticHeightTexture?: 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?

optional waterCausticUniforms?: 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

readonly scene: 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?

optional depthTexture?: Texture2D

Defined in: libs/scene/src/render/drawable.ts:139

Scene (non-linear) depth texture bound for sampling.


linearDepthTexture?

optional linearDepthTexture?: Texture2D

Defined in: libs/scene/src/render/drawable.ts:141

Linearized depth texture bound for sampling.


depthPrepassAttachment?

optional depthPrepassAttachment?: Texture2D

Defined in: libs/scene/src/render/drawable.ts:143

Depth attachment populated by the scene depth prepass, when current target reuses it.


sceneColorTexture?

optional sceneColorTexture?: Texture2D

Defined in: libs/scene/src/render/drawable.ts:145

Scene color texture bound for sampling (previous pass or resolved color).


depthFormat

readonly depthFormat: TextureFormat

Defined in: libs/scene/src/render/drawable.ts:147

Default depth buffer format for targets created in this pass.


colorFormat

readonly colorFormat: TextureFormat

Defined in: libs/scene/src/render/drawable.ts:149

Default color buffer format for targets created in this pass.


instanceData?

optional instanceData?: InstanceData

Defined in: libs/scene/src/render/drawable.ts:151

Instance data buffer/metadata for the current drawing task (instanced rendering).


compositor?

optional compositor?: 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?

optional sunLight?: DirectionalLight

Defined in: libs/scene/src/render/drawable.ts:159

Sun/directional light reference for passes that need it.


primaryDirectionalLight?

optional primaryDirectionalLight?: DirectionalLight

Defined in: libs/scene/src/render/drawable.ts:161

Primary directional light fallback when no explicit sun light is marked.


primaryTransmissionLight?

optional primaryTransmissionLight?: 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?

optional clusteredLight?: 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?

optional forceCullMode?: FaceMode

Defined in: libs/scene/src/render/drawable.ts:169

Force cull mode override for special passes (optional).


forceColorState?

optional forceColorState?: ColorState

Defined in: libs/scene/src/render/drawable.ts:171

Force color mask state override for special passes (optional).


SSR

readonly SSR: 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.

Released under the MIT License.