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

WebGL Texture2d array #5754

Merged
merged 21 commits into from Nov 21, 2023
Merged

WebGL Texture2d array #5754

merged 21 commits into from Nov 21, 2023

Conversation

heretique
Copy link
Contributor

@heretique heretique commented Oct 13, 2023

Adds support for WebGL2 TEXTURE2D_ARRAY

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

This PR adds support for 2d texture arrays useful in a lot of scenarios but most commonly for terrain rendering.
It introduces a new uniform type UNIFORMTYPE_TEXTURE2D_ARRAY and sampler type sampler2DArray ca be used now inside the shaders.
There are also a few small additions to the options used when constructing a pc.Texture

[options.arrayLength] - The number of textures in a 2D texture array (not supported by WebGl1).
[options.levels]            - These gain an additional type Uint8Array[][]

The PR also adds a new simple example Texture Array that shows how a 2D Array texture can be created and used.
There is no WebGPU support for this at the moment.
The textures used are from https://polyhaven.com/ and are public domain (CCO license).

I'm pretty sure the PR is rough around the edges and I'm looking forward for PlayCanvas team's feedback.

@Maksims
Copy link
Contributor

Maksims commented Oct 17, 2023

Is there a new public API related to this PR?
If so, could you please write it in first post?

@heretique
Copy link
Contributor Author

@Maksims I updated the first post. I hope it is more clear now.
As a first PR to add support I believe this could be useful but it does have one big limitation, similar to the 3d textures you can only update the whole texture array.
It would be also useful to be able to update a single texture and it's mips.
That would used texSubImage3D and would be more in line with PRs like #5759 speeding up updates.

@mvaligursky
Copy link
Contributor

Related issue: #4265

@mvaligursky
Copy link
Contributor

Ideally Texture.lock would allow us to lock individual slice as well, but that would be done in a separate PR.

@heretique
Copy link
Contributor Author

Ideally Texture.lock would allow us to lock individual slice as well, but that would be done in a separate PR.

Yeah, totally agree there are a lot of cases where it would make sense to be able to upload individual slices. I will add a separate PR for that as well after this is merged.

@mvaligursky mvaligursky changed the title Texture2d array WebGL Texture2d array Nov 10, 2023
Copy link
Contributor

@mvaligursky mvaligursky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me. Any thoughts @willeastcott @slimbuck ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants