|
1 | 1 | Shader "Daggerfall/GhostShader" { |
2 | | - Properties { |
| 2 | + Properties { |
3 | 3 | _Color("Color", Color) = (1,1,1,1) |
4 | | - _MainTex ("Albedo (RGB)", 2D) = "white" {} |
| 4 | + _MainTex ("Albedo (RGB)", 2D) = "white" {} |
5 | 5 | _BumpMap ("Bumpmap", 2D) = "bump" {} |
6 | 6 | _EmissionMap("Emission Map", 2D) = "white" {} |
7 | 7 | _EmissionColor("Emission Color", Color) = (1,1,1) |
8 | 8 | _Cutoff ("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 |
9 | | - _Glossiness ("Smoothness", Range(0.0, 1.0)) = 0.0 |
10 | | - _Metallic ("Metallic", Range(0.0, 1.0)) = 0.0 |
11 | | - } |
12 | | - SubShader { |
13 | | - Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } |
14 | | - LOD 200 |
| 9 | + _Glossiness ("Smoothness", Range(0.0, 1.0)) = 0.0 |
| 10 | + _Metallic ("Metallic", Range(0.0, 1.0)) = 0.0 |
| 11 | + } |
15 | 12 |
|
16 | | - CGPROGRAM |
17 | | - // Physically based Standard lighting model |
18 | | - #pragma surface surf Standard alpha:blend |
19 | | - |
20 | | - // Use shader model 3.0 target, to get nicer looking lighting |
21 | | - #pragma target 3.0 |
| 13 | + // 1) SM3.0 / GLES3+ variant |
| 14 | + SubShader { |
| 15 | + Tags { "Queue"="Transparent" "RenderType"="Transparent" } |
| 16 | + CGPROGRAM |
| 17 | + #pragma surface surf Standard alpha:blend |
| 18 | + #pragma target 3.0 |
22 | 19 |
|
23 | 20 | half4 _Color; |
24 | | - sampler2D _MainTex; |
25 | | - sampler2D _BumpMap; |
26 | | - sampler2D _EmissionMap; |
| 21 | + sampler2D _MainTex, _BumpMap, _EmissionMap; |
27 | 22 | half4 _EmissionColor; |
28 | | - |
29 | | - struct Input { |
30 | | - float2 uv_MainTex; |
| 23 | + half _Cutoff, _Glossiness, _Metallic; |
| 24 | + |
| 25 | + struct Input { |
| 26 | + float2 uv_MainTex; |
31 | 27 | float2 uv_BumpMap; |
32 | 28 | float2 uv_EmissionMap; |
33 | | - }; |
34 | | - |
35 | | - half _Cutoff; |
36 | | - half _Glossiness; |
37 | | - half _Metallic; |
38 | | - |
39 | | - void surf (Input IN, inout SurfaceOutputStandard o) { |
40 | | - // Albedo comes from a texture tinted by color |
41 | | - fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; |
42 | | - clip (c.a - _Cutoff); |
43 | | - |
| 29 | + }; |
| 30 | + |
| 31 | + void surf (Input IN, inout SurfaceOutputStandard o) { |
| 32 | + fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; |
| 33 | + clip(c.a - _Cutoff); |
| 34 | + |
44 | 35 | half3 emission = tex2D(_EmissionMap, IN.uv_EmissionMap).rgb * _EmissionColor; |
45 | | - o.Albedo = c.rgb - emission; // Emission cancels out other lights |
46 | | - o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap)); |
| 36 | + o.Albedo = c.rgb - emission; |
| 37 | + o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); |
47 | 38 | o.Emission = emission; |
48 | | - // Metallic and smoothness come from slider variables |
49 | | - o.Metallic = _Metallic; |
50 | | - o.Smoothness = _Glossiness; |
51 | | - // Transparency comes from albedo alpha - allows parts some parts of image to be transparent (e.g. body) and other parts opaque (e.g. eyes) |
52 | | - o.Alpha = c.a; |
53 | | - } |
54 | | - ENDCG |
55 | | - } |
56 | | - FallBack "Diffuse" |
| 39 | + o.Metallic = _Metallic; |
| 40 | + o.Smoothness = _Glossiness; |
| 41 | + o.Alpha = c.a; |
| 42 | + } |
| 43 | + ENDCG |
| 44 | + } |
| 45 | + |
| 46 | + // 2) SM2.0 / GLES2 fallback |
| 47 | + SubShader { |
| 48 | + Tags { "Queue"="Transparent" "RenderType"="Transparent" } |
| 49 | + CGPROGRAM |
| 50 | + #pragma surface surf Lambert alpha:blend // use a simpler lighting model |
| 51 | + #pragma target 2.0 |
| 52 | + |
| 53 | + half4 _Color; |
| 54 | + sampler2D _MainTex, _BumpMap, _EmissionMap; |
| 55 | + half4 _EmissionColor; |
| 56 | + half _Cutoff; |
| 57 | + |
| 58 | + struct Input { |
| 59 | + float2 uv_MainTex; |
| 60 | + float2 uv_BumpMap; |
| 61 | + float2 uv_EmissionMap; |
| 62 | + }; |
| 63 | + |
| 64 | + void surf (Input IN, inout SurfaceOutput o) { |
| 65 | + fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; |
| 66 | + clip(c.a - _Cutoff); |
| 67 | + |
| 68 | + o.Albedo = c.rgb; |
| 69 | + o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); |
| 70 | + o.Emission = tex2D(_EmissionMap, IN.uv_EmissionMap).rgb * _EmissionColor.rgb; |
| 71 | + o.Alpha = c.a; |
| 72 | + } |
| 73 | + ENDCG |
| 74 | + } |
| 75 | + |
| 76 | + FallBack "Diffuse" |
57 | 77 | } |
0 commit comments