playcanvas / playcanvas/engine
Add support for rendering to Texture2DArray
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
Task: Add support for rendering to Texture2DArray
Description:
The current engine implementation supports rendering only to regular 2D textures and cube maps. Extend the render target system to support rendering to individual layers of texture arrays (Texture2DArray).
Requirements:
- Implement render target creation based on Texture2DArray, allowing output to a specific array layer.
- When binding the render target to framebuffer, use framebufferTextureLayer (WebGL2) to specify the target layer.
- When binding the render target to framebuffer, use depthOrArrayLayers (WebGPU) to specify the target layer.
- Support layer selection both at render target configuration time and dynamically during render passes (e.g., cyclic rendering across layers).
Here is a workaround that works great:
const device = this.device as pcx.WebglGraphicsDevice;
const gl = device.gl;
const rt = new pc.RenderTarget(...someOptions);
const glFrameBuffer = gl.createFramebuffer();
const glTexture = rt.colorBuffer.impl._glTexture;
const mipLevel = 0;
const textureIndex = 0;
rt.impl.suppliedColorFramebuffer = glFrameBuffer;
device.setFramebuffer(rt.impl.suppliedColorFramebuffer);
gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, glTexture, mipLevel, textureIndex);
gl.drawBuffers([gl.COLOR_ATTACHMENT0]);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the RenderTarget system and trace how render targets are created and bound during render passes. Compare the WebGL2 framebufferTextureLayer path and the WebGPU depthOrArrayLayers path, then verify that a layer can be configured initially and changed dynamically for cyclic rendering across Texture2DArray layers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100