Search Unity

fast shader help

Discussion in 'Shaders' started by abkarch, Oct 18, 2010.

  1. abkarch

    abkarch

    Joined:
    Jun 12, 2010
    Posts:
    41
    Code (csharp):
    1.         Shader "Rotating UV" {
    2.       properties {  _MainTex ("Base (RGB) Transparency (Ambient)", 2D) = "" {}}
    3.         SubShader {
    4.            Pass { Tags {"Queue" = "Transparent" }      Blend SrcAlpha OneMinusSrcAlpha
    5.                 Material { Diffuse (1,1,1,1) Ambient (1,1,1,1) }
    6.                 Lighting On
    7.                 SetTexture [_MainTex] {
    8.                    matrix [_Rotation]
    9.                     combine texture * primary double, texture
    10.                }
    11.             }
    12.         }
    13.         }
    this is a shader that someone in the IRC created for me. it works along with a script to rotate a material according to mouse input.
    All i need now is for black to be transparent. i tried adding some code, as you all can see, but the black is only a very, very, small amount transparent. can someone fix it up for me? thx
     
  2. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Your shader doesn't do that at all. If you see black as transparent with that, it's because your brain and eye connection is wonky. :p Also, "Transparency (Ambient)" doesn't make any sense. You need to decide what you actually want to do. You're talking about additive blending. But additive blending is going to let the background through everywhere. So if that's not what you want, use what you had to begin with, and make a better alpha channel.

    Also, please try to make an attempt at formatting.

    Code (csharp):
    1. Shader "Additive Blend, Rotating UV" {
    2.    
    3. Properties {
    4.     _MainTex ("Texture (RGBA)", 2D) = ""
    5. }
    6.  
    7. SubShader {
    8.     Tags {Queue = Transparent}
    9.     Blend One One
    10.    
    11.     Lighting On
    12.     Material {
    13.         Diffuse (1,1,1)
    14.         Ambient (1,1,1)
    15.     }
    16.    
    17.     Pass {
    18.         SetTexture [_MainTex] {
    19.             Matrix[_Rotation]
    20.             Combine texture * primary Double
    21.         }
    22.     }
    23. }
    24.  
    25. }
     
    Last edited: Oct 18, 2010