SFML community forums
Help => Graphics => Topic started by: zeno15 on August 05, 2013, 06:45:57 am
-
I have a simple tile map that uses vertex arrays to display it, and it refers to a texture ive passed to it, it all works fine, I'm just curious as to what effect setting the color of the vertex's has? I know when I set it to Transparent it shows the color used to clear the screen and when set to black it shows all black, but I was wondering if there was a more official answer than my trial and error,
Cheers
-
A pixel color is the result of the interpolation of the color of its related vertices. ( http://www.sfml-dev.org/tutorials/2.1/images/graphics-vertex-array-triangle.png )
Then its color is multiplied with its texture color.
It can obviously be used to change the opacity, but you can also use it to colorize your texture. For example with the same greyscale grass texture, you could display it with several different shades of green (or whatever) just by modyfing its vertices colors.
(also works with sprite, if you use Sprite::setColor, it sets its 4 vertices to the given color)
-
The texture's pixels are modulated (multiplied) by the vertex color.
-
Oh righto, that's excellent thanks :)