summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/UMotion/UMotionEditor/Shaders/CameraLit.shader
blob: 6ca491b3c2d5dc9ce9932c2060eb08434101128d (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
Shader "UMotion Editor/Camera Lit"
{ 
    Properties 
    {
		_Color("Main Color (RGB)", color) = (1, 1, 1, 1)
		_WireColor("Wire Color (RGB) Trans (A)", color) = (0, 0, 0, 1)	
		_WireSize("Wire Size", Range(0, 4)) = 0.9
    }

    SubShader 
    {
		Tags { "RenderType" = "Opaque" "IgnoreProjector"="True" }
		LOD 100

		Pass
	    {
            CGPROGRAM 
		    #pragma vertex vert
	    	#pragma fragment frag
			#pragma target 3.0
			
		    #include "UnityCG.cginc"

			fixed4 _Color;
			fixed4 _WireColor;
			half _WireSize;

			struct vInput
			{
				float4 vertex : POSITION;
				half4 texcoord : TEXCOORD0;
				float3 normal : NORMAL;
			};

			struct vOutput
			{
				float4 pos : SV_POSITION;
				fixed3 wirecoord : TEXCOORD1;
				float3 lambert : TEXCOORD2;		
			};

			vOutput vert(vInput i)
			{
				vOutput o;

				o.pos = UnityObjectToClipPos(i.vertex);

				o.wirecoord = fixed3(floor(i.texcoord.x), frac(i.texcoord.x) * 10, i.texcoord.y);

				float3 viewDir = normalize(WorldSpaceViewDir(i.vertex));
				float3 worldNormal = normalize(UnityObjectToWorldNormal(i.normal));
				o.lambert = saturate(dot(viewDir, worldNormal));

				return o;
			}

			fixed4 frag(vOutput i) : SV_Target 
			{
				fixed4 outColor;
				outColor.rgb = i.lambert * _Color;
				outColor.a = 1.0;
				 
				half3 width = abs(ddx(i.wirecoord.xyz)) + abs(ddy(i.wirecoord.xyz));
				half3 smoothed = smoothstep(half3(0, 0, 0), width * _WireSize, i.wirecoord.xyz);		
	  			half wireAlpha = min(min(smoothed.x, smoothed.y), smoothed.z);	
				
				return lerp(lerp(outColor, _WireColor, _WireColor.a), outColor, wireAlpha);
			}

			ENDCG
    	} //Pass
    } //SubShader
} //Shader