Search Unity

Question [Solved] Blending of Textures

Discussion in 'Shader Graph' started by Oribaru, Feb 27, 2020.

  1. Oribaru

    Oribaru

    Joined:
    Feb 23, 2019
    Posts:
    9
    Dear all,

    I (beginner) struggle with a apparently simple problem:

    I have a shader which applies different textures based on alpha maps on my generic created terrain. Now i try to blend different textures to each other where they have contact. My problem is that where the blend happens the texture is brighter. See pictures: TextureBlendFail1.PNG
    TextureBlendFail2.PNG

    The alpha map is a map with black and white areas, choosing the corresponding texture where my area is black. The blend happens with a gray scale value.

    I understand my problem as follows: I have texture A which uses the alpha map black = normal display. Then i try to add a gray-scale value (for example 0.5) using texture B on top of it. This brightens my texture.

    I cant figure it out how I can normalize my two textures without turning every other area (where only 1 texture is present) down as well. Is there a way to apply normalization only where this situation of 2 alpha maps values (in total > 1) are present?

    Does someone has experience with something similar and can point me in the right direction? Did I present my problem in a somewhat understandable way?

    Thanks a lot in advance!
    Cheers Ori
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    When you say "blend", what do you exactly mean? Are you multiplying two values together, for example? I would imagine you could just use a lerp to mix two values together based on an alpha value (0-1 range.)
     
  3. Oribaru

    Oribaru

    Joined:
    Feb 23, 2019
    Posts:
    9
    Hi Olmi - thanks for your reply!

    I multiply the alpha values (ranged from 0 to 1) and then later add the textures. The multiply and add subgraph are just several multiply and add nodes in series.
    ShaderGraph1.PNG
    SubGraph.PNG

    When i lerp instead of add then i have the blend textures with the expected brightness and where only 1 texture is it is too dark... (quasi offset of the add on the alpha map...)
     
  4. Oribaru

    Oribaru

    Joined:
    Feb 23, 2019
    Posts:
    9
    Hi Everyone,

    Quick update - I finally figured it out! When i create my alpha map i just subtract 1-blend value from the previous tile and voila, works like a charm!

    Thanks Olmi for your help!