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

Implement support for Uniform Buffers #4261

Open
mvaligursky opened this issue May 20, 2022 · 3 comments
Open

Implement support for Uniform Buffers #4261

mvaligursky opened this issue May 20, 2022 · 3 comments
Assignees
Labels
area: graphics Graphics related issue feature
Milestone

Comments

@mvaligursky
Copy link
Contributor

mvaligursky commented May 20, 2022

Uniform Buffer Objects let you specify a bunch of uniforms from a buffer. The advantages are:

  • You can manipulate all the uniforms in the buffer outside of WebGL / WebGPU
  • You can have different sets of uniform buffer objects.
  • Assign whole buffer with many uniforms with a single WebGL call

Also, WebGPU allows uniforms to only be set using uniform buffers.

Basic design:
UniformBufferFormat - describes the content of the buffer (similar to VertexFormat) - list of uniforms and their types and so on.
UniformBuffer - an actual buffer, storing uniforms in a format described by UniformBufferFormat

WebGPU specifically has API that connects multiple uniform buffers as well as other buffer objects (textures) into a binding, and all of those can be set on a device (assigned to a bind slot) by a single call. The engine will support this as a way of setting up textures and uniform buffers as well. Design:
BindGroupFormat - describes the format as an array of uniform buffers / textures.
BindGroup - an actual instance of the BindGroupFormat, attaching actual uniform buffers and textures into the bind group. This can then be set on device using a single call.

In general, the engine will use 3 sets of BindGroups:

  • view - uniform buffers / textures that are constant per layer rendering using a camera.
  • material - uniform buffers / textures that are constant per material
  • mesh - uniform buffers / textures that change per mesh (all that is not included in the previous two groups)
@willeastcott
Copy link
Contributor

I notice we have UniformBuffer class in the engine now. Can this be closed yet?

@mvaligursky
Copy link
Contributor Author

Not yet I think. We have Uniform Buffers, but their integration is limited to Scene and Mesh Uniform Buffers, and we still need to implement Material Uniform buffers.

Additionally, this is only WebGPU implementation, and we need WebGL2 implementation using Uniform Buffer Objects.

We could spin up separate tickets for this, but at the moment this covers all this work.

@mvaligursky mvaligursky added this to the Q3 2023 milestone Jan 25, 2023
@willeastcott willeastcott moved this from Todo to In Progress in PlayCanvas Roadmap Oct 3, 2023
@willeastcott willeastcott modified the milestones: Q3 2023, Q4 2023 Oct 3, 2023
@willeastcott willeastcott modified the milestones: Q4 2023, Q2 2024 Feb 11, 2024
@MatthewDZane
Copy link

Webgl2 Uniform Buffer Objects support would be great!!

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
Projects
Status: In Progress
Development

No branches or pull requests

4 participants