I want to achieve a ripple effect on a procedurally generated mesh: distort it’s z coordinate so that the mesh kind of floats like a wave in a random manner.
To do that I’m generating a heightmap using a Perlin noise, feeding it into a vertex shader and smoothly (via time uniform parameter) interpolating to the sampled height. But when the interpolation is complete, I need to change a heightmap (to achieve randomness of a ripple), doing that flickers the mesh, that is, a transition is not smooth. How do I smooth it out? The mesh in VBO is just a plain triangulated surface with the constant z-coordinate.
My current vertex shader in glsl es:
One would normally won’t do any animation with the Vertex Shader.
I will advise you to have a look at Geometry Shaders. They are more meant to do change on the geometry. GS are however known not to be that fast. And people here and there tend to say they are not really useful anymore (but for one or two specific uses…).
So you can have a look at the Tesselation Shaders. They allow another way to do that, but a bit less simply. They also require a more recent hardware than GS.
[QUOTE=Silence;1283691]One would normally won’t do any animation with the Vertex Shader.
I will advise you to have a look at Geometry Shaders. They are more meant to do change on the geometry. GS are however known not to be that fast. And people here and there tend to say they are not really useful anymore (but for one or two specific uses…).
So you can have a look at the Tesselation Shaders. They allow another way to do that, but a bit less simply. They also require a more recent hardware than GS.[/QUOTE]
I don’t have any of that since I’m using WebGL 1.0
That’s wrong. The vertex shader is where you’d normally do animation.
I’d advise you to ignore geometry shaders. There’s a fairly significant performance hit for using one, and they’re only useful if you need to either change the type or number of primitives, or perform calculations which involve all of a primitive’s vertices (a vertex shader sees each vertex in isolation).
[QUOTE=Silence;1283691]So you can have a look at the Tesselation Shaders.
[/QUOTE]
Tessellation shaders aren’t useful here either.
So interpolate between height maps. The mesh’s vertices probably shouldn’t even have a Z coordinate (i.e. the Z value at t=0 should come from the first height map). Between t=0 and t=1 you’d interpolate between the first and second height maps; between t=1 and t=2 you’d interpolate between the second and third height maps, etc.
[QUOTE=GClements;1283704]That’s wrong. The vertex shader is where you’d normally do animation.
I’d advise you to ignore geometry shaders. There’s a fairly significant performance hit for using one, and they’re only useful if you need to either change the type or number of primitives, or perform calculations which involve all of a primitive’s vertices (a vertex shader sees each vertex in isolation).
Tessellation shaders aren’t useful here either.[/QUOTE]