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

[3.x] GLES2: Make GPU skinning more consistent with GLES3 #80652

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 38 additions & 11 deletions drivers/gles2/shaders/scene.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -433,17 +433,44 @@ void main() {
#else
// look up transform from the "pose texture"
{
for (int i = 0; i < 4; i++) {
ivec2 tex_ofs = ivec2(int(bone_ids[i]) * 3, 0);

highp mat4 b = mat4(
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs + ivec2(0, 0)),
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs + ivec2(1, 0)),
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs + ivec2(2, 0)),
vec4(0.0, 0.0, 0.0, 1.0));

bone_transform += transpose(b) * bone_weights[i];
}
ivec4 bone_indicesi = ivec4(bone_ids); // cast to signed int

ivec2 tex_ofs = ivec2(bone_indicesi.x * 3, 0);
bone_transform = mat4(
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs),
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs + ivec2(1, 0)),
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs + ivec2(2, 0)),
vec4(0.0, 0.0, 0.0, 1.0)) *
bone_weights.x;

tex_ofs = ivec2(bone_indicesi.y * 3, 0);

bone_transform += mat4(
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs),
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs + ivec2(1, 0)),
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs + ivec2(2, 0)),
vec4(0.0, 0.0, 0.0, 1.0)) *
bone_weights.y;

tex_ofs = ivec2(bone_indicesi.z * 3, 0);

bone_transform += mat4(
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs),
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs + ivec2(1, 0)),
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs + ivec2(2, 0)),
vec4(0.0, 0.0, 0.0, 1.0)) *
bone_weights.z;

tex_ofs = ivec2(bone_indicesi.w * 3, 0);

bone_transform += mat4(
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs),
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs + ivec2(1, 0)),
texel2DFetch(bone_transforms, skeleton_texture_size, tex_ofs + ivec2(2, 0)),
vec4(0.0, 0.0, 0.0, 1.0)) *
bone_weights.w;

bone_transform = transpose(bone_transform);
}

#endif
Expand Down