fix text orientation.

This commit is contained in:
hecomi
2016-11-05 22:56:22 +09:00
parent a3a7754fb0
commit 7774290e71
7 changed files with 35 additions and 35 deletions
@@ -17,18 +17,18 @@ struct v2f
struct Input struct Input
{ {
float2 uv_MainTex; float2 uv_MainTex;
}; };
float2 uddInvertUV(float2 uv) float2 uddInvertUV(float2 uv)
{ {
#ifdef INVERT_X #ifdef INVERT_X
uv.x = 1.0 - uv.x; uv.x = 1.0 - uv.x;
#endif #endif
#ifdef INVERT_Y #ifdef INVERT_Y
uv.y = 1.0 - uv.y; uv.y = 1.0 - uv.y;
#endif #endif
return uv; return uv;
} }
float2 uddRotateUV(float2 uv) float2 uddRotateUV(float2 uv)
@@ -38,14 +38,14 @@ float2 uddRotateUV(float2 uv)
uv.x = tmp.y; uv.x = tmp.y;
uv.y = 1.0 - tmp.x; uv.y = 1.0 - tmp.x;
#elif ROTATE180 #elif ROTATE180
uv.x = 1.0 - uv.x; uv.x = 1.0 - uv.x;
uv.y = 1.0 - uv.y; uv.y = 1.0 - uv.y;
#elif ROTATE270 #elif ROTATE270
float2 tmp = uv; float2 tmp = uv;
uv.x = 1.0 - tmp.y; uv.x = 1.0 - tmp.y;
uv.y = tmp.x; uv.y = tmp.x;
#endif #endif
return uv; return uv;
} }
inline void uddConvertToLinearIfNeeded(inout fixed3 rgb) inline void uddConvertToLinearIfNeeded(inout fixed3 rgb)
@@ -66,19 +66,19 @@ inline fixed4 uddGetCursorTexture(sampler2D tex, float2 uv, fixed4 cursorPosScal
uv.x = (uv.x - cursorPosScale.x) / cursorPosScale.z; uv.x = (uv.x - cursorPosScale.x) / cursorPosScale.z;
uv.y = (uv.y - cursorPosScale.y) / cursorPosScale.w; uv.y = (uv.y - cursorPosScale.y) / cursorPosScale.w;
fixed4 c = tex2D(tex, uv); fixed4 c = tex2D(tex, uv);
fixed a = c.a * step(0, uv.x) * step(0, uv.y) * step(uv.x, 1) * step(uv.y, 1); fixed a = c.a * step(0, uv.x) * step(0, uv.y) * step(uv.x, 1) * step(uv.y, 1);
c *= step(0.01, a); c *= step(0.01, a);
return c; return c;
} }
inline fixed4 uddGetScreenTextureWithCursor(sampler2D screenTex, sampler2D cursorTex, float2 uv, fixed4 cursorPosScale) inline fixed4 uddGetScreenTextureWithCursor(sampler2D screenTex, sampler2D cursorTex, float2 uv, fixed4 cursorPosScale)
{ {
uv = uddInvertUV(uv); uv = uddInvertUV(uv);
fixed4 screen = uddGetScreenTexture(screenTex, uddRotateUV(uv)); fixed4 screen = uddGetScreenTexture(screenTex, uddRotateUV(uv));
fixed4 cursor = uddGetCursorTexture(cursorTex, uv, cursorPosScale); fixed4 cursor = uddGetCursorTexture(cursorTex, uv, cursorPosScale);
fixed4 color = lerp(screen, cursor, cursor.a); fixed4 color = lerp(screen, cursor, cursor.a);
uddConvertToLinearIfNeeded(color.rgb); uddConvertToLinearIfNeeded(color.rgb);
return color; return color;
} }
#endif #endif
@@ -25,12 +25,12 @@ SubShader
#pragma multi_compile ___ VERTICAL #pragma multi_compile ___ VERTICAL
#pragma multi_compile ___ ROTATE90 ROTATE180 ROTATE270 #pragma multi_compile ___ ROTATE90 ROTATE180 ROTATE270
#define SURFACE_SHADER #define SURFACE_SHADER
#include "./uDD_Common.cginc" #include "./uDD_Common.cginc"
#include "./uDD_Params.cginc" #include "./uDD_Params.cginc"
half _Glossiness; half _Glossiness;
half _Metallic; half _Metallic;
void surf(Input IN, inout SurfaceOutputStandard o) void surf(Input IN, inout SurfaceOutputStandard o)
{ {
@@ -6,7 +6,7 @@ Properties
_Color ("Color", Color) = (1, 1, 1, 1) _Color ("Color", Color) = (1, 1, 1, 1)
_MainTex ("Texture", 2D) = "white" {} _MainTex ("Texture", 2D) = "white" {}
[Toggle(USE_BEND)] _UseBend("UseBend", Float) = 0 [Toggle(USE_BEND)] _UseBend("UseBend", Float) = 0
[PowerSlider(10.0)]_Radius ("Radius", Range(3, 100)) = 10 [PowerSlider(10.0)]_Radius ("Radius", Range(3, 100)) = 10
[KeywordEnum(Off, Front, Back)] _Cull("Culling", Int) = 2 [KeywordEnum(Off, Front, Back)] _Cull("Culling", Int) = 2
} }
@@ -28,9 +28,9 @@ v2f vert(appdata v)
{ {
v2f o; v2f o;
#ifdef USE_BEND #ifdef USE_BEND
half a = v.vertex.x / _Radius; half a = v.vertex.x / _Radius;
v.vertex.x = _Radius * sin(a); v.vertex.x = _Radius * sin(a);
v.vertex.y += _Radius * (1 - cos(a)); v.vertex.y += _Radius * (1 - cos(a));
#endif #endif
o.vertex = UnityObjectToClipPos(v.vertex); o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex); o.uv = TRANSFORM_TEX(v.uv, _MainTex);
@@ -39,7 +39,7 @@ v2f vert(appdata v)
fixed4 frag(v2f i) : SV_Target fixed4 frag(v2f i) : SV_Target
{ {
return uddGetScreenTextureWithCursor(_MainTex, _CursorTex, i.uv, _CursorPositionScale); return uddGetScreenTextureWithCursor(_MainTex, _CursorTex, i.uv, _CursorPositionScale);
} }
ENDCG ENDCG
@@ -35,23 +35,23 @@ v2f vert(appdata v)
fixed4 frag(v2f i) : SV_Target fixed4 frag(v2f i) : SV_Target
{ {
fixed4 tex = uddGetScreenTextureWithCursor(_MainTex, _CursorTex, i.uv, _CursorPositionScale); fixed4 tex = uddGetScreenTextureWithCursor(_MainTex, _CursorTex, i.uv, _CursorPositionScale);
fixed alpha = pow((tex.r + tex.g + tex.b) / 3.0, _Mask); fixed alpha = pow((tex.r + tex.g + tex.b) / 3.0, _Mask);
return fixed4(tex.rgb * _Color.rgb, alpha * _Color.a); return fixed4(tex.rgb * _Color.rgb, alpha * _Color.a);
} }
ENDCG ENDCG
Pass Pass
{ {
CGPROGRAM CGPROGRAM
#pragma vertex vert #pragma vertex vert
#pragma fragment frag #pragma fragment frag
#pragma multi_compile ___ INVERT_X #pragma multi_compile ___ INVERT_X
#pragma multi_compile ___ INVERT_Y #pragma multi_compile ___ INVERT_Y
#pragma multi_compile ___ VERTICAL #pragma multi_compile ___ VERTICAL
#pragma multi_compile ___ ROTATE90 ROTATE180 ROTATE270 #pragma multi_compile ___ ROTATE90 ROTATE180 ROTATE270
ENDCG ENDCG
} }
} }
Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB