-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve skinning shader #183
Comments
In addition, for this model, the mesh only has two joints, but the vertex shader is created for four. Given our goal of performance, we really need to generate a tighter shader that only weights the joint matrices used. |
Yep, I totally agree. I usually make this optimization indeed but as an option because in some cases you want to avoid switching shaders to many times too, so I think there is a whole topic on shader optimizations that I will be happy to tackle once we are feature complete. |
This is more than optimization. Depending on how an engine is designed, it may try to set all active uniforms, but in this case, the glTF file doesn't provide 60 matrices. |
Also, the skinning shader generates these varyings which are not used in the fragment shader: varying vec4 v_joint;
varying vec4 v_weight; |
Fixed in v0.6-fixes |
now shaders just contain the needed number of matrices to match the number of bones. It is still needed to split meshes to comply with a maximum number of uniform. |
Following up here #283 |
👍 |
The shader generated for skinning declares
uniform mat4 u_jointMat[60];
, which is going to hurt performance because many (all?) WebGL implementations will not optimize out the unused array elements. CPU overhead aside, using this much memory/registers will limit the number of shaders that can run in parallel.We should explicitly declare the upper-bound based on the number of joints used.
Complete shader:
Use the same model as #182 for testing.
The text was updated successfully, but these errors were encountered: