MaterialTypeParam float vs pack_texureBlendFunc

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
tonic
Posts: 69
Joined: Mon Dec 10, 2007 6:18 pm
Contact:

MaterialTypeParam float vs pack_texureBlendFunc

Post by tonic »

I seem to be running to problems every now and then with the MaterialTypeParam field in SMaterial, and how a blend mode is packed in it using pack_texureBlendFunc.

For some reason the current implementation (which uses inttofloat union trick for the int<->float conversion) doesn't seem to be working correctly on iOS after upgrading to Xcode 4. No idea why.

If I change that back to the old style of converting the actual int value to float, it works again. But somehow we're having problems with that way on android, leading to all blended stuff being black!


Since the whole problem comes from the fact that the MaterialTypeParam is float, what do you think if we'd change type of that param to int? It is not used by very many materials after all, so it could as well work the other way by changing others to treat int back to a float in a way they like.

Or, alternatively we could change the MaterialTypeParam2 to be an int, and modify onetexture_blend material to read MaterialTypeParam2 instead of MaterialTypeParam. The only instance currently using MaterialTypeParam2 is the Q3 shader which actually also just crams shader id integers to that float.

Opinions?


Also, if we fiddle in one or other way by my proposition, we could also maybe fix the pack_textureBlendFunc typo at the same time.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I think that it would be easier to change MaterialTypeParam2 to u32 and pack the values into that member. I'll keep this on the list and add the changes once I have a cleaner repository with less work in progress...
Post Reply