-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Skeleton2D not supported on devices with GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS == 0, should replace texture2DLod by software logic (like for 3D) [GLES2] #35143
Comments
The error is surprising as it happens in the vertex shader, where Might be a driver bug? I'll see if I can find any reference to |
The funny thing is that the Mali-400 MP I have has support for |
See https://stackoverflow.com/a/14503063 - my device has So we need to check that and disable/work around the relevant code path. It's probably not worth to spend too much effort for such old devices, so I'd suggest to just add a validation, print an error if texture access in vertex shader was requested by the user and disable relevant code. |
Looks like we already check for this capability in 3D, and we have godot/drivers/gles2/rasterizer_storage_gles2.cpp Lines 5976 to 5978 in bab91bd
The same logic needs to be ported to I started looking into it for diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl
index afce403a9f..76b0f73ce2 100644
--- a/drivers/gles2/shaders/canvas.glsl
+++ b/drivers/gles2/shaders/canvas.glsl
@@ -22,9 +22,25 @@ attribute vec4 color_attrib; // attrib:3
attribute vec2 uv_attrib; // attrib:4
#ifdef USE_SKELETON
+
+#ifdef USE_SKELETON_SOFTWARE
+
+attribute highp vec4 bone_transform_row_0; // attrib:13
+attribute highp vec4 bone_transform_row_1; // attrib:14
+
+#else
+
attribute highp vec4 bone_indices; // attrib:6
attribute highp vec4 bone_weights; // attrib:7
-#endif
+
+uniform highp sampler2D skeleton_texture; // texunit:-3
+uniform highp ivec2 skeleton_texture_size;
+uniform highp mat4 skeleton_transform;
+uniform highp mat4 skeleton_transform_inverse;
+
+#endif // USE_SKELETON_SOFTWARE
+
+#endif // USE_SKELETON
#ifdef USE_INSTANCING
@@ -37,14 +53,7 @@ attribute highp vec4 instance_color; //attrib:11
attribute highp vec4 instance_custom_data; //attrib:12
#endif
-#endif
-
-#ifdef USE_SKELETON
-uniform highp sampler2D skeleton_texture; // texunit:-3
-uniform highp ivec2 skeleton_texture_size;
-uniform highp mat4 skeleton_transform;
-uniform highp mat4 skeleton_transform_inverse;
-#endif
+#endif // USE_INSTANCING
varying vec2 uv_interp;
varying vec4 color_interp;
@@ -178,9 +187,18 @@ VERTEX_SHADER_CODE
#ifdef USE_SKELETON
+ highp mat4 bone_matrix = mat4(0.0);
+
+#ifdef USE_SKELETON_SOFTWARE
+ // passing the transform as attributes
+ bone_matrix[0] = vec4(bone_matrix_row_0.x, bone_matrix_row_1.x, 0.0, 0.0);
+ bone_matrix[1] = vec4(bone_matrix_row_0.y, bone_matrix_row_1.y, 0.0, 0.0);
+ bone_matrix[2] = vec4(bone_matrix_row_0.z, bone_matrix_row_1.z, 1.0, 0.0);
+ bone_matrix[3] = vec4(bone_matrix_row_0.w, bone_matrix_row_1.w, 0.0, 1.0);
+
+#else
// look up transform from the "pose texture"
if (bone_weights != vec4(0.0)) {
-
highp mat4 bone_transform = mat4(0.0);
for (int i = 0; i < 4; i++) {
@@ -195,12 +213,14 @@ VERTEX_SHADER_CODE
bone_transform += b * bone_weights[i];
}
- mat4 bone_matrix = skeleton_transform * transpose(bone_transform) * skeleton_transform_inverse;
-
- outvec = bone_matrix * outvec;
+ bone_matrix = skeleton_transform * transpose(bone_transform) * skeleton_transform_inverse;
}
-#endif
+#endif // USE_SKELETON_SOFTWARE
+
+ outvec = bone_matrix * outvec;
+
+#endif // USE_SKELETON
uv_interp = uv;
gl_Position = projection_matrix * outvec;
diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl
index 63eee4eb87..901c86cbfc 100644
--- a/drivers/gles2/shaders/scene.glsl
+++ b/drivers/gles2/shaders/scene.glsl
@@ -59,9 +59,9 @@ attribute highp vec4 bone_weights; // attrib:7
uniform highp sampler2D bone_transforms; // texunit:-1
uniform ivec2 skeleton_texture_size;
-#endif
+#endif // USE_SKELETON_SOFTWARE
-#endif
+#endif // USE_SKELETON
#ifdef USE_INSTANCING
@@ -379,7 +379,6 @@ void main() {
#ifdef USE_SKELETON_SOFTWARE
// passing the transform as attributes
-
bone_transform[0] = vec4(bone_transform_row_0.x, bone_transform_row_1.x, bone_transform_row_2.x, 0.0);
bone_transform[1] = vec4(bone_transform_row_0.y, bone_transform_row_1.y, bone_transform_row_2.y, 0.0);
bone_transform[2] = vec4(bone_transform_row_0.z, bone_transform_row_1.z, bone_transform_row_2.z, 0.0);
@@ -387,8 +386,7 @@ void main() {
#else
// look up transform from the "pose texture"
- {
-
+ if (bone_weights != vec4(0.0)) {
for (int i = 0; i < 4; i++) {
ivec2 tex_ofs = ivec2(int(bone_ids[i]) * 3, 0);
@@ -402,11 +400,11 @@ void main() {
}
}
-#endif
+#endif // USE_SKELETON_SOFTWARE
world_matrix = world_matrix * bone_transform;
-#endif
+#endif // USE_SKELETON
#ifdef USE_INSTANCING
vec4 instance_custom = instance_custom_data; |
Can anyone still reproduce this bug in Godot 3.2.3 or any later release? |
I haven't tested but I assume this might still be reproducible, it would probably need software skinning as implemented by @pouleyKetchoupp in #40313 extended to 2D. But it's probably not worth the hassle at this point and the situation will be different with Godot 4.0 and Vulkan/GLES3, so I think we can close this issue as WONTFIX. Contributors still welcome if anyone wants to tackle it. |
Godot version:
3.2 master (bab91bd)
OS/device including version:
Samsung Galaxy S3, Mali 400: http://opengles.gpuinfo.org/displayreport.php?id=3407
Old GLES2-only device, running LineageOS 14 (Android 7.1.2).
Issue description:
Follow-up to GLES3 issue in similar configuration (#27919).
On the above described device, the Polygon2D character with textures and assigned Skeleton2D fails to render completely. It works OK on a newer device (Xiaomi Pocophone F1) with GLES2.
adb logcat
points to a shader compilation error due to missing support fortextureLod
:Full error log with for some reason two shader dumps with slightly different amount of errors (but they seem to be the same):
Steps to reproduce:
textureLod
in GLES2Minimal reproduction project:
SkeletonBug.zip (from #27919)
The text was updated successfully, but these errors were encountered: