|
| 1 | +Shader "Gothic/UI" |
| 2 | +{ |
| 3 | + Properties |
| 4 | + { |
| 5 | + [MainTexture] _BaseMap("Texture", 2D) = "white" {} |
| 6 | + [MainColor] _BaseColor("Color", Color) = (1,1,1,1) |
| 7 | + |
| 8 | + // Obsolete properties for backward compatibility |
| 9 | + [HideInInspector] _MainTex("Base Map", 2D) = "white" {} |
| 10 | + [HideInInspector] _Color("Base Color", Color) = (1,1,1,1) |
| 11 | + |
| 12 | + // Blending state — driven by MaterialExtension methods |
| 13 | + // Defaults match ToOpaqueMode() behavior |
| 14 | + [HideInInspector] _SrcBlend("Src Blend", Float) = 1 |
| 15 | + [HideInInspector] _DstBlend("Dst Blend", Float) = 0 |
| 16 | + [HideInInspector] _ZWrite("Z Write", Float) = 1 |
| 17 | + [HideInInspector] _Cull("Cull", Float) = 0 |
| 18 | + |
| 19 | + // Alpha cutoff |
| 20 | + _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 |
| 21 | + } |
| 22 | + |
| 23 | + SubShader |
| 24 | + { |
| 25 | + Tags |
| 26 | + { |
| 27 | + "RenderType" = "Opaque" |
| 28 | + "Queue" = "Geometry" |
| 29 | + "RenderPipeline" = "UniversalPipeline" |
| 30 | + "IgnoreProjector" = "True" |
| 31 | + } |
| 32 | + |
| 33 | + Blend [_SrcBlend] [_DstBlend] |
| 34 | + ZWrite [_ZWrite] |
| 35 | + Cull [_Cull] |
| 36 | + |
| 37 | + Pass |
| 38 | + { |
| 39 | + Name "Default" |
| 40 | + Tags { "LightMode" = "SRPDefaultUnlit" } |
| 41 | + |
| 42 | + HLSLPROGRAM |
| 43 | + #pragma vertex vert |
| 44 | + #pragma fragment frag |
| 45 | + #pragma target 2.0 |
| 46 | + |
| 47 | + #pragma shader_feature_local_fragment _ALPHATEST_ON |
| 48 | + |
| 49 | + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" |
| 50 | + |
| 51 | + struct Attributes |
| 52 | + { |
| 53 | + float4 positionOS : POSITION; |
| 54 | + float2 uv : TEXCOORD0; |
| 55 | + float4 color : COLOR; |
| 56 | + UNITY_VERTEX_INPUT_INSTANCE_ID |
| 57 | + }; |
| 58 | + |
| 59 | + struct Varyings |
| 60 | + { |
| 61 | + float4 positionCS : SV_POSITION; |
| 62 | + float2 uv : TEXCOORD0; |
| 63 | + float4 color : COLOR; |
| 64 | + UNITY_VERTEX_OUTPUT_STEREO |
| 65 | + }; |
| 66 | + |
| 67 | + TEXTURE2D(_BaseMap); |
| 68 | + SAMPLER(sampler_BaseMap); |
| 69 | + float4 _BaseMap_ST; |
| 70 | + half4 _BaseColor; |
| 71 | + half _Cutoff; |
| 72 | + |
| 73 | + // Alias for backward compatibility with code that sets _MainTex |
| 74 | + #define _MainTex _BaseMap |
| 75 | + #define _Color _BaseColor |
| 76 | + |
| 77 | + Varyings vert(Attributes input) |
| 78 | + { |
| 79 | + Varyings output; |
| 80 | + UNITY_SETUP_INSTANCE_ID(input); |
| 81 | + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); |
| 82 | + |
| 83 | + output.positionCS = TransformObjectToHClip(input.positionOS.xyz); |
| 84 | + output.uv = TRANSFORM_TEX(input.uv, _BaseMap); |
| 85 | + output.color = input.color * _BaseColor; |
| 86 | + return output; |
| 87 | + } |
| 88 | + |
| 89 | + half4 frag(Varyings input) : SV_Target |
| 90 | + { |
| 91 | + half4 texColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv); |
| 92 | + half4 color = texColor * input.color; |
| 93 | + |
| 94 | + #if defined(_ALPHATEST_ON) |
| 95 | + clip(color.a - _Cutoff); |
| 96 | + #endif |
| 97 | + |
| 98 | + return color; |
| 99 | + } |
| 100 | + ENDHLSL |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + FallBack "Hidden/Universal Render Pipeline/FallbackError" |
| 105 | +} |
0 commit comments