Skip to main content
update dead link
Source Link
tigrou
  • 3.2k
  • 1
  • 27
  • 43

Yes, you are right, this 2D water effect can be simulated using math sine function :

wave = sin(phase + t * frequency) * amplitude

enter image description here

  • phase is a constant, put whatever you want.
  • set t to horizontal position of pixel/vertex you are processing : t = x;
  • change amplitude over the time (that will make the waves moving up and down) :

amplitude = sin(t * wave_speed) * wave_height

  • combine several waves to get a more relastic effect :

wave_final = wave0 + wave1 + ... .

For each wave, change some parameters a little bit (eg: phase, frequency,...).

Here is a quick example i made, using only two waves :

http://glsl.heroku.com/e#4988.0http://glslsandbox.com/e#4988.0 (require recent browser and WebGL enabled)

NOTE : this is a shader, but doing this using 2D primitives is the same approach .

EDIT : you dont specify any framework or 2d rendering system, but here is how it could be rendered using polygons / triangle strips :

enter image description here

Yes, you are right, this 2D water effect can be simulated using math sine function :

wave = sin(phase + t * frequency) * amplitude

enter image description here

  • phase is a constant, put whatever you want.
  • set t to horizontal position of pixel/vertex you are processing : t = x;
  • change amplitude over the time (that will make the waves moving up and down) :

amplitude = sin(t * wave_speed) * wave_height

  • combine several waves to get a more relastic effect :

wave_final = wave0 + wave1 + ... .

For each wave, change some parameters a little bit (eg: phase, frequency,...).

Here is a quick example i made, using only two waves :

http://glsl.heroku.com/e#4988.0 (require recent browser and WebGL enabled)

NOTE : this is a shader, but doing this using 2D primitives is the same approach .

EDIT : you dont specify any framework or 2d rendering system, but here is how it could be rendered using polygons / triangle strips :

enter image description here

Yes, you are right, this 2D water effect can be simulated using math sine function :

wave = sin(phase + t * frequency) * amplitude

enter image description here

  • phase is a constant, put whatever you want.
  • set t to horizontal position of pixel/vertex you are processing : t = x;
  • change amplitude over the time (that will make the waves moving up and down) :

amplitude = sin(t * wave_speed) * wave_height

  • combine several waves to get a more relastic effect :

wave_final = wave0 + wave1 + ... .

For each wave, change some parameters a little bit (eg: phase, frequency,...).

Here is a quick example i made, using only two waves :

http://glslsandbox.com/e#4988.0 (require recent browser and WebGL enabled)

NOTE : this is a shader, but doing this using 2D primitives is the same approach .

EDIT : you dont specify any framework or 2d rendering system, but here is how it could be rendered using polygons / triangle strips :

enter image description here

added 5 characters in body
Source Link
tigrou
  • 3.2k
  • 1
  • 27
  • 43

Have a look atYes, you are right, this 2D water effect can be simulated using math sine function :

wave = sin(phase + t * frequency) * amplitude

enter image description here

  • phase is a constant, put whatever you want.
  • set t to horizontal position of pixel/vertex you are processing : t = x;
  • change amplitude over the time (that will make the waves moving up and down) :

amplitude = sin(t * wave_speed) * wave_height

  • combine several waves to get a more relastic effect :

wave_final = wave0 + wave1 + ... .

For each wave, change some parameters a little bit (eg: phase, frequency,...).

Here is a quick example i made, using only two waves :   

http://glsl.heroku.com/e#4988.0 (require recent browser and webgl to beWebGL enabled)

NOTE : this is a shader, but doing this using 2D primitives is the same approach .

EDIT : you dont specify any framework or 2d rendering system, but here is how it could be rendered using polygons / triangle strips :

enter image description here

Have a look at math sine function :

wave = sin(phase + t * frequency) * amplitude

enter image description here

  • phase is a constant, put whatever you want.
  • set t to horizontal position of pixel you are processing : t = x;
  • change amplitude over the time (that will make the waves moving up and down) :

amplitude = sin(t * wave_speed) * wave_height

  • combine several waves to get a more relastic effect :

wave_final = wave0 + wave1 + ... .

For each wave, change some parameters a little bit (eg: phase, frequency,...).

Here is a quick example i made, using only two waves :  http://glsl.heroku.com/e#4988.0 (require recent browser and webgl to be enabled)

NOTE : this is a shader, but doing this using 2D primitives is the same approach .

EDIT : you dont specify any framework or 2d rendering system, but here is how it could be rendered using polygons / triangle strips :

enter image description here

Yes, you are right, this 2D water effect can be simulated using math sine function :

wave = sin(phase + t * frequency) * amplitude

enter image description here

  • phase is a constant, put whatever you want.
  • set t to horizontal position of pixel/vertex you are processing : t = x;
  • change amplitude over the time (that will make the waves moving up and down) :

amplitude = sin(t * wave_speed) * wave_height

  • combine several waves to get a more relastic effect :

wave_final = wave0 + wave1 + ... .

For each wave, change some parameters a little bit (eg: phase, frequency,...).

Here is a quick example i made, using only two waves : 

http://glsl.heroku.com/e#4988.0 (require recent browser and WebGL enabled)

NOTE : this is a shader, but doing this using 2D primitives is the same approach .

EDIT : you dont specify any framework or 2d rendering system, but here is how it could be rendered using polygons / triangle strips :

enter image description here

edited body
Source Link
tigrou
  • 3.2k
  • 1
  • 27
  • 43

Have a look at math sine function :

wave = sin(phase + t * frequency) * amplitude

enter image description here

  • phase is a constant, put whatever you want.
  • set t to horizontal position of pixel you are processing : t = y;x;
  • change amplitude over the time (that will make the waves moving up and down) :

amplitude = sin(t * wave_speed) * wave_height

  • combine several waves to get a more relastic effect :

wave_final = wave0 + wave1 + ... .

For each wave, change some parameters a little bit (eg: phase, frequency,...).

Here is a quick example i made, using only two waves : http://glsl.heroku.com/e#4988.0 (require recent browser and webgl to be enabled)

NOTE : this is a shader, but doing this using 2D primitives is the same approach .

EDIT : you dont specify any framework or 2d rendering system, but here is how it could be rendered using polygons / triangle strips :

enter image description here

Have a look at math sine function :

wave = sin(phase + t * frequency) * amplitude

enter image description here

  • phase is a constant, put whatever you want.
  • set t to horizontal position of pixel you are processing : t = y;
  • change amplitude over the time (that will make the waves moving up and down) :

amplitude = sin(t * wave_speed) * wave_height

  • combine several waves to get a more relastic effect :

wave_final = wave0 + wave1 + ... .

For each wave, change some parameters a little bit (eg: phase, frequency,...).

Here is a quick example i made, using only two waves : http://glsl.heroku.com/e#4988.0 (require recent browser and webgl to be enabled)

NOTE : this is a shader, but doing this using 2D primitives is the same approach .

EDIT : you dont specify any framework or 2d rendering system, but here is how it could be rendered using polygons / triangle strips :

enter image description here

Have a look at math sine function :

wave = sin(phase + t * frequency) * amplitude

enter image description here

  • phase is a constant, put whatever you want.
  • set t to horizontal position of pixel you are processing : t = x;
  • change amplitude over the time (that will make the waves moving up and down) :

amplitude = sin(t * wave_speed) * wave_height

  • combine several waves to get a more relastic effect :

wave_final = wave0 + wave1 + ... .

For each wave, change some parameters a little bit (eg: phase, frequency,...).

Here is a quick example i made, using only two waves : http://glsl.heroku.com/e#4988.0 (require recent browser and webgl to be enabled)

NOTE : this is a shader, but doing this using 2D primitives is the same approach .

EDIT : you dont specify any framework or 2d rendering system, but here is how it could be rendered using polygons / triangle strips :

enter image description here

added 218 characters in body
Source Link
tigrou
  • 3.2k
  • 1
  • 27
  • 43
Loading
Source Link
tigrou
  • 3.2k
  • 1
  • 27
  • 43
Loading