"F_hardware_skinning" Flag Not Being Set?

In short, what might prevent the “F_hardware_skinning” flag in a shader-attrib from being set?

To explain, I’m attempting to implement hardware skinning, and, in accordance with this thread and the example given there, one of the steps of my implementation is to create a shader-attrib and set its “F_hardware_skinning” flag to “True”.

However, for some reason the setting doesn’t seem to take effect: if I call “getFlag” immediately after the call to “setFlag”, I get a result of “False”. :/

That is to say, given the following code:
(Where “shader” is a custom shader previously loaded via Shader.load(Shader.SL_GLSL, <vertex-shader-file-name>, <fragment-shader-file-name>) )

                attrib = ShaderAttrib.make(shader)
                attrib.setFlag(ShaderAttrib.F_hardware_skinning, True)
                print (">>>>>", attrib.getFlag(ShaderAttrib.F_hardware_skinning))

I’m seeing printed output of “>>>>> False”.

Conversely, however, the example given in the thread linked-to above seems to work just as expected, and indeed a similar call to “getFlag” there returns a result of “True”.

I’ve tried messing with config-variables, thus far to no avail.

I’m thus stumped–does anyone here have an idea as to what might be going wrong?

It might be worth noting that, unlike in the example, I’m using a (GLSL) shader that is loaded from a file, rather than made using inline text. Like the shader in the example, my shader uses “#version 130”.

You should do something like that:

sattrib = ShaderAttrib.make(shader, 100)
sattrib = sattrib.set_flag(ShaderAttrib.F_hardware_skinning, True)
np.set_attrib(sattrib)

.set_flag() returns a new modified version of passed ShaderAttrib with a new flag enabled. It’s a little confusing, but that’s how it works.

2 Likes

Aaah, you’re quite right!

And indeed, looking again at the example, I had completely missed that it was in fact taking the return-value of the call to “setFlag”!

Thank you, and fixing that does indeed solve the problem! :slight_smile:

[edit] And with that, what a difference hardware skinning makes to the performance of my game! Indeed an optimisation well worth implementing in my case, I feel! :slight_smile:

1 Like