How to implement a heat haze effect with HLSL

Started by
3 comments, last by TonyT_GameDev 12 years ago
if you look throw the air on top of fire, the scene behind will be blurred and distorted. I have implemented thd effect by this way: 1.render the scene to a render target 2.offset the pixels with time_0 and a noise image but this is a whole screen effect,is there a effect can be used as material? on the side, I think using render target is slow, isn't it?
MSN:xoyojank#live.com
Advertisement
I don't really see how you could implement it so you wouldn't have to use a post-processing pass, since you need to know what's behind the area of distortion.

If you don't want to use a full-screen pass, you could instead keep the effect restricted an area of the screen covered by some geometry that you render. This can be done in two ways:

-Render the volume, and in the pixel shader calculate the texture coordinate used to access the full-screen texture based on the current clip-space position:

float2 texPos = 0.5f * IN.position2D.xy / IN.position2D.w + float2(0.5f, 0.5f);float2 offset = 0.5f / screenDimensions;texPos -= offset;texPos.y = 1.0f - texPos.y;


-Render the volume with stenciling enabled, then render a full-screen pass using the stencil buffer as a mask

Then what you can do, to keep the effect from having the harsh polygonal edges of your bounding volume, is to use some sort of attenuation function based on the primitive shape you're attempting to render. So for example if you're rendering a sphere or cone, you could use the same attenuation equations used for a spotlight and pointlight.
I think you could do that:
1. render the scene to a render target
2. render the "distortion scene" to another texture (render the heat volumes)
3. post process using the 2nd buffer to see where to distort

You could optimize that by using the alpha channel or the stencil buffer to store distorted areas.
Tchou kanaky ! tchou !
Chapter 7 in "Shaders for game programmers and artists" by Sebastien St-Laurent covers this, in HLSL.
____________________________Bjarni Arnasonbjarni.us
Chapter 7 in "Shaders for game programmers and artists" by Sebastien St-Laurent covers this, in HLSL.

thx

This topic is closed to new replies.

Advertisement