Small World Engine API Reference - v0.76.20
    Preparing search index...

    Class WebGL2Renderer

    WebGL 2.0 implementation of the renderer.

    Hierarchy (View Summary)

    Index
    _activeCubeFace: number = 0
    _activeRenderTarget: RenderTarget | RenderTargetCube | null = null
    _bloomPassGL: BloomPassGL | undefined = undefined
    _clearColor: Color = ...

    The clear color of the renderer.

    _frameFar: number = 1000
    _frameNear: number = 0.1

    This frame's camera near/far and raw projection matrix, stashed here so flushPostProcess() (called later, from a pass with no camera parameters of its own) can hand them to HBAO for reconstructing view-space position from the opaque depth buffer. _frameProjMatrix is also handed to WebGLRenderPass.execute() as an explicit parameter every frame (see below) for WebGLClusterCullPass, rather than being a public field passes reach for directly.

    _frameProjMatrix: Float32Array<ArrayBufferLike> | undefined = undefined
    _hbaoPassGL: AOPassGL | undefined = undefined
    _hdrFbo: WebGL2FrameBuffer | undefined = undefined
    _lightData: LightDataInterface = ...

    Cached light data to avoid GC pressure.

    _motionTrailPassGL: HistoryBlendPassGL | undefined = undefined
    _passes: WebGLRenderPass[] = []
    _postPassGL: PostProcessPassGL | undefined = undefined
    _quality: QualityConfig = ...

    Global quality settings.

    _taaPassGL: HistoryBlendPassGL | undefined = undefined
    defaultCubeTexture: WebGLTexture
    defaultNormalMap: WebGLTexture
    defaultSpecularMap: WebGLTexture
    defaultTexture: WebGLTexture
    gl: WebGL2RenderingContext
    postProcessing: PostProcessingGroup = ...

    The global post processing volume/group.

    type: RendererType = RendererType.WEB_GL2

    The type of the renderer.

    • get webglContext(): WebGLRenderingContext | WebGL2RenderingContext

      Returns WebGLRenderingContext | WebGL2RenderingContext

    • Captures the opaque depth buffer into a sampleable DEPTH24_STENCIL8 texture, for underwater/refraction depth-fade effects (e.g. OpenWaterMaterial). Only possible while an HDR FBO is active: _hdrFbo's depth/stencil renderbuffer has a known, fixed format (DEPTH24_STENCIL8), which blitFramebuffer requires to match the capture texture's format exactly. Without post-processing (rendering straight to the default framebuffer), the actual depth/stencil format is implementation-defined, so capture is skipped -- water materials fall back to their non-depth (Fresnel-based) blending in that case.

      Returns void

    • Renders a scene.

      Parameters

      • scene: Scene
      • vp: Float32Array
      • camPos: Vector3D = Vector3D.ZERO
      • OptionalvMat: Float32Array<ArrayBufferLike>
      • Optionalnear: number
      • Optionalfar: number
      • OptionalprojMatrix: Float32Array<ArrayBufferLike>

      Returns void

    • Stages the clustered light culling grid metadata into the (not-yet-uploaded) global UBO -- see docs/adr/0007-clustered-lighting-webgl2-webgpu-only.md. Actual GPU upload happens via updateGlobalUBO()'s trailing _globalUBO.update(), called right after this in the same frame (WebGLClusterCullPass runs before WebGLShadowPass in _passes).

      Parameters

      • tileSizePx: [number, number]

        Screen-space tile size in pixels, [width, height].

      Returns void