Search Unity

Blending of transparent textures

Discussion in 'Shaders' started by OlegGel, Dec 1, 2010.

  1. OlegGel

    OlegGel

    Joined:
    Nov 9, 2010
    Posts:
    12
    I write game for ipad. When i apply default diffuse shader to material of background and SpotLight for imitation of dark room, i get slow fps on ipad.
    Then i set non-transparent background, create Projector object and set custom shader on projector material
    Code (csharp):
    1.  
    2. Shader "Projector/New Light"
    3. {  
    4.     Properties
    5.     {  
    6.         _Color ("Main Color", Color) = (0,0,0,1)    
    7.         _ShadowTex ("Cookie", 2D) = "" { TexGen ObjectLinear }
    8.         //_FalloffTex ("FallOff", 2D) = "" { TexGen ObjectLinear }
    9.     }
    10.  
    11.     Subshader
    12.     {
    13.         Pass
    14.         {    
    15.             ZWrite off
    16.             Fog { Color (0, 0, 0) }
    17.             Color [_Color]
    18.             ColorMask RGB
    19.             Alphatest Greater 0
    20.             Blend DstColor Zero
    21.             Offset -1, -1
    22.             SetTexture [_ShadowTex]
    23.             {
    24.                 constantColor [_Color]
    25.                 combine texture * primary, texture * primary
    26.                 Matrix [_Projector]
    27.             }
    28.      
    29.         }
    30.     }
    31. }
    32.  
    when in scene only non transparent object - all work perfectly: visible only objects, which blending with white color of projector texture, but when in scene transparent objects - no effect of projector to them. How modify this projector shader for support hiding in black color transparent sprites??