Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.49k stars 174 forks source link

[WebGL] Support for Uniform Buffer Objects #1365

Open QuantumCoderQC opened 2 years ago

QuantumCoderQC commented 2 years ago

Is your feature request related to a problem? Please describe. The number of uniforms that can be set are limited by the maximum available vertex uniform components. Using Uniform Buffer Objects overcome this limitation on devices that support it.

Describe the solution you'd like Provision to set UBOs.

Additional context In situations such as mesh skinning, large number of uniforms(bone transforms) has to be sent to the GPU. This number is limited by the maximum available vertex uniform components on that device. Introducing UBOs might overcome this limit on some platforms. An issue related to this from Armory3D.

RobDangerous commented 2 years ago

Hey, false marketing, as you know UBOs are also limited, just less so.

onelsonic commented 2 years ago

From our research this will open Kha to be used for complex skinning animation on top tier mobile which is not the case now. The current "vertex uniform" format is not really fit for the Adreno platform.

RobDangerous commented 2 years ago

Hu, top-tier mobile is still using OpenGL?

onelsonic commented 2 years ago

Yes life is tough on mobile

So you cannot animated properly on a 1000$ mobile when using Kha.

RobDangerous commented 2 years ago

Those 26% I think are not the 1000$ top tier phones. And hu, an extension for vertex-skinning? What's that? And webview is a different story all together of course. When those don't support webgl2 which was only very recently added on iOS, they can't even support UBOs.

RobDangerous commented 2 years ago

Aand webgl being a different story here will also be relevant for the implementation - therefore henceforth this issue right here will just be about WebGL, while a new issue over at the Kinc-repo will be about OpenGL: https://github.com/Kode/Kinc/issues/708

onelsonic commented 2 years ago

The idea is to be able to handle complex animation bones data in realtime 200+ bones. Current hardware limitations on Adreno plateforme is throwing errors as not enough uniforms are available when using standard uniforms, so we are trying to find another placeholder for this data. Uniform Buffer Objects seems to fit the requirements.

Although I hope the number of uniform buffer objects will be enough. On iOS they are supported natively now on webgl2 (24 Uniform Buffer Objects on a 4 years old iphone/ipad)
On latest android Adreno 600 series (84 Uniform Buffer Objects are available)

Yes most of those 26% are not the 1000$ top tier but many can't run vulkan due to OEM drivers or missing extensions even being the lastest flagship models. By extension I mean : VKEXT####### OpenGL ES GLEXT#######

When they don't support webgl2, well that are very old mobile devices then.

RobDangerous commented 2 years ago

iOS only added WebGL 2 support last year. That's not that long ago - basically every iOS device that's not on the latest OS doesn't support WebGL 2. What phones in particular are those that don't support Vulkan? And what extensions do you mean in particular? There are hundreds of EXT extensions and to support Vulkan you don't need to support any extensions. Also if this is about a specific project of yours - you can just add some extra code until this if fixed and fill the UBOs yourself. The shader-cross-compiler should just keep the buffer structs when compiling to glsl and then it's just, uhm, five GL calls or something along those lines to create and fill them.