Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Vertex Array giving coluor to texture  (Read 1958 times)

0 Members and 1 Guest are viewing this topic.

ashleybeshir

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Vertex Array giving coluor to texture
« on: May 18, 2016, 04:39:27 am »
Hello ,

I know that you can add colour to the vertex but if i want to use a texture atlas . Is it possible to only change colour of it . Lets say i want to add green colour to brick instead of changing the texture itself in photoshop

Regards Ashley

nicox11

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Vertex Array giving coluor to texture
« Reply #1 on: May 18, 2016, 09:56:33 am »
I don't exactly understand. Is it what it is shown in the sprite tutorial :

http://www.sfml-dev.org/tutorials/2.3/graphics-sprite.php

If so, it is probably possible to do it using vertex array, using this ?

http://www.sfml-dev.org/documentation/2.3.2/classsf_1_1Vertex.php#ad5943f2b3cbc64b6e714bb37ccaf4960

Or I don't understand what you asked.


Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Vertex Array giving colour to texture
« Reply #2 on: May 18, 2016, 10:20:50 pm »
Each Nicox mentioned, it is possible to use the colour to "multiply" the texture as shown in the Sprite tutorial.

Each vertex in a vertex array has multiple properties: position, colour and texture co-ordinates. They can all be used at any time so texture co-ordinates and colour can be applied at the same time to each vertex. Technically, each vertex always has a colour - even when displaying a texture; it's just set to white as this shows the texture in its original form.

As with the sprite colouring, colours in vertices and multiplied with the texture. This works like a filter. For example, full white allows all three components in their original form, full red allows only the texture's red component to show (whatever value it may be) and half blue allows only the texture's blue component to be shown but halves its value.
Note that this means that something can't retain white (for example) after being "filtered" by a colour.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything