Search Unity

Create a new texture from multiple or blend textures in shader?

Discussion in 'Scripting' started by Fellshadow, Apr 17, 2014.

  1. Fellshadow

    Fellshadow

    Joined:
    Dec 2, 2012
    Posts:
    169
    What I'm trying to do is allow the player to choose different heads, upper bodies, and lower bodies to customize their (2D) character, and I'm trying to figure out which method would be the most efficient.
    I'm using quads instead of sprites and a custom shader so that I can have lighting and shadows.

    I'm worried that using SetPixel to create new textures would take too long, as I'd need to combine at least 96 textures down to 32 textures. Each texture is at least 1024x1024.

    Where it gets a little bit more complicated is that I plan to use the alpha channel of the Normal Maps as Depth Maps to compare depths of the pixels, so that the character can have depth.

    So the two options I have are:
    1) Combine the textures only when the player changes how the character looks.
    2) Get the needed textures for the currently playing animation, and blend it in the shader.

    Which do you think is the better method? Or am I going about this the wrong way?


    For any who are curious as to why I have at least 96 textures for one character:
    For a single animation, I would need 1 Diffuse texture for each body part (Head, Upper, Lower), as well as a Normal Map. (6 Textures total)
    Then, I'd need a different texture for each direction the player is facing (total of 4 directions) (6 * 4)
    So, per animation (including the different directions), I'd need 24 Textures.
     
    Last edited: Apr 17, 2014