Hi everyone,

I am trying to tackle shaders and I want to create a simple “swing in the wind” shader for my foliage. Basically I want to transform the vertices with a sin() depending on their height in the object, to give them the swinging motion. This works fine already, but during the matrix calculations I seem to be scaling the object twice, and I have no idea why.

This is my vertex shader function.

```
void vert (inout appdata_full v) {
float4 wpos = mul( _Object2World, v.vertex);
float4 opos = mul( _Object2World, float4(0,0,0,1) );
float phase = _Time * 25.0 + opos.x * 0.6 + opos.z * 0.05 ;
wpos.x = wpos.x + sin(phase) * wpos.y * _Bend;
v.vertex = mul(_World2Object, wpos);
}
```

I use the object position to determine the phase so that the whole objects swings in unison. I also make the calculations in world space so that the rotation of the object does not affect the swing direction.

The problem I have is this:

The mushroom is scaled inside the editor to 0.3, 0.3, 0.3. The desired position is shown by the wireframe which appears when I select the object. But the shader seems to apply the scaling again, making the object to small. Is there a way to fix this?

Thanks for your help.