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?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityHaxeFlixel has a nifty built-in shader called FlxWaveEffect
.
How does one go about creating a similar effect in LibGDX?
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.