playcanvas / playcanvas/engine

Add support for rendering to Texture2DArray

Open
#8,327 1 comment 3 reactions 0 assignees View on GitHub

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:

  1. Implement render target creation based on Texture2DArray, allowing output to a specific array layer.
  2. When binding the render target to framebuffer, use framebufferTextureLayer (WebGL2) to specify the target layer.
  3. When binding the render target to framebuffer, use depthOrArrayLayers (WebGPU) to specify the target layer.
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.