유니티 스캔라인 쉐이더 ( Unity Scan-line shader )



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Shader "Custom/Scanlines" { 
 
Properties { 
    _Color("Color", Color) = (0,0,0,1
    _LinesSize("LinesSize", Range(1,10)) = 1 
SubShader { 
    Tags {"IgnoreProjector" = "True" "Queue" = "Overlay"
    Fog { Mode Off } 
    Pass { 
        ZTest Always 
        ZWrite Off 
        Blend SrcAlpha OneMinusSrcAlpha
 
CGPROGRAM
 
#pragma vertex vert 
#pragma fragment frag
#include "UnityCG.cginc"
 
        fixed4 _Color; half _LinesSize;
 
        struct v2f { 
            half4 pos:POSITION; 
            fixed4 sPos:TEXCOORD; 
        };
 
        v2f vert(appdata_base v) {
            v2f o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 
            o.sPos = ComputeScreenPos(o.pos); 
            return o; 
        }
 
        fixed4 frag(v2f i) : COLOR {
            fixed p = i.sPos.y / i.sPos.w;
 
            if((int)(p*_ScreenParams.y/floor(_LinesSize))%2==0) discard;
 
               return _Color; 
         }
 
ENDCG
       }
 
 
}
 


댓글

Designed by JB FACTORY