I’m trying to move a vertex up and down with noise, simulating random water ripples.
The water does that fine when I’m looking at it from a side view, however the water moves north/south when looking at it from above. The vertices are moving up and down from the cameras point of view, I want it to always be moving up and down on the world’s view of up.
v2f vert (appdata v)
{
v2f o;
float4 offset = float4(
tex2Dlod(_NoiseTex, float4(v.vertex.z / 16 + v.vertex.z / 16 + _Time[1] / 20, 0, 0, 0)).r,
0,
0,
0
);
o.worldPosition = mul(_Object2World, v.vertex);
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.vertex.y += offset;
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
I’m not sure where I can get the world’s orientation rather than the camera’s.
http://image.prntscr.com/image/2f8587948c7244d4b063f2cca3b9512d.png
http://image.prntscr.com/image/9ab905560685457fb3982e76c68b4260.png
How do I change my code to move the vertices in ONLY the up and down directions of the WORLD’s orientation and NOT the camera?