r/GraphicsProgramming • u/SYCarrot • Mar 26 '16
How to achieve camera-hit shockwave post-processing effect?
I'm using DirectX/HLSL for post-processing and I want to create a post-processing effect of the screen shaking suddenly.
Any idea how I can achieve this? thanks
3
u/HighRelevancy Mar 27 '16
Screen shake or shockwave? The shockwave is done by drawing a wave that floats outwards from the centre point, and is used as a displacement map (i.e. each pixel's colour gets replaced with the pixel that is the wave's magnitude as a distance away from/towards the centre of the wave).
1
u/skytomorrownow Mar 27 '16
Even then, you'd probably have to sell it with some screen shake when the displacement reaches the camera position.
1
u/ultrapingu Mar 27 '16
To do this in post, you will need to render a larger render target than what you are actually sending to the screen buffer. Then you can just offset that by an amount each frame.
It's a pretty bad way of doing it because you will always have to draw parts of the scene which won't be seen/you have to constantly re size the render target.
The best option is to just rotate the camera a bit per frame, but if you can't access that for some reason, the above answer is your best bet.
5
u/[deleted] Mar 26 '16
Usually a screen-shake is achieved by randomly moving the camera position and rotation multiplied by some kind of pre-determined intensity.