From 44e7223547a97b8601616da8e8445f4671800cf0 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Mon, 3 Aug 2015 16:05:04 -0700 Subject: [PATCH] Fixing the skinning by simply reverting the change to the format for the inSkinIndex --- libraries/gpu/src/gpu/Format.h | 20 +++++++++++++++++++ libraries/gpu/src/gpu/GLBackendInput.cpp | 4 ++++ libraries/gpu/src/gpu/Inputs.slh | 16 +++++++-------- libraries/render-utils/src/skin_model.slv | 2 +- .../src/skin_model_normal_map.slv | 2 +- .../render-utils/src/skin_model_shadow.slv | 2 +- 6 files changed, 35 insertions(+), 11 deletions(-) diff --git a/libraries/gpu/src/gpu/Format.h b/libraries/gpu/src/gpu/Format.h index b710a44f39..8cd16e0be4 100644 --- a/libraries/gpu/src/gpu/Format.h +++ b/libraries/gpu/src/gpu/Format.h @@ -88,7 +88,26 @@ static const int TYPE_SIZE[NUM_TYPES] = { 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 enum Dimension { @@ -168,6 +187,7 @@ public: Type getType() const { return (Type)_type; } bool isNormalized() const { return (getType() >= NFLOAT); } + bool isInteger() const { return TYPE_IS_INTEGER[getType()]; } uint32 getSize() const { return DIMENSION_COUNT[_dimension] * TYPE_SIZE[_type]; } diff --git a/libraries/gpu/src/gpu/GLBackendInput.cpp b/libraries/gpu/src/gpu/GLBackendInput.cpp index eccd9dda49..2faffe1c6c 100755 --- a/libraries/gpu/src/gpu/GLBackendInput.cpp +++ b/libraries/gpu/src/gpu/GLBackendInput.cpp @@ -215,8 +215,12 @@ void GLBackend::updateInput() { GLuint stride = strides[bufferNum]; GLuint pointer = attrib._offset + offsets[bufferNum]; GLboolean isNormalized = attrib._element.isNormalized(); + glVertexAttribPointer(slot, count, type, isNormalized, stride, reinterpret_cast(pointer)); + + // TODO: Support properly the IAttrib version + (void) CHECK_GL_ERROR(); } } diff --git a/libraries/gpu/src/gpu/Inputs.slh b/libraries/gpu/src/gpu/Inputs.slh index 843d1059f2..8f90b6ebee 100644 --- a/libraries/gpu/src/gpu/Inputs.slh +++ b/libraries/gpu/src/gpu/Inputs.slh @@ -10,12 +10,12 @@ !> <@if not GPU_INPUTS_SLH@> <@def GPU_INPUTS_SLH@> -layout(location = 0) in vec4 inPosition; -layout(location = 1) in vec4 inNormal; -layout(location = 2) in vec4 inColor; -layout(location = 3) in vec4 inTexCoord0; -layout(location = 4) in vec4 inTangent; -layout(location = 5) in ivec4 inSkinClusterIndex; -layout(location = 6) in vec4 inSkinClusterWeight; -layout(location = 7) in vec4 inTexCoord1; +in vec4 inPosition; +in vec4 inNormal; +in vec4 inColor; +in vec4 inTexCoord0; +in vec4 inTangent; +in vec4 inSkinClusterIndex; +in vec4 inSkinClusterWeight; +in vec4 inTexCoord1; <@endif@> diff --git a/libraries/render-utils/src/skin_model.slv b/libraries/render-utils/src/skin_model.slv index 32fe92040d..53e68727fb 100755 --- a/libraries/render-utils/src/skin_model.slv +++ b/libraries/render-utils/src/skin_model.slv @@ -34,7 +34,7 @@ void main(void) { vec4 position = 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++) { - mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]]; + mat4 clusterMatrix = clusterMatrices[int(inSkinClusterIndex[i])]; float clusterWeight = inSkinClusterWeight[i]; position += clusterMatrix * inPosition * clusterWeight; interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight; diff --git a/libraries/render-utils/src/skin_model_normal_map.slv b/libraries/render-utils/src/skin_model_normal_map.slv index 0771117a3f..c7de8f4a36 100755 --- a/libraries/render-utils/src/skin_model_normal_map.slv +++ b/libraries/render-utils/src/skin_model_normal_map.slv @@ -36,7 +36,7 @@ void main(void) { vec4 interpolatedNormal = 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++) { - mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]]; + mat4 clusterMatrix = clusterMatrices[int(inSkinClusterIndex[i])]; float clusterWeight = inSkinClusterWeight[i]; position += clusterMatrix * inPosition * clusterWeight; interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight; diff --git a/libraries/render-utils/src/skin_model_shadow.slv b/libraries/render-utils/src/skin_model_shadow.slv index 727a23f861..6cb4da25f4 100755 --- a/libraries/render-utils/src/skin_model_shadow.slv +++ b/libraries/render-utils/src/skin_model_shadow.slv @@ -24,7 +24,7 @@ uniform mat4 clusterMatrices[MAX_CLUSTERS]; void main(void) { vec4 position = vec4(0.0, 0.0, 0.0, 0.0); for (int i = 0; i < INDICES_PER_VERTEX; i++) { - mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]]; + mat4 clusterMatrix = clusterMatrices[int(inSkinClusterIndex[i])]; float clusterWeight = inSkinClusterWeight[i]; position += clusterMatrix * inPosition * clusterWeight; }