Adapt reflection and screenshot components to WebGPURenderer#5848
Open
vincentfretin wants to merge 1 commit into
Open
Adapt reflection and screenshot components to WebGPURenderer#5848vincentfretin wants to merge 1 commit into
vincentfretin wants to merge 1 commit into
Conversation
- Use CubeRenderTarget with WebGPURenderer (WebGLCubeRenderTarget is not exported by the three.webgpu.js build), selected at runtime like the renderer implementation in a-scene. This also removes a webpack warning when building with WEBGPU=true. - WebGPURenderer does not support RawShaderMaterial; the equirectangular cubemap-to-equirect projection is implemented with TSL nodes when THREE.TSL is available. - WebGPURenderer only supports asynchronous pixels read back, use readRenderTargetPixelsAsync when readRenderTargetPixels is not available. getCanvas() returns a Promise resolving to the canvas with WebGPURenderer; it still returns the canvas synchronously with WebGLRenderer. - Use RGBAFormat instead of RGBFormat for the cube render target; RGBFormat is not color-renderable with the WebGL 2 backend of WebGPURenderer. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Testing help wanted: on this machine I could only verify gh pr checkout 5848
# or without the GitHub CLI:
# git fetch https://github.com/vincentfretin/aframe.git webgpu-reflection-screenshot && git checkout FETCH_HEAD
npm ci
npm run dist
npm run start:webgpuThen open AFRAME.scenes[0].renderer.backend.isWebGPUBackend // should be trueThings to verify:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the
reflectionandscreenshotcomponents work withWebGPURenderer(three.webgpu.js build, see #5749 for context).Changes
WebGLCubeRenderTargetis not exported by the three.webgpu.js build, which usesCubeRenderTargetinstead. Both components now select the class at runtime with the same trick a-scene uses to select the renderer implementation, so webpack can't statically resolve the export. This also removes theWebGLCubeRenderTargetwebpack warning when building withWEBGPU=true.THREE.CubeCameraworks unchanged with either target.WebGPURendererdoes not supportRawShaderMaterial/ShaderMaterial(not in its node library). WhenTHREE.TSLis available, the cubemap-to-equirectangular projection is built as aMeshBasicNodeMaterialwith TSL nodes implementing the same longitude/latitude math as the GLSL shaders; the cube texture is swapped per capture through the texture node's.value.WebGPURendereronly supports asynchronous read back.renderCaptureusesreadRenderTargetPixelsAsyncwhenreadRenderTargetPixelsis not available.getCanvas()still returns the canvas synchronously withWebGLRenderer(no breaking change) and returns aPromiseresolving to the canvas withWebGPURenderer(documented inscreenshot.md).capture()works on both.RGBFormat, which is not color-renderable with the WebGL 2 backend ofWebGPURenderer(incomplete framebuffer, black capture). Switched toRGBAFormat; the projection outputs alpha 1 and the readback path already assumed 4 bytes per pixel.Verification
Tested with a scene with distinct sky/box/ground colors on both builds (
npm run devandnpm run start:webgpu) driving headless Chrome, probing pixels of the resulting canvas:WebGLRendererand onWebGPURenderer(WebGL 2 fallback backend — no WebGPU adapters on Linux Chrome).reflectioncomponent sets a live cube texture asscene.environmenton both renderers without errors.Note: the actual WebGPU backend readback couldn't be tested on Linux; worth a quick check of equirect orientation in a desktop Chrome with WebGPU support.
ar-hit-test.jsuses the samereadRenderTargetPixelspattern but is WebXR-only, so it's left untouched until WebXR support lands forWebGPURenderer.🤖 Generated with Claude Code