Damn I'd really love to help you on it with shader code but I'm going to a village. There's not electricity(needless to say about internets) and I'm coming back on monday.
About your idea: if particles are already drawn over fullscreen fbo texture then you can totally add distortion effect into the same shader. But are particles really drawn via fullscreen quad? I've thought every particle has its own quad. And if you want particles to be unaffected by distortion, you can simply apply distortion texture to the fbo before rendering them.
Now your fragment shader should look approximately like this:
Code: Select all
//fullscreen fragment shader
void main()
{
gl_FragColor = texture2D(sceneFBO, gl_FragCoord.xy) + texture2D(particleFBO, gl_FragCoord.xy);
//particleFBO is fullscreen layer that contains your particles
}
you should alter it to be simply like this:
Code: Select all
void main()
{
vec3 distortionColor = texture2D(distortionTexture, gl_FragCoord.xy);
vec2 distortionOffset = vec2(distortionColor.r - 0.5f, distortionColor.g - 0.5f) * distortionPower;
//distortionPower is an arbitrary constant
gl_FragColor = texture2D(sceneFBO, gl_FragCoord.xy + distortionOffset) + texture2D(particleFBO, gl_FragCoord.xy);
}
That's all!
Distortion texture for a shockwave-like effect can be as follows:
Code: Select all
void main()
{
vec2 explosionCenter = vec2(width / 2.0, height / 2.0); // center of the explosion, screenspace coords
float explosionRadius = 100; // current shockwave radius, can vary with time
float shockwaveWidth = 10; // current shockwave width, can vary as well
vec2 centerDist = gl_FragCoord.xy - explosionCenter;
vec2 distortionOffset = normalize(centerDist) * exp(-length(centerDist) / shockwaveWidth);
gl_FragColor = vec3(distortionOffset.x, distortionOffset.y, 0) / distortionPower - vec3(0.5, 0.5, 0);
//distortionPower is the same constant as in previous shader
}
Hope it helps, sorry for mistakes in shader - I was typing directly in browser.
If you are too lazy to generate distortion texture by yourself or for testing purposes you can grab this one:

(it should magnify your image)
And I'm really excited that you can add such feature to the game - it is relatively simple to implement(far simpler than most things you code every day) and should look cool!