Hi, I got this basic unlit shader, now I simply want to move up the vertices by one world unit, thats it. Any help is appreciated.
The code below does not work, it moves the tile up by more than 1 unit.
Multiplying by unity_ObjectToWorld or unity_WorldToObject does not change the position at all.
// Upgrade NOTE: replaced ‘_Object2World’ with ‘unity_ObjectToWorld’
// Upgrade NOTE: replaced ‘_World2Object’ with ‘unity_WorldToObject’
// Upgrade NOTE: replaced ‘_Object2World’ with ‘unity_ObjectToWorld’
// Upgrade NOTE: replaced ‘_Object2World’ with ‘unity_ObjectToWorld’
// Upgrade NOTE: replaced ‘_World2Object’ with ‘unity_WorldToObject’
// Upgrade NOTE: replaced ‘_Object2World’ with ‘unity_ObjectToWorld’
Shader “Unlit/CurvatureShader”
{
Properties
{
_MainTex (“Texture”, 2D) = “white” {}
_MapWidth (“Map Width”, Int) = 0
_CamX (“Camera X”, Float) = 0
}
SubShader
{
Tags { “Queue”=“Transparent”
“IgnoreProjector”=“True”
“RenderType”=“Transparent”
“PreviewType”=“Plane”
“CanUseSpriteAtlas”=“True”
}
LOD 100
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Blend One OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include “UnityCG.cginc”
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
float3 worldPos = mul(unity_ObjectToWorld, o.vertex.xyz);
worldPos.y += 1.0;
o.vertex.xyz = mul(unity_WorldToObject, worldPos);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
// apply fog
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
}