How to move vertices up/down randomly in shader.

Hello!

I have a plane and I’d like to adjust the y positions of the vertices in the shader.
Actually moving them is simple enough, but I was wondering what the best way of getting the random values for heights was?

Would I need a random function inside the shader to get a value within a range?

Thanks

Hey bud, Are you trying to scroll your texture with the shader or something like that ?
You would be looking to do this in the Surf shader function

You could call to the _Time property and multiply it by a set of values based on the x and y you set it. yo could then effect them with random values passed into the vars holding the x and y values.
I could go on.
the code would look similar to this…

fixed yScrollValue = _ScrollYSpeed * _Time;

you might make _ScrollYSpeed an accessible parameter in the inspector for the shader allowing you to adjust/tweak it visually afterwards.

You could be looking for a a small function to run on a float in your code like so…

float randomNum(in float2 uv)

    float2 noise = (frac(sin(dot(uv ,float2(12.9898,78.233)*2.0)) * 43758.5453));
    return abs(noise.x + noise.y) * 0.5;
}

but without your code, who knows ?
Then again, who even knows, if you are using Unitys shader language, Cg, HLSL ?

So… Could you possibly add in your shader code please, so we can get to the bottom of it faster for you.

Hope that helps some
Take care Bud
Gruffy