@@ -8,10 +8,12 @@ Shader "GUI/InteractionGizmo"
88 _RTColor ( "RT Color" , Color ) = (1 , 0 , 0 , 1 )
99 _Smoothness ( "Smoothness" , Float ) = 1
1010 _IconScales ( "Icon Scales" , Vector ) = (2.23 , 2.23 , 2.23 , 1 )
11+ _Icon ( "Icon" , Vector ) = (0 , 0 , 0 , 0 )
1112
12- [HideInInspector ] _LTRect ( "LT Rect" , Vector ) = (0 , 0 , 0 , 0 )
13- [HideInInspector ] _RTRect ( "RT Rect" , Vector ) = (0 , 0 , 0 , 0 )
14- [HideInInspector ] _BothRect ( "Both Rect" , Vector ) = (0 , 0 , 0 , 0 )
13+ [HideInInspector ] _DialogueRect ( "Dialogue Rect" , Vector ) = (0 , 0 , 0 , 0 )
14+ [HideInInspector ] _SkipRect ( "Skip Rect" , Vector ) = (0 , 0 , 0 , 0 )
15+ [HideInInspector ] _PlayRect ( "Play Rect" , Vector ) = (0 , 0 , 0 , 0 )
16+ [HideInInspector ] _CancelRect ( "Cancel Rect" , Vector ) = (0 , 0 , 0 , 0 )
1517 [HideInInspector ] _AtlasTex ( "Atlas Texture" , 2D ) = "white" {}
1618
1719 [HideInInspector ] _Direction ( "Direction" , Vector ) = (1 , 0 , 0 , 0 )
@@ -66,17 +68,19 @@ Shader "GUI/InteractionGizmo"
6668 };
6769
6870 CBUFFER_START (UnityPerMaterial)
69- float4 _Color;
70- float4 _LTColor;
71- float4 _RTColor;
72- float4 _MidColor;
73- float _Smoothness;
74- float4 _IconScales;
75- float4 _LTRect;
76- float4 _RTRect;
77- float4 _BothRect;
78- sampler2D _AtlasTex;
79- float4 _AtlasTex_TexelSize;
71+ float4 _Color;
72+ float4 _LTColor;
73+ float4 _RTColor;
74+ float4 _MidColor;
75+ float _Smoothness;
76+ float4 _IconScales;
77+ float4 _DialogueRect;
78+ float4 _SkipRect;
79+ float4 _PlayRect;
80+ float4 _CancelRect;
81+ float4 _Icon;
82+ sampler2D _AtlasTex;
83+ float4 _AtlasTex_TexelSize;
8084 CBUFFER_END
8185
8286 float4 _State;
@@ -90,8 +94,8 @@ Shader "GUI/InteractionGizmo"
9094 inline float fromTo (const float smoothness, const float distance, const float from, const float to)
9195 {
9296 return
93- smoothstep (from, from - smoothness, distance) *
94- smoothstep (to - smoothness, to, distance);
97+ smoothstep (from + smoothness , from - smoothness, distance) *
98+ smoothstep (to - smoothness, to + smoothness , distance);
9599 }
96100
97101 inline float get2DClipping (in float2 position, in float4 clipRect)
@@ -109,7 +113,8 @@ Shader "GUI/InteractionGizmo"
109113
110114 float iconSDF (const float2 uv, const float4 rect, const float scale)
111115 {
112- const float2 iconUV = (uv - 0.5 ) * scale + 0.5 ;
116+ const float ratio = rect.z / rect.w;
117+ const float2 iconUV = (uv - 0.5 ) * scale * float2 (1 / ratio, 1 ) + 0.5 ;
113118 float distance = tex2D (_AtlasTex, iconUV * rect.zw + rect.xy).a;
114119 distance *= get2DClipping (iconUV, float4 (0 , 0 , 1 , 1 ));
115120 distance = (0.5 - distance) / scale / 3.0 ;
@@ -121,7 +126,7 @@ Shader "GUI/InteractionGizmo"
121126 UNITY_SETUP_INSTANCE_ID (input);
122127 Varyings output;
123128
124- const float scale = lerp (1 , 0.58333333333333 , _State.x);
129+ const float scale = 0.5 + lerp (1 , 0.58333333333333 , _State.x);
125130 const float4 positionOS = input.positionOS * scale;
126131 output.positionOS = positionOS;
127132 output.positionCS = TransformObjectToHClip (positionOS);
@@ -153,15 +158,20 @@ Shader "GUI/InteractionGizmo"
153158 half4 playerColor = lerp (_LTColor, _MidColor, saturate (colorDot * 2 ));
154159 playerColor = lerp (playerColor, _RTColor, saturate (colorDot * 2 - 1 ));
155160 playerColor = lerp (_Color, playerColor, playerPresence);
156- half4 color = fromTo (smoothness, circleDistance, strokeOffset, strokeOffset - 8 / 96.0 ) * playerColor;
161+ half4 color = fromTo (smoothness, circleDistance, strokeOffset, strokeOffset - 7 / 96.0 ) * playerColor;
157162
158163 float4 iconScales = _IconScales / lerp (1 , 0.5833333 , saturate (expansion));
159- float bothIconDistance = iconSDF (input.uv, _BothRect, iconScales.z);
160-
161- float iconDistance = bothIconDistance;
164+ float4 icons = float4 (
165+ iconSDF (input.uv, _DialogueRect, iconScales.x),
166+ iconSDF (input.uv, _PlayRect, iconScales.y),
167+ iconSDF (input.uv, _SkipRect, iconScales.z),
168+ iconSDF (input.uv, _CancelRect, iconScales.w)
169+ );
170+
171+ float iconDistance = dot (icons, _Icon) / dot (_Icon, float4 (1 , 1 , 1 , 1 ));
162172 float innerCircle = circleDistance - (1 - 0.58333333333333 ) * -0.5 + (16 / 96.0 );
163173 iconDistance = lerp (iconDistance, innerCircle, saturate (expansion * 1.25 ));
164- color += _Color * smoothstep (0 , -smoothness, iconDistance);
174+ color += _Color * smoothstep (smoothness , -smoothness, iconDistance);
165175 color *= opacity;
166176
167177 return color;
0 commit comments