summaryrefslogtreecommitdiff
path: root/Assets/Art/Shaders/Effects/RimLight 1.shader
blob: bcf6609c6d78654cbec5bfc345e34fffac803080 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "ASESampleShaders/RimLight"
{
	Properties
	{
		// Color property for material inspector, default to white
		_Color("Main Color", Color) = (1,1,1,1)
		_Intensity("Intensity", range(0,10)) = 1

		_MKGlowPower("Emission Power", range(0,10)) = 0

		_MKGlowColor("Emission Color", color) = (1.0,0.95,0.8,1.0)

		_StencilMask("Mask Layer", Range(0, 255)) = 1
		[Enum(CompareFunction)] _StencilComp("Mask Mode", Int) = 6

        _Albedo("Albedo", 2D) = "white" {}
        _CutOff("Alpha CutOff", Float) = 0.5
	}
		SubShader
	{
		//Tags{ "Queue" = "AlphaTest" "IgnoreProjector" = "False" "RenderType" = "Transparent" "RenderType" = "MKGlow" }
		Stencil
		{
			Ref 255
			ReadMask[_StencilMask]
			Comp[_StencilComp]
		}

	//Pass
	//{
	//	ZWrite On
	//	//ZTest LEqual
	//	ColorMask 0
	//}
	
		Tags{ "Queue" = "AlphaTest-1" "IgnoreProjector" = "False" "RenderType" = "Transparent" "RenderType" = "MKGlow" }
		Pass
	{
		Cull Front
		ZTest LEqual
		ZWrite Off
		Blend One OneMinusSrcAlpha
		CGPROGRAM
#pragma vertex vert
#pragma fragment frag

        struct appdata
        {
            float4 vertex : POSITION;
            float2 uv : TEXCOORD0;
        };


        struct v2f
        {
            float2 uv : TEXCOORD0;
            float4 vertex : SV_POSITION;
        };

		// vertex shader
		// this time instead of using "appdata" struct, just spell inputs manually,
		// and instead of returning v2f struct, also just return a single output
		// float4 clip position
		v2f vert(appdata i)
	{
        v2f o;
        o.vertex = UnityObjectToClipPos(i.vertex);
        o.uv = i.uv; 
		return o;
	}

		// color from the material
	fixed4 _Color;
	float _Intensity;
	fixed4 _MKGlowColor;
	float	_MKGlowPower;

	sampler2D _Albedo;
    float _CutOff;

	// pixel shader, no inputs needed
	fixed4 frag(v2f i) : SV_Target
	{ 
		//_Color.rgb *= _Intensity;
		//_Color.rgb *= _Color.a;

		//_Color.rgb *= _Intensity;
		//_Color *= _Intensity;
		//_MKGlowColor = _Color;
		//_MKGlowPower = _Intensity;

        float alpha = tex2D(_Albedo, i.uv);
        if(alpha <= _CutOff) 
            discard;
        _Color.rgb *= _Intensity;
		return _Color; // just return it
	}
		ENDCG
	}
	}
}