Question by
slole · Jul 01, 2017 at 01:06 PM ·
spritevertex shader
Increase vertices number in sprite
I would simply want to split my simple cube sprite with a higher number of vertices so that I can create a warping effect with a vertex shader. I have allredy written the vertex shader but it produces a rateher linear result due to the fact that there are only 4 vertices on my sprite.
the shader:
v2f vert(appdata_t IN)
{
v2f OUT;
UNITY_SETUP_INSTANCE_ID(IN);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
float3 worldPos = mul(unity_ObjectToWorld, IN.vertex).xyz;
OUT.vertex = UnityObjectToClipPos(IN.vertex + (IN.vertex * (sin(abs(worldPos.x / 2)) * 2 - 1) * 0.4f * (1 / (pow(worldPos.x, 2) + 1))) + float4((cos(abs(worldPos.x) / 2) * 3 + 1) * 0.4f * worldPos.x * (1 / (pow(worldPos.x, 2) + 1)), 0, 0, 0));
//OUT.vertex = UnityObjectToClipPos(IN.vertex);
OUT.texcoord = IN.texcoord;
OUT.color = IN.color * _Color;
#ifdef PIXELSNAP_ON
OUT.vertex = UnityPixelSnap(OUT.vertex);
#endif
return OUT;
}
Comment
Your answer
Follow this Question
Related Questions
GrabPass for local distortion effect problem 0 Answers
How can I make Image border not change a size? 1 Answer
Creating a 2D Maze 0 Answers
Rebuild Roguelike with other sprite sheet size 1 Answer
Sprite sheet and animation slice doubt 0 Answers