Home Technical Talk

Overlaying a texture onto a model

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

  • McGreed
    Offline / Send Message
    McGreed polycounter lvl 15
    Or you can do it in the material, I think I saw a material tutorial about it, where the shader takes an ID from the model name, and then used it for the texture in the shader, which it then overlayed with the base texture.
  • S_ource
    Offline / Send Message
    S_ource polycounter lvl 9
    You can use several materials for models in source engine. So i would had the places where the unique textures would be on separate texture and then use one base texture for all materials and one texture for every number. Maybe its a better way to do it but that's what i can think of you can read more about it here. https://developer.valvesoftware.com/wiki/Multiple_Skins_for_a_Single_Model
  • Thinge
    McGreed wrote: »
    Or you can do it in the material, I think I saw a material tutorial about it, where the shader takes an ID from the model name, and then used it for the texture in the shader, which it then overlayed with the base texture.
    Any idea where this is from? We still haven't found a solution. At the moment its around 12GB extra of data if not, which isn't really feasable!
  • cryrid
    Offline / Send Message
    cryrid interpolator
    If I recall, assign the card a different texture before exporting it. If you open the smd file in notepad you should see those faces looking for that second texture name (which is what you'll want to name the second material file)
  • Kurt Russell Fan Club
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    It's not too much trouble if you want to do it this way:

    - 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!)
Sign In or Register to comment.