0
\$\begingroup\$

HaxeFlixel has a nifty built-in shader called FlxWaveEffect.

  • Video
  • Demo (Flash required) if you start the game and steer the player into an enemy.
  • Usage (search for FlxWaveEffect)

How does one go about creating a similar effect in LibGDX?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

These are generally done using post processing shaders. Instead of rendering the game to the screen, you render it to a framebuffer, then use it as a texture and draw a quad filling the screen with it. You can use custom shaders in the last part to enhance or stylize the game. This is how blur, DOF or sometimes special shaders (such as skyward swords water painting look) are made.

In your case, you just render everything to a framebuffer, bind that to a shader, pass the current time as a uniform and render a quad on the screen. Inside the shader you'll have:

gl_FragColor = texture2D(sampler, UV + vec2(sin(time + UV. y / waviness * 2.0 * 3.1415) * waveStrength, 0);

where waviness is the amount of waves on the screen and waveStrength is the amplitude of those waves in pixels.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .