PDA

View Full Version : vert attributes



supagu
12-08-2004, 02:24 AM
trying to make a skinning shader in GLSL, now with my bone index's are turning out to be a problem.

i cant have int as an attribute.
eg. attribute int boneIdx[4];

so if i send them up as floats
attribute vec4 boneIdx; this works okay.
then the problem become not being able to convert a float to an int!

is there a simple solution to this problem?

spasi
12-08-2004, 04:08 AM
Originally posted by supagu:
is there a simple solution to this problem?ivec4(boneIdx)

Ffelagund
12-08-2004, 12:31 PM
or attribute ivec4 boneIdx;

spasi
12-08-2004, 01:07 PM
You can't declare integer typed attributes. From the spec:


The attribute qualifier can be used only with the data types float, vec2, vec3, vec4, mat2, mat3, and mat4.
Attribute variables cannot be declared as arrays or structures.But...you actually can with the NVIDIA compiler. It allows integer attributes, obviously because it is allowed (?) in Cg. Unfortunately, it doesn't work anywhere else. And most unfortunately, the low-level code generated when having float attributes and using casts, is considerabely worse than when you just use integer ones. Strange, but may be fixed in the future.

Korval
12-08-2004, 02:16 PM
Can't you just do the conversion (which is almost certainly a no-op on most hardware) when you index the array?

supagu
12-08-2004, 06:05 PM
cant cast from float to int in GLSL :-/

so an ivec4 is a vector of ints im assuming :D

supagu
12-08-2004, 11:35 PM
okay just tried ivec4

"attribute ivec4 bone;"

and the error:

ERROR: 0:5: 'attribute' : cannot be bool or int

:'(

spasi
12-09-2004, 12:53 AM
Originally posted by supagu:
cant cast from float to int in GLSL :-/Of course you can. Just do the cast when indexing the bones array:

bones[int(boneIdx.x)];

Or create a new ivec4 by casting the vec4 and then use the ivec4's components immediately:

ivec4 indices = ivec4(boneIdx);
bones[indices.x];


Originally posted by supagu:
ERROR: 0:5: 'attribute' : cannot be bool or intIt's an error, as it is not allowed by the spec (see previous post).