Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Masked Additive Shader -- Almost there!

Discussion in 'Shaders' started by tabor, Sep 23, 2013.

  1. tabor

    tabor

    Joined:
    Nov 29, 2011
    Posts:
    42
    Hi friends,

    I am trying to make a additive shader, with tint, main texture, and uses a texture as a mask.
    I am almost there, but I can't seem to get the additive and mask going at the same time.
    Any ideas?

    Thanks


    Code (csharp):
    1. Shader "Custom/AdditiveMask"
    2. {
    3. Properties
    4. {
    5. _TintColor ("Tint Color", Color) = (1,1,1,1)
    6. _MainTex ("Base (RGB)", 2D) = "white" {}
    7. _Mask ("Culling Mask", 2D) = "white" {}
    8. _Cutoff ("Alpha cutoff", Range (0,1)) = 0.1
    9. }
    10. SubShader
    11. {
    12. ZWrite Off
    13. Alphatest Greater 0.1
    14. Tags {"Queue"="Transparent"}
    15. Lighting off
    16. Blend SrcAlpha One
    17. AlphaTest GEqual [_Cutoff]
    18. Color [_TintColor]
    19. Cull off
    20. Pass
    21. {
    22. SetTexture [_Mask] {
    23.  
    24. combine texture * constant
    25. }
    26. SetTexture [_MainTex] {
    27. constantColor [_TintColor]
    28. combine constant * primary
    29. }
    30. SetTexture [_MainTex] {
    31. combine texture * previous DOUBLE
    32. }
    33. }
    34. }
    35. }