shaders - ripple effect

BlitzMax Forums/OpenGL Module/shaders - ripple effect

Bremer(Posted 2006) [#1]
I would like to add a ripple effect to my sprite module. I have seen a video of a game where they have such an effect so that when something explode the graphics ripple from the center and out. I am sure that someone wrote that the game was using shaders to produce that effect.

My questions are the following:

What kind of shader can be used for this and will it work when all my sprites are essential quads with texture on them?

Any one got any code or links to tutorials/info about how to go about setting something like that up?


N(Posted 2006) [#2]
I'd use a vertex shader that maps the UV coordinates so it matches the vertices' positions on-screen then write a fragment shader that displaces the texture coordinates based on a normal map. The scale of the displacement would be a uniform, of course.

Then it's simply a matter of rendering the scene to a texture and then drawing the ripple mesh with the shader.

As for code and how to set it up, you could pay me. It's not simple enough to justify writing it up for free without making it very, very specialized.


Bremer(Posted 2006) [#3]
If I were to pay for code that would render my current output to a texture and that handles the shader setup and execution, how much would that cost me?


N(Posted 2006) [#4]
Depends on whether or not your current code is flexible enough to have it added in without problem.


Bremer(Posted 2006) [#5]
I really appreciate if you would look into if it would work and I have emailed you with a little more info on how my system works. I have included the openGL functions which sets up the context and such.


ImaginaryHuman(Posted 2006) [#6]
You could do the same without shaders using an animated mesh and regular texture mapping.


N(Posted 2006) [#7]
Wouldn't look as good.


ImaginaryHuman(Posted 2006) [#8]
It wouldn't be on a per-pixel basis accurate, no. But for most people it could look more or less the same, and not have such high requirements.


N(Posted 2006) [#9]
Use a fallback where necessary, otherwise use a shader.


ImaginaryHuman(Posted 2006) [#10]
Or use texture mapping, and use a shader if available. ;-D


Leiden(Posted 2006) [#11]
Get a real job Noel.


Grover(Posted 2006) [#12]
Hrm, not sure whats being suggested here, but a ripple anim texture based bump/normal map would actually look as good, and perform much better than any shader variant. The reason for this, is that you will need to render to texture at a fairly decent resolution (to match that of an anim normal map) and then apply it as a post render effect - which is pretty wasteful and pointless.

So Id do something like (pseudo code):
LoadTextureAnim - bump/normal map ripple

During render loop:
RenderScene as normal

When needing ripple:
Render quad Mesh overlay with bump/normal mapped frame

For this effect, there simply isnt any point in runtime render to texture rendering, unless you are doing something fancy with the onscreen data (seems very unlikely).