Is there a way to overlay a texture onto a model?
For example, for a soccer player model you want each player to have a different number on their back. Without using a different texture for every shirt, is there a way to overlay a number with transparency on to the back of their shirt? In particular with the Source engine. What would be the best of going about this?
Replies
- You have two types of texture: one that's normal shirt; and one that's a grid of numbers, all evenly spaced.
- set up two UV sets for your player's shirts: one for normal texture, and one with the area that will be numbered (which is mapped to 0..1 UV space)
- When sampling your textures, sample from your shirt diffuse using UV set 1, and sample from your numbers texture sheet using UV set 2. Use some simple math to scale UV set 2 based on which numbers you want to show, and how many numbers you have in your numbers sheet. Just say your numbers texture sheet is an 8x8 grid of numbers, you multiply UV set 2 by 0.125f to make it 1/8th of the texture sheet, then you offset the UVs to pick the number you want.
- Now blend the number over the normal diffuse. If your numbers sheet is just an alpha value, you can just lerp from the t-shirt colour to a number colour shader parameter using the number texture sheet's alpha.
- Pass through which number you want to use to the shader as a shader parameter. I don't use Source but I imagine that's easy to set up (it should be!)