PDA

View Full Version : Declaring vertex attribute as ivec4



Vexator
06-23-2011, 03:13 PM
I've got the following vertex shader to perform hardware skinning. I'd like to declare the vertex attribute in_boneIds as ivec4 so that I can use the id's directly for the bone matrix look-up. This does, however, not work - all bone id's default to 0 then. Instead, I have to declare the attribute as vec4 and then cast it manually to ivec4 before using it.

Tested this on both NVidia and AMD cards. No error is returned. Also, it does not matter whether I declare and store the input data as floating points or integers.

Does anyone have an idea what's going on here? Thank you.


#version 330 core

#extension GL_EXT_gpu_shader4 : enable

layout(location = 0) in vec4 in_vertexPos;
layout(location = 1) in vec2 in_textureCoords;

layout(location = 2) in vec4 in_weights;
layout(location = 3) in ivec4 in_boneIds;

out Vertex
{
vec2 textureCoords;
} vertex;

layout(std140) uniform;

uniform Transform
{
mat4 view;
mat4 model;

mat4 bones[64];
} transform;

uniform Projection
{
mat4 perspective;
mat4 orthographic;
} projection;

void main()
{
vertex.textureCoords = in_textureCoords;

mat4 modelView = transform.view*transform.model;
mat4 modelViewProjection = projection.perspective*modelView;

vec4 finalVertexPos = vec4( 0.0 );

finalVertexPos += in_weights.x * in_vertexPos * transform.bones[in_boneIds.x];
finalVertexPos += in_weights.y * in_vertexPos * transform.bones[in_boneIds.y];
finalVertexPos += in_weights.z * in_vertexPos * transform.bones[in_boneIds.z];
finalVertexPos += in_weights.w * in_vertexPos * transform.bones[in_boneIds.w];

gl_Position = modelViewProjection * finalVertexPos;
}

Ilian Dinev
06-23-2011, 03:24 PM
You're not binding with the glVertexAttribIPointer

Vexator
06-23-2011, 04:59 PM
d'oh! thanks!