Hi,
I've written a simple *curved* unlit shader in HLSL that basically translates each vertex based on the distance to the camera (the magic happens in the vertex shader):
Properties
{
_BendFactor ("Bend Factor", Vector) = (0, 0, 0, 0)
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Lighting Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv_tex1 : TEXCOORD0;
};
struct v2f
{
float2 uv_tex1 : TEXCOORD0;
float4 vertex : SV_POSITION;
};
fixed4 _BendFactor;
fixed4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
// here I calculate the offset
fixed4 offset = mul( unity_ObjectToWorld, v.vertex );
offset.xyz -= _WorldSpaceCameraPos.xyz;
offset =_BendFactor * (offset.z * offset.z);
o.vertex = UnityObjectToClipPos ( v.vertex) + offset ;
o.uv_tex1 = TRANSFORM_TEX(v.uv_tex1, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return tex2D(_MainTex, i.uv_tex1) * _Color;
}
ENDCG
}
}
It worked perfectly in Unity 5.5, but I just updated to 5.6 and now I get different results in Editor vs Android device. On the Y axis, I get opposite translations:
Editor:
![alt text][1]
Huawei P9 plus:
![alt text][2]
Does anyone know what could be the issue here?
Thank you in advance!
[1]: /storage/temp/95003-1.png
[2]: /storage/temp/95005-3.png
↧