So I'm making a vertex shader to make a GameObject look like it's shrinking/expanding (pulsating?) continuously.
I am using a normal scale matrix to multiply the position of every vertex, but I want to keep the object appearing centered in the same position. If I could get the transform.position of the gameObject that is being rendered, I know I would be able to keep the center position the same.
So how would I access the gameobject's position in my CG shader?
Or am I approaching this problem incorrectly?
vertexOut vert(vertexIn v)
{
vertexOut o;
o.pos = mul(UNITY_MATRIX_MVP,v.vertex);
o.pos2 = mul(UNITY_MATRIX_MVP,v.vertex);
float scaleVal = sin(_Time.y*10)/8 + 1.0;
float4x4 scaleMat = float4x4(
scaleVal, 0, 0, 0,
0, scaleVal, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
o.pos = mul(scaleMat,o.pos);
return o;
}