I'm rather new to shaderlab with unity. I am trying to distort the vertices so that they are push backwards and towards the camera almost like looking at the camera from a 45 degree angle. I am replicating an effect from a game for fun. This is the code used for the effect
ive tried implenting the code into a shader script like so:
float4 vert(appdata v){
float3 position = mul(unity_ObjectToWorld, v.vertex).xyz;
float y = position.y;
float z = position.x;
float3 parentTranslation = ParentMatrix._m30_m31_m32;
position -= parentTranslation;
position.z += AlternateLayeringScale;
position.z -= y;
position.y += position.z;
position += parentTranslation + float3(0,parentTranslation.z,0);
return position;
}
however i get an error stating it cannot convert from float3 to float4, i am not sure how it was implemented
The fourth part is 'w' also called the inverse stretching factor. To convert from vec4 to vec3 it's best to do position.xyz / position.w
and to put it back in a vec4 you can write return fixed4(position, 1)