Search Unity

Question Stack textures on top of eachother

Discussion in 'Shader Graph' started by Anax7, Jan 18, 2021.

  1. Anax7

    Anax7

    Joined:
    Nov 23, 2012
    Posts:
    13
    Hi,

    I'd like to create a customizable camouflage pattern consisting of two images with transparency. I'm trying to place the images one on top of another while maintaining their alphas.

    I can't figure out a proper way to do it, all I'm achieving so far is to blend their colors using math functions or the blend node which is not what I want. I include an image with the wanted result.

    Thanks for reading!
     

    Attached Files:

  2. TheCandy

    TheCandy

    Joined:
    Dec 5, 2016
    Posts:
    22
    Well.. You want to add two patterns over each other. They overlap at some spots, where it is represented as white. What you need to do is to take the bottom color (blue in your case) and substract the pattern from the orange one, so it creates "cutouts" so no part of the two patterns overlap. I uploaded my version (I create the pattern with noise, but it should be the same for you. The "clamp" node is to take anything below zero out of the equation, as that would make some funky result (but expectable) you can try for yourself... I suppose there might be a more intelligent solution, but this works
     

    Attached Files:

  3. JG-Denver

    JG-Denver

    Joined:
    Jan 4, 2013
    Posts:
    77
    Off the top of my head, you could try picking one texture for the top, pick out it's components to separate alpha and do a Blend with type Overwrite, put the alpha in the Opacity.
     
  4. Anax7

    Anax7

    Joined:
    Nov 23, 2012
    Posts:
    13
    Thanks a lot this works perfectly! It does need a clamp after the subtraction although I'm not 100% sure why. I suppose after the subtraction some values go negative and are somehow getting displayed? Also I don't understand, on the top texture, why do you Split and then Combine?
     
  5. TheCandy

    TheCandy

    Joined:
    Dec 5, 2016
    Posts:
    22
    Oh.. The split and combine is useless... I just forgot it there, when i tried to substract the separate channels.

    The negative values of the blue color wouldnt be problem, as they appear black, but when you add them to the top texture, they simply substract from the visible yellow colour. You get some green colors as result.
     
    Anax7 likes this.