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

    Class WebGPURenderer

    Modern WebGPU implementation with dynamic vertex updates and memory management.

    Hierarchy (View Summary)

    Index
    _activeCubeFace: number = 0
    _adapter: GPUAdapter | undefined = undefined
    _blackCubeTexView: GPUTextureView
    _clearColor: Color = ...

    The clear color of the renderer.

    _cubeTextureViewCache: Map<
        CubeTexture,
        { texture: GPUTexture; view: GPUTextureView },
    > = ...
    _defaultBrdfTexView: GPUTextureView
    _defaultCubeTexView: GPUTextureView
    _dummyBufferSize: number = 0
    _dummyNormalBuffer: GPUBuffer
    _dummyTangentBuffer: GPUBuffer
    _dummyUvBuffer: GPUBuffer
    _flatNormalTexView: GPUTextureView
    _frameCount: number = 0
    _geoCache: Map<GeometryDataInterface, WebGPUGeoCache> = ...
    _gpuInstanceBuffers: WeakMap<InstancedMesh, GPUBuffer> = ...
    _gpuInstanceDataBuffers: WeakMap<InstancedMesh, GPUBuffer> = ...
    _lightData: LightDataInterface = ...

    Cached light data to avoid GC pressure.

    _materialBGLCache: Map<string, GPUBindGroupLayout> = ...
    _materialBindGroups: Map<string, { bg: GPUBindGroup; resources: unknown[] }> = ...
    _objectUniformBuffers: Map<
        string,
        { buffer: GPUBuffer; lastFrame: number; objBg?: GPUBindGroup },
    > = ...
    _opaqueTextures: WeakMap<
        object,
        { height: number; tex: GPUTexture; view: GPUTextureView; width: number },
    > = ...
    _passes: RenderPass[] = []
    _pipelines: Map<string, WebGPUPipelineCache> = ...
    _quality: QualityConfig = ...

    Global quality settings.

    _renderTargetCubeTextures: Map<
        RenderTargetCube,
        {
            cubeView: GPUTextureView;
            depth?: GPUTexture;
            depthView?: GPUTextureView;
            faceViews: GPUTextureView[];
            tex: GPUTexture;
        },
    > = ...
    _renderTargetTextures: Map<
        RenderTarget,
        {
            depth?: GPUTexture;
            depthView?: GPUTextureView;
            tex: GPUTexture;
            view: GPUTextureView;
        },
    > = ...
    _samplerCache: Map<string, GPUSampler> = ...
    _scratchAreaLightData: Float32Array<ArrayBuffer> = ...
    _scratchColorArray: Float32Array<ArrayBuffer> = ...
    _scratchModelMatrix: Float32Array<ArrayBuffer> = ...
    _scratchObjBufferData: Float32Array<ArrayBuffer> = ...
    _scratchPointLightData: Float32Array<ArrayBuffer> = ...
    _scratchSpotLightData: Float32Array<ArrayBuffer> = ...
    _scratchUniformValues: Record<string, unknown> = {}
    _screenOpaqueTexture?: {
        height: number;
        tex: GPUTexture;
        view: GPUTextureView;
        width: number;
    }
    _shaderModules: Map<string, GPUShaderModule> = ...
    _shadowSampler: GPUSampler
    _textureViewCache: Map<Texture, { texture: GPUTexture; view: GPUTextureView }> = ...
    postProcessing: PostProcessingGroup = ...

    The global post processing volume/group.

    type: RendererType = RendererType.WEB_GPU

    The type of the renderer.

    • get defaultDirShadowTextureView(): GPUTextureView

      Read by the fragment shader's global bind group; reassigned once by CascadedShadowPassGPU when a real cascaded shadow map first exists.

      Returns GPUTextureView

    • set defaultDirShadowTextureView(view: GPUTextureView): void

      Parameters

      • view: GPUTextureView

      Returns void

    • get defaultSpotShadowTextureView(): GPUTextureView

      Read by the fragment shader's global bind group; reassigned once by SpotShadowPassGPU when a real spot shadow map first exists.

      Returns GPUTextureView

    • set defaultSpotShadowTextureView(view: GPUTextureView): void

      Parameters

      • view: GPUTextureView

      Returns void

    • get globalBindGroup(): GPUBindGroup

      Rebuilt once (not per-frame) by a shadow pass, the first time a real shadow map for that light type exists -- see CascadedShadowPassGPU/SpotShadowPassGPU.

      Returns GPUBindGroup

    • set globalBindGroup(bindGroup: GPUBindGroup): void

      Parameters

      • bindGroup: GPUBindGroup

      Returns void

    • get gpuCanvasContext(): GPUCanvasContext

      Satisfies RenderPass-consuming passes, which have no other way to reach this.

      Returns GPUCanvasContext

    • Builds the material bind group layout for shaderId, containing only the texture bindings that material actually declares (plus normalMap/envMap/emissiveMap, which the shared PBR lighting chunk references regardless of what an individual material's own layout declares). A layout with every possible material texture bound at once (diffuse, normal, specular, terrain x4, metallic, roughness, env, emissive, alpha, opaque, reflection, opaqueDepth = 15, plus the 5 IBL/shadow textures in the global bind group = 20) exceeds WebGPU's guaranteed per-stage sampled-texture minimum of 16 on any device that doesn't happen to allow more.

      Parameters

      • shaderId: string
      • flags: string[]

      Returns GPUBindGroupLayout

    • Parameters

      • objBufferData: { buffer: GPUBuffer; objBg?: GPUBindGroup }
      • layout: GPUBindGroupLayout

      Returns GPUBindGroup

    • Parameters

      • shaderId: string
      • isInstanced: boolean = false
      • flags: string[] = []

      Returns GPUShaderModule

    • Parameters

      • rp: GPURenderPassEncoder
      • batch: RenderBatch
      • OptionalvMat: Float32Array<ArrayBufferLike>

      Returns void

    • Parameters

      • rp: GPURenderPassEncoder
      • objects: Object3D[]
      • isInstanced: boolean
      • matUuid: string
      • manifest: RenderManifest
      • OptionalvMat: Float32Array<ArrayBufferLike>
      • topology: GPUPrimitiveTopology = Topology.DEFAULT
      • OptionalwireframeMode: "structural" | "triangles"

      Returns void

    • Renders a scene.

      Parameters

      • scene: Scene
      • vp: Float32Array
      • camPos: Vector3D = Vector3D.ZERO
      • OptionalvMat: Float32Array<ArrayBufferLike>
      • near: number = 0.1
      • far: number = 1000
      • OptionalprojMatrix: Float32Array<ArrayBufferLike>

      Returns void