Merge pull request #5488 from samcake/punk

Fixing the skinning by simply reverting the change to the format for the inSkinIndex
This commit is contained in:
Brad Davis 2015-08-03 16:17:05 -07:00
commit 3da2a1c64c
6 changed files with 35 additions and 11 deletions

View file

@ -88,7 +88,26 @@ static const int TYPE_SIZE[NUM_TYPES] = {
1, 1,
1 1
}; };
// Array answering the question Does this type is integer or not
static const bool TYPE_IS_INTEGER[NUM_TYPES] = {
false,
true,
true,
false,
true,
true,
true,
true,
false,
true,
true,
false,
true,
true,
true,
true
};
// Dimension of an Element // Dimension of an Element
enum Dimension { enum Dimension {
@ -168,6 +187,7 @@ public:
Type getType() const { return (Type)_type; } Type getType() const { return (Type)_type; }
bool isNormalized() const { return (getType() >= NFLOAT); } bool isNormalized() const { return (getType() >= NFLOAT); }
bool isInteger() const { return TYPE_IS_INTEGER[getType()]; }
uint32 getSize() const { return DIMENSION_COUNT[_dimension] * TYPE_SIZE[_type]; } uint32 getSize() const { return DIMENSION_COUNT[_dimension] * TYPE_SIZE[_type]; }

View file

@ -215,8 +215,12 @@ void GLBackend::updateInput() {
GLuint stride = strides[bufferNum]; GLuint stride = strides[bufferNum];
GLuint pointer = attrib._offset + offsets[bufferNum]; GLuint pointer = attrib._offset + offsets[bufferNum];
GLboolean isNormalized = attrib._element.isNormalized(); GLboolean isNormalized = attrib._element.isNormalized();
glVertexAttribPointer(slot, count, type, isNormalized, stride, glVertexAttribPointer(slot, count, type, isNormalized, stride,
reinterpret_cast<GLvoid*>(pointer)); reinterpret_cast<GLvoid*>(pointer));
// TODO: Support properly the IAttrib version
(void) CHECK_GL_ERROR(); (void) CHECK_GL_ERROR();
} }
} }

View file

@ -10,12 +10,12 @@
!> !>
<@if not GPU_INPUTS_SLH@> <@if not GPU_INPUTS_SLH@>
<@def GPU_INPUTS_SLH@> <@def GPU_INPUTS_SLH@>
layout(location = 0) in vec4 inPosition; in vec4 inPosition;
layout(location = 1) in vec4 inNormal; in vec4 inNormal;
layout(location = 2) in vec4 inColor; in vec4 inColor;
layout(location = 3) in vec4 inTexCoord0; in vec4 inTexCoord0;
layout(location = 4) in vec4 inTangent; in vec4 inTangent;
layout(location = 5) in ivec4 inSkinClusterIndex; in vec4 inSkinClusterIndex;
layout(location = 6) in vec4 inSkinClusterWeight; in vec4 inSkinClusterWeight;
layout(location = 7) in vec4 inTexCoord1; in vec4 inTexCoord1;
<@endif@> <@endif@>

View file

@ -34,7 +34,7 @@ void main(void) {
vec4 position = vec4(0.0, 0.0, 0.0, 0.0); vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0); vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < INDICES_PER_VERTEX; i++) { for (int i = 0; i < INDICES_PER_VERTEX; i++) {
mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]]; mat4 clusterMatrix = clusterMatrices[int(inSkinClusterIndex[i])];
float clusterWeight = inSkinClusterWeight[i]; float clusterWeight = inSkinClusterWeight[i];
position += clusterMatrix * inPosition * clusterWeight; position += clusterMatrix * inPosition * clusterWeight;
interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight; interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight;

View file

@ -36,7 +36,7 @@ void main(void) {
vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0); vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
vec4 interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0); vec4 interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < INDICES_PER_VERTEX; i++) { for (int i = 0; i < INDICES_PER_VERTEX; i++) {
mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]]; mat4 clusterMatrix = clusterMatrices[int(inSkinClusterIndex[i])];
float clusterWeight = inSkinClusterWeight[i]; float clusterWeight = inSkinClusterWeight[i];
position += clusterMatrix * inPosition * clusterWeight; position += clusterMatrix * inPosition * clusterWeight;
interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight; interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight;

View file

@ -24,7 +24,7 @@ uniform mat4 clusterMatrices[MAX_CLUSTERS];
void main(void) { void main(void) {
vec4 position = vec4(0.0, 0.0, 0.0, 0.0); vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < INDICES_PER_VERTEX; i++) { for (int i = 0; i < INDICES_PER_VERTEX; i++) {
mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]]; mat4 clusterMatrix = clusterMatrices[int(inSkinClusterIndex[i])];
float clusterWeight = inSkinClusterWeight[i]; float clusterWeight = inSkinClusterWeight[i];
position += clusterMatrix * inPosition * clusterWeight; position += clusterMatrix * inPosition * clusterWeight;
} }