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

fix: Remove signed blend indices due to dropping OpenGL ES 2 support #2323

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

Basewq
Copy link
Contributor

@Basewq Basewq commented Jun 12, 2024

PR Details

Primary aim is to fix TransformationSkinning.sdsl shader where skinning wasn't working on Android, due to mismatched data type being passed from app to shader. Due to dropping OpenGL ES 2, blend indices can now just behave like non-ES 2 versions (ie. just use uint data type, instead of using float).

Related Issue

Fixes #2284 where the background info/problem arose from.

Here's my understanding of the original intention/code:
OpenGL ES 2 did not support passing int/uint data types, so needed a workaround to use float instead.

#if STRIDE_GRAPHICS_API_OPENGLES
stage stream float4 BlendIndices : BLENDINDICES;
//stage stream int4 BlendIndices : BLENDINDICES;
#else
stage stream uint4 BlendIndices : BLENDINDICES;
#endif

As seen in this code (and the comments I removed from the TransformationSkinning.sdsl file), the workaround for ES 2 was supposed to be to use float4.

However, it turns out the importer only passed signed or unsigned integer types:

var controlPointIndices16 = (AllowUnsignedBlendIndices && totalClusterCount > 256) || (!AllowUnsignedBlendIndices && totalClusterCount > 128);
if (vertexIndexToBoneIdWeight.Count > 0)
{
if (controlPointIndices16)
{
if (AllowUnsignedBlendIndices)
{
vertexElements.Add(new VertexElement("BLENDINDICES", 0, PixelFormat.R16G16B16A16_UInt, vertexStride));
vertexStride += sizeof(ushort) * 4;
}
else
{
vertexElements.Add(new VertexElement("BLENDINDICES", 0, PixelFormat.R16G16B16A16_SInt, vertexStride));
vertexStride += sizeof(short) * 4;
}
}
else
{
if (AllowUnsignedBlendIndices)
{
vertexElements.Add(new VertexElement("BLENDINDICES", 0, PixelFormat.R8G8B8A8_UInt, vertexStride));
vertexStride += sizeof(byte) * 4;
}
else
{
vertexElements.Add(new VertexElement("BLENDINDICES", 0, PixelFormat.R8G8B8A8_SInt, vertexStride));
vertexStride += sizeof(sbyte) * 4;
}
}
}

This was still incorrect and should have been passing a float type.
Side note: even though this file is the new importer, this bug goes all the way back to the original importer.

Anyway, OpenGL ES3+ now supports int/uint data types, so the above no longer needs a workaround.
I have tested this on an Android project and the model is skinned properly now.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

…pport, and fix model skinning on platforms using OpenGL ES (ie. Android and iOS)
@Eideren Eideren merged commit e678fd2 into stride3d:master Jun 18, 2024
13 checks passed
@Eideren Eideren changed the title Remove signed blend indices due to dropping OpenGL ES 2 support fix: Remove signed blend indices due to dropping OpenGL ES 2 support Jun 18, 2024
@Basewq Basewq deleted the android_skinning_fix branch June 25, 2024 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potential skin/bone animation bug
2 participants