Unity3D/Shadow

Projector Multiply Offset

blueasa 2014. 4. 3. 12:51

Unity Pro에 있는 Blob Project Shadow를 쓰는데 그림자가 알파가 있는 텍스쳐보다 아래 그려져서 떠보이길래 약간 수정..


겸사겸사 Color Offset도 추가..


Shader "Projector/Projector Multiply Offset" { 
    Properties {
        _ShadowTex ("Cookie", 2D) = "gray" { TexGen ObjectLinear }
        _FalloffTex ("FallOff", 2D) = "white" { TexGen ObjectLinear }
        _Tint ("Offset", Color) = (0,0,0,0)
    }
 
    Subshader {
	Tags { 
		"RenderType"="Transparent"  
		"Queue"="Transparent+100"		 // 알파 텍스쳐보다 위에 그리기 위해 Queue를 올림..
		}
		
        Pass {
            ZWrite Off
            Offset -1, -1
 
            Fog { Color (1, 1, 1) }
            AlphaTest Greater 0
            ColorMask RGB
            Blend DstColor Zero
            SetTexture [_ShadowTex] {
                combine texture, ONE - texture
                Matrix [_Projector]
            }
            SetTexture [_FalloffTex] {
                constantColor (1,1,1,0)
                combine previous lerp (texture) constant
                Matrix [_ProjectorClip]
            }
            SetTexture [_FalloffTex] { // add offset
                constantColor [_Tint]
                combine previous + constant
            }
        }
    }
}



참조 : http://forum.unity3d.com/threads/25162-Projector-Multiply-With-Alpha

반응형