Advertisement

Applying a transparent color to set of vertices with existing texture?

Started by August 06, 2020 08:56 PM
1 comment, last by markypooch 4 years, 3 months ago

Trying to figure out what the best way would be to go about this. Say I have a model with 100s of vertices and I need to have the faces that are composed of 9 of those vertices to have a partially transparent color applied on top of the texture already used by those vertices. A good example of this would be something like a grid based tactics game where to denote your movable area, a transparent overlay is placed on top of areas in the map:

My initial thought was to pass a buffer of vertices to the vertex shader and check each vertice to see if it is in the buffer and if so then pass a flag to the fragment shader which could then mix the appropriate color with the existing texture. But this seems like it would be quite inefficient as there would need to be looping logic which checked EVERY vertex to see if it was in the buffer or not…what are your thoughts on this?

Another option might be to use framebuffers. The initial scene could be held in a framebuffer, then another buffer could be generated using only the vertices of the faces to highlight giving them a color with an alpha, then blending the two buffers together…maybe?

Do either of these options seem feasible or is there another option that would make more sense? (As you've probably gathered by now I'm fairly new to graphics development so any advice is really appreciated).

Kinda guessing, but I'd wager tactics probably had a underlying representation of the game map in memory composed of tiles. These tiles probably have some members including a vector for it's position (x,y,z), some identifier of the tile type (maybe to use to figure out what tile asset to use when rendering the map, and to apply context sensitive game modifiers to the character when on them), and possibly some tracking for who is on that particular tile.

Using just this in memory representation of a tile, you could render a transparent overlay of the tiles completely separate from the in game assets they use and offset them appropriately based upon the underlying tile members, and as such apply separate blend states/other don't care states/shaders to them in separate draw calls.

Does that make sense?

Edit: Should also mention when authoring the model in your software of choice: blender/maya, you could just have some way of delineating subsets of a particular model w/ a material type. This could enable you to simply apply different rendering states/shaders as well when looping through the model subsets, or something to that tune

This topic is closed to new replies.

Advertisement