Hi, I want to make a shader to bend an object from the pivot point.
The problem is, the shader bellow is working in editor mode but not in play mode.
Help please!
PS. I don’t have any script screwing up the object or the shader.
Shader "Bend" {
Properties {
_MainTex("Texture (RGBA)", 2D) = "white" {}
_Curvature("Curvature", Float) = 1
}
SubShader {
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
LOD 100
Cull Off
Lighting Off
ZWrite Off
Fog {Mode Off}
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
float _Curvature;
struct VS_IN{
float4 vertex : POSITION;
float4 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
struct VS_OUT {
float4 position : SV_POSITION;
fixed4 color : COLOR;
float2 uv : TEXCOORD0;
};
VS_OUT vert (VS_IN input) {
float4 v = input.vertex;
v = float4((v.y * v.y) * -_Curvature, (v.y * v.y) * abs(_Curvature), 0.0f, 0.0f);
VS_OUT result;
result.position = mul(UNITY_MATRIX_MVP, input.vertex + v);
result.uv = TRANSFORM_TEX(input.texcoord, _MainTex);
result.color = input.color;
return result;
}
fixed4 frag (VS_OUT input) : COLOR {
fixed4 color = tex2D(_MainTex, input.uv);
return color * input.color;
}
ENDCG
}
}
}