Skinned shaders were exceeding maximum amount of vertex uniforms on amd hardware.

-Changed the transform matrix uniform to a 3x4 matrix and packed translation into it to free up uniforms. (3x3 is converted to 3x4 internally, so we were needlessly eating 3*52 extra uniform slots. translationPalette might also have been treated as a vec4 internally too, wasting 52 more slots.)
-matrix3x4 requires opengl2.1 and newer, so added a new featuretable mask.
-Also added a featuretable mask to disable hardware skinning and deferred shading on hardware with less than 1024 vertex uniforms.
NOTE: On old old old amd hardware, evidently a 3x4 matrix might be upgraded to 4x4. I'm unsure, but I doubt such hardware has 1024+ uniform components available to begin with. 4x3 supposedly doesn't do this, but opengl is column-major, so this makes little sense.
This commit is contained in:
Shyotl
2014-05-17 03:31:45 -05:00
parent fdcf2eda5a
commit 67c8ac2b04
12 changed files with 98 additions and 40 deletions

View File

@@ -24,12 +24,9 @@
ATTRIBUTE vec4 weight4;
uniform mat3 matrixPalette[52];
uniform vec3 translationPalette[52];
uniform mat3x4 matrixPalette[52];
uniform float maxWeight;
mat4 getObjectSkinnedTransform()
{
int i;
@@ -47,22 +44,21 @@ mat4 getObjectSkinnedTransform()
int i3 = int(index.z);
int i4 = int(index.w);
mat3 mat = mat3(matrixPalette[i1])*w.x;
mat += mat3(matrixPalette[i2])*w.y;
mat += mat3(matrixPalette[i3])*w.z;
mat += mat3(matrixPalette[i4])*w.w;
mat3 mat = matrixPalette[i1]*w.x;
mat += matrixPalette[i2]*w.y;
mat += matrixPalette[i3]*w.z;
mat += matrixPalette[i4]*w.w;
vec3 trans = translationPalette[i1]*w.x;
trans += translationPalette[i2]*w.y;
trans += translationPalette[i3]*w.z;
trans += translationPalette[i4]*w.w;
vec3 trans = vec3(matrixPalette[i1][0].w,matrixPalette[i1][1].w,matrixPalette[i1][2].w)*w.x;
trans += vec3(matrixPalette[i2][0].w,matrixPalette[i2][1].w,matrixPalette[i2][2].w)*w.y;
trans += vec3(matrixPalette[i3][0].w,matrixPalette[i3][1].w,matrixPalette[i3][2].w)*w.z;
trans += vec3(matrixPalette[i4][0].w,matrixPalette[i4][1].w,matrixPalette[i4][2].w)*w.w;
mat4 ret;
ret[0] = vec4(mat[0].xyz, 0);
ret[1] = vec4(mat[1].xyz, 0);
ret[2] = vec4(mat[2].xyz, 0);
ret[0] = vec4(mat[0], 0);
ret[1] = vec4(mat[1], 0);
ret[2] = vec4(mat[2], 0);
ret[3] = vec4(trans, sum);
return ret;