Home Technical Talk

Compare texture blending methods in performance

polycounter lvl 13
Offline / Send Message
omid3098 polycounter lvl 13
1- we can paint vertex color on model and blend them using vertex color. with/without mask texture in blend edges.
this way when we want to export model to game engine, it should export vertex color with model. and used textures.

2- we can make an mask texture and blend textures using that mask. where is black will be texture1 and where is white will be texture2.
we can paint every way we want on mask texture.
for tile-able UVs we can use second channel and non-tileable uv to paint on any parts of model. this way when you want to export model to game engines, it does not need vertex color, but maybe some times one more UV channel.

so..

- which way has more performance in game engines?
- is there any other way?
- which way is easier to use in your pipeline?
- may you suggest any related things or points to increase performance?

Replies

  • Bal
    Options
    Offline / Send Message
    Bal polycounter lvl 17
    I'm pretty sure the first technique is still the most viable, for the simple reason that you'll be adding too much extra texture data with the second one, what with all the masks you'll need.
    The first technique is also alot easier to apply on a large scale, and easy to work with with current tools.
  • JostVice
    Options
    Offline / Send Message
    JostVice polycounter lvl 12
    does anyone know if there is any way of having more than 4 textures in the blending in one material? a programmer told me that it couldn't be done if you want each texture to have a normal map too (specular can be derived from diffuse though) and performance wasn't very good

    does anyone know if there is a shader for max to show 4 texture blend by vertex colors with mask?
  • felipefrango
    Options
    Offline / Send Message
    felipefrango polycounter lvl 9
    Bal wrote: »
    I'm pretty sure the first technique is still the most viable, for the simple reason that you'll be adding too much extra texture data with the second one, what with all the masks you'll need.
    The first technique is also alot easier to apply on a large scale, and easy to work with with current tools.

    Well, you don't have to have one black and white texture for every mask, I suppose you could use a RGBA texture and have 4 b/w masks on the same texture.

    @JostVice: I don't know how viable that would be in a real game but I quickly set up a shader at work using ShaderFX for 3dsmax that mixed 6 textures (2 diffuse, 2 normal, 2 spec) according to R and G vertex channels, and I could add 6 more to use with the B and Alpha channels. I don't know if that's too many instructions or whatever cause it was just a quick prototype but as far as I know it can be done.
  • ZacD
    Options
    Offline / Send Message
    ZacD ngon master
    JostVice wrote: »
    does anyone know if there is any way of having more than 4 textures in the blending in one material? a programmer told me that it couldn't be done if you want each texture to have a normal map too (specular can be derived from diffuse though) and performance wasn't very good

    does anyone know if there is a shader for max to show 4 texture blend by vertex colors with mask?


    Starcraft 2 allows 7... so I dunno
  • Axios
    Options
    Offline / Send Message
    Axios polycounter lvl 10
    JostVice wrote: »
    does anyone know if there is any way of having more than 4 textures in the blending in one material?

    I don't know about the performance side of it, but theoretically you should be able to blend 16 different textures by using vertex colors to mask each other. Basically, instead of R = Texture 1, B = Texture 2, etc think of the channels in terms of combinations.

    RGBA

    0000 = Texture 1
    0001 = Texture 2
    0010 = Texture 3
    0011 = Texture 4
    ...
    1110 = Texture 15
    1111 = Texture 16

    Here's a mockup I did in UDK; didn't bother with texture masking since this is simply conceptual. Also, I guess UDK caps your texture samples for a material at 12 (is there a way around this?) so I did 8 unique maps and inverted them for the other 8 to make 16 textures.

    vertexColor_mat.jpg

    vertexColor_mesh.jpg

    I wouldn't know how to set this up from program to program, but I think the concept is sound. Also, please excuse how terrible it looks, but the material is working.
  • felipefrango
    Options
    Offline / Send Message
    felipefrango polycounter lvl 9
    @Axios: and theoretically if you wanted to have normal and specular maps all you'd have to do would be duplicate this setup twice and have a new set of 8 textures for each, right? I mean, 24 textures is obviously excessive, but in theory that's it, right?
  • Axios
    Options
    Offline / Send Message
    Axios polycounter lvl 10
    @felipefrango: Yeah, assuming that each normal/spec map matched up with only a specific diffuse. Diffuse Texture 7 would always be with Normal Texture 7 and Spec Texture 7; no other mixing. Of course, I can't think of a ton of reasons you'd want this many, but I don't think you should be limited to 4.
  • felipefrango
    Options
    Offline / Send Message
    felipefrango polycounter lvl 9
    Oh cool. Looks like what I set up in ShaderFX only a lot smarter, I like the solution of combining the channels to produce 16 variations, thanks for sharing. :D
  • Axios
    Options
    Offline / Send Message
    Axios polycounter lvl 10
    Okay, so I thought about this some more, and I tested the concept of isolation specific portions of the 0-1 scale of a given vertex color and using it to mask textures. So instead of using just 0 and 1 to decide between Texture 1 and Texture 2, you can 0.1 for Texture 1, 0.2 for Texture 2, etc. Actually, it'd be more like 0.15-0.25 instead of just 0.2. Take, for instance, you use a 0.00 - 1.00 scale as UDK does, then you can define a texture in 0.01 increments. In effect, you can set up 100 textures to function on one vertex color. Now combine that with the system from my previous post and you can set up combinations like this:
    R     G     B     A
    
    0.00, 0.00, 0.00, 0.00
    0.00, 0.00, 0.00, 0.01
    0.00, 0.00, 0.00, 0.02
    ...
    0.94, 0.07, 0.28, 0.54
    0.94, 0.07, 0.28, 0.55
    ...
    1.00, 1.00, 1.00, 0.98
    1.00, 1.00, 1.00, 0.99
    1.00, 1.00, 1.00, 1.00
    

    Then end result there would be 100,000,000 possible unique textures. I just set up a small portion of this system to test the concept which appears to be working. The method right now eliminate gradients between textures so it's a harsh, ugly transition, but I think that gradients would cause the transition to go through a bunch of the textures rather than smoothly blending from A to B. However, I would think that the blend could be modified elsewhere in the material. Of course none of this is really practical, but it's fun to think about. Note: You should never put a hundred million textures on any mesh.

    Edit: A slightly less ridiculous way of look at it would be to use 0.0, 0.5, and 1.0 as your vertex color values. This would give 3 possible textures per vertex color as opposed to the original two. That would result in 81 unique textures.
Sign In or Register to comment.