Skip to content

Support for WebGPU #46

Closed
Closed

Description

@vorth

WebGPU is not baseline on major browsers yet, but Three.js WebGpuRenderer can (supposedly) fall back to WebGL if WebGPU is not supported. At some point we will want to switch to WebGPU. In particular, it opens up the possibility of using Three Shader Language for custom shaders, automatically generating GLSL or WGSL as appropriate.

Activity

  1. bigmistqke commented on Jun 5, 2026

    @bigmistqke
    Contributor

    WebGPU is supported now — landed in #53 (and ported to the Solid 2.x line in #56).

    Rather than depending on three/webgpu ourselves, the gl prop and useThree().gl were widened to a structural Renderer union (WebGLRenderer | WebGPURenderer | RendererLike). Any renderer matching the shape works — WebGPURenderer, the DOM renderers (SVGRenderer, CSS2DRenderer, CSS3DRenderer), or your own.

    Usage

    import { WebGPURenderer } from "three/webgpu"
    
    <Canvas gl={canvas => new WebGPURenderer({ canvas })}>
      {/* scene */}
    </Canvas>

    solid-three awaits renderer.init() automatically before the first frame, so the async WebGPU setup just works — no manual await needed. It also skips init() when hasInitialized() is already true, so a pre-initialized renderer is fine too. WebGL-only config (toneMapping, outputEncoding, the flat gl={{ ... }} object form) is guarded so it does not get applied to a non-WebGL renderer.

    Typing it project-wide

    By default gl is the open Renderer union. If your whole app is WebGPU, declare it once and the type narrows everywhere:

    // src/solid-three.d.ts
    import type { WebGPURenderer } from "three/webgpu"
    
    declare module "solid-three" {
      interface Register {
        renderer: WebGPURenderer
      }
    }

    After that, useThree().gl.init() is typed with no narrowing, and passing a WebGLRenderer to <Canvas gl> becomes a type error.

    Re: TSL — since you bring your own WebGPURenderer instance, Three Shader Language works exactly as it does in plain three; nothing extra on the solid-three side. Docs are in the README under Custom renderers.

    Closing as resolved by #53 / #56 — shout if anything is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions