5
\$\begingroup\$

I'm working on adding volume effects to an existent, open-source game engine. At the moment, the engine only supports two dimensional "thruster" bitmaps with a planar heat distortion drawn over the bitmap.

Is it possible to make a Volume filling Heat Distortion? If so, what would be the general idea behind it?

\$\endgroup\$
  • \$\begingroup\$ I know I've seen it before, so it must be possible. My guess would be two steps: draw everything but the heat volume to a render target, then a pass using the depth buffer to distort the render target in the regions covered by the heat volume. Someone who knows shaders really well should be able to provide more detail. \$\endgroup\$ – jzx Dec 4 '14 at 7:35
0
\$\begingroup\$

I think you have two options. (1) You could go for a view-space effect where you render everything first and then apply the heat-distortion as a post-processing effect to the 2D rendered scene. (2) Alternatively you could apply the effect in world space through vertex displacements in the vertex shader stage.

(1) View-space distortion could make use of the depth buffer to estimate the depth of objects, as jzx mentions. The advantage of this approach would be simplicity, as you are just operating on a part of the final 2D projected scene - i.e. a zone of pixels. The disadvantage you only have information of the nearest polygon for every pixel. This means distorting a foreground object can never reveal objects located behind it. This effect might therefore look give the impression of a fake, flat effect.

(2) By working in world-space, you can apply distortions to the vertices of all objects. The advantages are: 1. distorted objects can reveal objects behind them, 2. distorting of vertices is very efficient compared to distorting individual pixels (as the rasterization process, in hardware, will take care of all fragments inbetween the vertices) - unless you have a scene with (extremely) many overlapping objects, 3. you can use a 3D function to drive the intensity of the distortion throughout space, which seems very elegant as compared to using a bounding volume. 4. the effect is applied in 3D, meaning distant objects will natrally have less distortion than near ones, solving the problem of the "fake, flat distortion effect".

In summary, you can go for 2 broad approaches: distortion in view-space and distortion in world-space. I would use the latter for better visual results, more elegancy and likely more performance.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ You forgot to add the disadvantages of distorting vertices, which include that you need quite a fine degree of tesselation and that it's prone to interpolation artefacts. (FYI I'm aware this is a 5+ year-old answer, but it seems appropriate to add this comment for the benefit of anyone coming across it in the future.) \$\endgroup\$ – Maximus Minimus Jan 6 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.