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, thanks for the reply! Sorry I was vague. What I'm hoping to achieve is to modify a flat plane so that the vertices will move up and/or down in the y axis, giving it an uneven surface. I am just using this: // Vertex modifier void vert (inout appdata_full v) { v.vertex.y += _Amount; } where _Amount will be the random value generated. With the function you provided, what float2 input should it take? Thanks a lot!
Unless you want complete randomness you should probably use some kind of noise function such as perlin noise. But for optimization purposes you should probably just use a texture as a heightmap to offset your verts!
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…
Hey, thanks for the reply! Sorry I was vague. What I'm hoping to achieve is to modify a flat plane so that the vertices will move up and/or down in the y axis, giving it an uneven surface. I am just using this: // Vertex modifier void vert (inout appdata_full v) { v.vertex.y += _Amount; } where _Amount will be the random value generated. With the function you provided, what float2 input should it take? Thanks a lot!
– batchUnless you want complete randomness you should probably use some kind of noise function such as perlin noise. But for optimization purposes you should probably just use a texture as a heightmap to offset your verts!
– SimonTS