Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webglmrts by default #22089

Closed
wants to merge 4 commits into from
Closed

webglmrts by default #22089

wants to merge 4 commits into from

Conversation

mbredif
Copy link
Contributor

@mbredif mbredif commented Jul 5, 2021

Related issue: #21930

This PR shows that, with very hardly no API changes, a refactoring may lift many current (multiple)rendertarget limitations.

Description
Because of the current design, orthogonal features are currently incompatible :

  • MRT is only available for 2D textures (targeting a cube, 2Darray and 3D texture is limited to a single texture)
  • RenderTarget.depthTexture must be DepthTextures, and are thus limited to 2D textures (rather than cube or 2Darray)
  • Many places do not provide a systematic treatment of the 4 texture cases (2D, cube, 3D, 2Darray) : eg generateMipmaps only work on 2D and cube textures.

Proposal

  • Deprecate WebGLMultipleRenderTargets, and have WebGLRenderTargetDepth handle MRTs by default. For backward compability, install a getter/setter from texture to textures[0]
  • DepthTexture is no longer needed, it may be kept to instantiate with sensible defaults a 2D depth texture. However any Texture with format set to DepthFormat or DepthStencilFormat may be used as a depth texture (except 3D textures, as this is forbidden by the spec).
  • Refactor code to enable mixing render target depth texture and color textures with different types. Currently all attached non-2D textures write to the same layer/cubeface and mipmap level specified in setRenderTarget.

Limitations
the code paths with cube texture and/or cube rendertarget has not been extensively tested. I am not sure whether it makes sense to mix cube texture targets with, 2D, 3D layer and 2D array layer. Maybe it does, considering it as if it were a 2D array with 6 layers.

@mbredif
Copy link
Contributor Author

mbredif commented Jul 6, 2021

Rendering depth and/or color(s) to a CubeTexture in WebGLCubeRenderTarget.depthTexture should now work (see the webgl_materials_cubemap_dynamic example).
I am looking for feedback in terms of use cases (does it work for your use cases ?) and design/coding (would it be possible to merge such a refactoring ?).

@LeviPesin
Copy link
Contributor

@mbredif Can you please update the PR and remove build files from it?

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 27, 2024

In the meanwhile, #26427 has been merged which means WebGLMultipleRenderTargets is gone and MRT is integrated int the RenderTarget class with a new count option.

Missing features like MRT support for 3D textures can be investigated/implemented separately in step-by-step fashion.

I'm afraid too many changes were packed into this PR which made it too complex to review. Sorry for not providing this feedback earlier.

@Mugen87 Mugen87 closed this Feb 27, 2024
@mbredif
Copy link
Contributor Author

mbredif commented Feb 29, 2024

I understand. I am glad #26427 was merged. I'll try to rebase this PR and cut it down in more manageable PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants