I recently pushed a patch which inverses the meaning of the alpha channel almost everywhere in Clonk, both for engine and script. Previously, alpha=0 meant the color to be opaque, and for alpha=255 it was transparent. This has been inversed, so that alpha=0 is transparent and alpha=255 is opaque.
As far as scripting is concerned, the following needs to be payed attention to:
I made this change because
A few spots might have been missed during the conversion, so if, after having taken care of the points above, an object does not behave as you expect it to with respect to its transparency, feel free to assume it is an engine bug, and tell us.
As far as scripting is concerned, the following needs to be payed attention to:
- I changed the
RGB
function so that it continues to produce an opaque color. - However, if you are using
RGBa
, you most likely want to change its alpha value to 255 minus itself, to keep getting the same effect. - To reset an object's ClrModulation,
SetClrModulation(0)
no longer works; this renders the object invisible now. UseSetClrModulation()
orSetClrModulation(RGB(255,255,255))
instead. - Likewise, for an unmodulated object,
GetClrModulation()
no longer returns 0, butRGB(255,255,255)
.
I made this change because
- this is how the alpha channel is used almost everywhere else.
- OGRE material scripts use this convention, and it becomes hard or even impossible to covert them to Clonk's old convention for more advanced scripts (which are not yet supported, but might well be in the future).
A few spots might have been missed during the conversion, so if, after having taken care of the points above, an object does not behave as you expect it to with respect to its transparency, feel free to assume it is an engine bug, and tell us.
> However, if you are using RGBa
We should consolidate RGBa and RGB to just one function. I don't actually know why this hasn't been done in CR, since the interface wouldn't have changed.
> To reset an object's ClrModulation, SetClrModulation() is no longer enough; this renders the object invisible now. Use SetClrModulation(RGB(255,255,255)) instead.
I thought nil was supposed to solve just such a problem? SetClrModulation(nil) and SetClrModulation() can reset while SetClrModulation(0) makes the object black and invisible. Though making an object invisible with ClrModulation is not very interesting, because we already have a dedicated function for that.
> this is how the alpha channel is used almost everywhere else.
And with good reason: Earlier, making an object half-transparent with ClrModulation meant that those parts of the object which were already less than half visible, say the antialiased edges, became completely invisible, because the alpha channel was mixed through addition. Now, making an object half as opaque actually works.
> I thought nil was supposed to solve just such a problem? SetClrModulation(nil) and SetClrModulation() can reset while SetClrModulation(0) makes the object black and invisible.
Actually I changed the ClrMod behaviour in C4Object, and didn't consider changing the script functions in any way - I just noticed what implications my changes have from a scripter's perspective. Anyway, your suggestion sounds perfectly reasonable, so I implemented it.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill