- Home /
vertex shader moving vertex up in world space
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?
Answer by Auburn · Jul 30, 2016 at 07:45 AM
You need to offset the v.vertex.y instead, do this before it is used.
Your answer

Follow this Question
Related Questions
Shader graph : Convert world position effect to UV position 0 Answers
Vuforia Follow Character In World 0 Answers
world space shader giving me a weird glitch when i running my project 0 Answers
How do I create a dynamicly spaced and UVed brick wall without having multiple material instances? 0 Answers
How to return from shader the indexes of triangles/vertices that was actually rendered? 1 Answer