Latest Posts

Topic: White border around PlayerColor

Kiscsirke
Avatar
Joined: 2009-12-16, 13:40
Posts: 42
Ranking
Pry about Widelands
Location: Budapest, Hungary
Posted at: 2013-01-25, 01:02

Hey Chuck! Here is something I noticed with the new barbarian flag: there is a (very) slight white outline around the axe. It's most noticable with blue player I think.

And I also know the reason face-smile.png I'll have the solution below, you only need to read this if you're curious. The problem is anti-aliasing. Let's suppose for a moment that we have the border of PlayerColor and a black (RGB 0, 0, 0) background, and our player's color is blue (0, 0, 255), and because of anti-aliasing the border pixel is half this, half that. Currently, the PlayerColor material is white (255, 255, 255), so on the normal render, the border pixel is grey (128, 128, 128), and the playercolor mask is half (128, ergo 0.5). Then when blue is applied, it gets mixed 0.5 - 0.5 with the original color, so we get (128, 128, 128) * 0.5 + (0, 0, 255) * 0.5 = (64, 64, 192). This is not between the (0, 0, 0) and the (0, 0, 255), but lighter.

The solution is to set the PlayerColor material in Blender to be the same color as the background is, in this case black, in the flag's case, brown. It will still be changed to "white" for the playercolor rendering, it will still work, but it will get rid of the white border.

If you plan to use this, you might need two different colored PlayerColors at one point I guess? In that case, can you have two different materials with the same name? If you can't I can easily change the menu script to work on all materials with names starting with "PlayerColor", so you could have PlayerColor1, PlayerColor2 and so on.

PS.: BTW shouldn't you upload the barbarian flag to widelands-media? face-tongue.png


Top Quote
chuckw
Avatar
Joined: 2010-03-15, 16:23
Posts: 945
Ranking
One Elder of Players
Location: New York - USA
Posted at: 2013-01-25, 22:04

Hey! Thanks for the note regarding the barbarian flag and the explanation of the effect of anti-aliasing. (I had noticed it more with the black player color.)

It did not dawn on me to reduce/eliminate the artifact because I rather think it aids distinguishing the dark player colors from the dark brown background of the flag. Had it not happened by accident, I likely would have put in some contrasting border around the axe image anyway.

Without some contrast, it would be nearly impossible for me, personally, to identify the color blue or black or where it changed to brown on the flag. (Side note-I'm still considering altering the hue of the blue player color to something lighter throughout the game to further distinguish it from black.)

Kiscsirke wrote: ...The solution is to set the PlayerColor material in Blender to be the same color as the background is, in this case black, in the flag's case, brown. It will still be changed to "white" for the playercolor rendering, it will still work, but it will get rid of the white border.

If you plan to use this, you might need two different colored PlayerColors at one point I guess? In that case, can you have two different materials with the same name? If you can't I can easily change the menu script to work on all materials with names starting with "PlayerColor", so you could have PlayerColor1, PlayerColor2 and so on.

Your point, though, is a good one. I'm just not eager to remove the effect in this case.

That is not to say there may not be cases where such functionality would be desirable.

Blender does not support assigning two or more different materials to the same name. It will merely append a qualifying extension or replace the former material with the newer one depending on where and how the attempt is made.

Your offer to change the script to support multiple materials is attractive if it is not too much work, although it could lead to some sloppy material maintenance on the part of the graphician. face-smile-big.png

.

Bottom line: I'm willing to entertain multiple player color functionality if you are willing to modify the script to handle it.


I see little people.

Top Quote
chuckw
Avatar
Joined: 2010-03-15, 16:23
Posts: 945
Ranking
One Elder of Players
Location: New York - USA
Posted at: 2013-01-25, 22:11

Kiscserke wrote: PS.: BTW shouldn't you upload the barbarian flag to widelands-media? face-tongue.png

face-smile.png I probably would have, but for the moment bzr has "broken" on my desktop. I'll set things right when I can.


I see little people.

Top Quote