|
1 | | -// Upgrade NOTE: replaced 'UNITY_INSTANCE_ID' with 'UNITY_VERTEX_INPUT_INSTANCE_ID' |
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. See LICENSE in the project root for license information. |
2 | 3 |
|
| 4 | +/// |
| 5 | +/// Basic 3D Text shader with proper z-shorting |
| 6 | +/// |
3 | 7 | Shader "HoloToolkit/3DTextShader" |
4 | 8 | { |
5 | 9 | Properties |
@@ -48,59 +52,59 @@ Shader "HoloToolkit/3DTextShader" |
48 | 52 | Pass |
49 | 53 | { |
50 | 54 | CGPROGRAM |
51 | | - #pragma vertex vert |
52 | | - #pragma fragment frag |
53 | | - #pragma multi_compile_instancing |
54 | | - #include "UnityCG.cginc" |
| 55 | + #pragma vertex vert |
| 56 | + #pragma fragment frag |
| 57 | + #pragma multi_compile_instancing |
| 58 | + #include "UnityCG.cginc" |
55 | 59 |
|
56 | | - struct appdata_t |
57 | | - { |
58 | | - float4 vertex : POSITION; |
59 | | - half4 color : COLOR; |
60 | | - float2 texcoord : TEXCOORD0; |
61 | | - UNITY_VERTEX_INPUT_INSTANCE_ID |
62 | | - }; |
| 60 | + struct appdata_t |
| 61 | + { |
| 62 | + float4 vertex : POSITION; |
| 63 | + half4 color : COLOR; |
| 64 | + float2 texcoord : TEXCOORD0; |
| 65 | + UNITY_VERTEX_INPUT_INSTANCE_ID |
| 66 | + }; |
63 | 67 |
|
64 | | - struct v2f |
65 | | - { |
66 | | - float4 vertex : POSITION; |
67 | | - half4 color : COLOR; |
68 | | - float2 texcoord : TEXCOORD0; |
69 | | - UNITY_VERTEX_INPUT_INSTANCE_ID |
70 | | - UNITY_VERTEX_OUTPUT_STEREO |
| 68 | + struct v2f |
| 69 | + { |
| 70 | + float4 vertex : POSITION; |
| 71 | + half4 color : COLOR; |
| 72 | + float2 texcoord : TEXCOORD0; |
| 73 | + UNITY_VERTEX_INPUT_INSTANCE_ID |
| 74 | + UNITY_VERTEX_OUTPUT_STEREO |
71 | 75 |
|
72 | | - }; |
| 76 | + }; |
73 | 77 |
|
74 | | - sampler2D _MainTex; |
75 | | - float4 _MainTex_ST; |
76 | | - UNITY_INSTANCING_CBUFFER_START(Props) |
77 | | - UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color) |
78 | | - UNITY_INSTANCING_CBUFFER_END |
| 78 | + sampler2D _MainTex; |
| 79 | + float4 _MainTex_ST; |
| 80 | + UNITY_INSTANCING_CBUFFER_START(Props) |
| 81 | + UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color) |
| 82 | + UNITY_INSTANCING_CBUFFER_END |
79 | 83 |
|
80 | | - v2f vert (appdata_t v) |
81 | | - { |
82 | | - v2f o; |
83 | | - UNITY_SETUP_INSTANCE_ID(v); |
84 | | - UNITY_TRANSFER_INSTANCE_ID(v, o); |
85 | | - UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); |
86 | | - o.vertex = UnityObjectToClipPos(v.vertex); |
87 | | - o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); |
88 | | - o.color = v.color; |
89 | | - #ifdef UNITY_HALF_TEXEL_OFFSET |
90 | | - o.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1); |
91 | | - #endif |
92 | | - return o; |
93 | | - } |
| 84 | + v2f vert (appdata_t v) |
| 85 | + { |
| 86 | + v2f o; |
| 87 | + UNITY_SETUP_INSTANCE_ID(v); |
| 88 | + UNITY_TRANSFER_INSTANCE_ID(v, o); |
| 89 | + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); |
| 90 | + o.vertex = UnityObjectToClipPos(v.vertex); |
| 91 | + o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); |
| 92 | + o.color = v.color; |
| 93 | + #ifdef UNITY_HALF_TEXEL_OFFSET |
| 94 | + o.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1); |
| 95 | + #endif |
| 96 | + return o; |
| 97 | + } |
94 | 98 |
|
95 | | - half4 frag (v2f i) : COLOR |
96 | | - { |
97 | | - UNITY_SETUP_INSTANCE_ID(i); |
98 | | - half4 col = i.color; |
99 | | - col.a *= tex2D(_MainTex, i.texcoord).a; |
100 | | - col = col * UNITY_ACCESS_INSTANCED_PROP(_Color); |
101 | | - clip (col.a - 0.01); |
102 | | - return col; |
103 | | - } |
| 99 | + half4 frag (v2f i) : COLOR |
| 100 | + { |
| 101 | + UNITY_SETUP_INSTANCE_ID(i); |
| 102 | + half4 col = i.color; |
| 103 | + col.a *= tex2D(_MainTex, i.texcoord).a; |
| 104 | + col = col * UNITY_ACCESS_INSTANCED_PROP(_Color); |
| 105 | + clip (col.a - 0.01); |
| 106 | + return col; |
| 107 | + } |
104 | 108 | ENDCG |
105 | 109 | } |
106 | 110 | } |
|
0 commit comments