I have a problem with a shader regarding the origin position in model space.

I want to scale an object in the world z axis (world space), so it looks “squashed” in the same plane orientation no matter which rotation the object has. To do that, I convert the point (0,0,0) from model space to world space, and scale its z related to that point.

The problem is that the object has its pivot point in its base, so rotation is done from its base, but the scale is applied as if the origin I converted to world space is the object’s centroid, so when I rotate it, it displaces in z axis.

Shouldn’t be model space’s origin the object’s pivot? If this is not like this, is there any way to get the object’s pivot inside the shader, without passing it as an external variable?

Thanks in advance!

Here is the vertex shader: (only vertex, since it’s the only thing relevant)

```
v2f vert (appdata_base v)
{
v2f out;
float4 lOriginWorld = mul(_Object2World, float4(0,0,0,1));
out.pos = mul (_Object2World, v.vertex);
float3 lDistance = out.pos - lOriginWorld;
out.pos.x = lOriginWorld.x + lDistance.x;
out.pos.y = lOriginWorld.y + lDistance.y;
out.pos.z = lOriginWorld.z + lDistance.z * 0.05;
out.pos = mul(UNITY_MATRIX_VP, out.pos);
return out;
}
```