Projekt

Obecné

Profil

Stáhnout (1.63 KB) Statistiky
| Větev: | Tag: | Revize:
1
Shader "Unlit/Grayscale"
2
{
3
    Properties
4
    {
5
        _MainTex ("Texture", 2D) = "white" {}
6
        _Min("Min", Range(0.0, 1.0)) = 0.0
7
        _Max("Max", Range(0.0, 1.0)) = 0.25
8
        _Color("Color", Color) = (0,0,0,0)
9

    
10
    }
11
    SubShader
12
    {
13
        Tags { "RenderType"="Opaque" }
14
        LOD 100
15

    
16
        Pass
17
        {
18
            CGPROGRAM
19
            #pragma vertex vert
20
            #pragma fragment frag
21
            // make fog work
22
            #pragma multi_compile_fog
23

    
24
            #include "UnityCG.cginc"
25

    
26
            struct appdata
27
            {
28
                float4 vertex : POSITION;
29
                float2 uv : TEXCOORD0;
30
            };
31

    
32
            struct v2f
33
            {
34
                float2 uv : TEXCOORD0;
35
                UNITY_FOG_COORDS(1)
36
                float4 vertex : SV_POSITION;
37
            };
38

    
39
            sampler2D _MainTex;
40
            float4 _MainTex_ST;
41
            float _Min;
42
            float _Max;
43
            float4 _Color;
44

    
45
            v2f vert (appdata v)
46
            {
47
                v2f o;
48
                o.vertex = UnityObjectToClipPos(v.vertex);
49
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
50
                UNITY_TRANSFER_FOG(o,o.vertex);
51
                return o;
52
            }
53

    
54
            fixed4 frag (v2f i) : SV_Target
55
            {
56
                // sample the texture
57
                fixed4 col = tex2D(_MainTex, i.uv);
58
                float bw = (0.3f * col.r) + (0.59f * col.g) + (0.11f * col.b);
59
                bw *= col.a;
60

    
61
                float res = _Min + (_Max - _Min) * bw;
62

    
63
                return 1 - fixed4(res, res, res, 1);
64
            }
65
            ENDCG
66
        }
67
    }
68
}
(15-15/20)