Animate height of heightmap

Im trying to animate the height of my heightmap. Now im loading a png and render that onto a grid. Then I take the color value of the position on the heightmap and multiply that by height so its like that:

u_Position = (position.x, height * heightMapValue.r ,position.z); 

now im looking for a way to animate the height so it goes from height = 0 to height = set by user

for that i already used this:

u_Position.y = height * heightMapValue * sin(time)

now I got two problems:

  1. how do I make it so that it doesnt goes from +height to -height like its doing right now. Basicly I want to move the sin wave up so it only goes between 0 - height.
  2. I want that animation to take 10 seconds. The time variable already returns the runtime of the program in seconds
u_Position.y = height * heightMapValue * (1 + sin(time)) / 2

(that’s about problem 1)

with 0.628… = Pi / 5 or 2 * Pi / 10 (a period of sin() is 2*Pi and you want it to take 10 seconds)

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.