I just Combined the motion Blur radial shader with the heat haze shade And I got it working!
http://www.youtube.com/watch?v=ssPe8dKOL7Y&feature=c4-overview&list=UUr0boUODFnZmY-PWnSyMokg
Code: [Select]
////////////////////////////////////////////////////////////////////////////////////////////////////////////
MotionBlur With Heat Haze
////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*HLSLSTART Motion Radial Blur
//-------------------------------------------------------------------------------------------
//Editables
//-------------------------------------------------------------------------------------------
float ScreenWidth = 1280;
float ScreenHeight = 1024;
float BlurStart = 1.0f;
float BlurWidth = -0.15f;
float time = 0.0;
float2 screenLocation = float2(0.5,0.5);
float radii = 0.5;
float4 oCol = float4(0.5f,0,0,0); //slightly red
float _CX = 0.0f;
float _CY = 0.0f;
static float2 Center2 = { _CX, _CY };
float _CCX = 0.5f;
float _CCY = 0.5f;
static float2 Center = { _CCX+(_CX/20),_CCY+ (-_CY/20) };
//-------------------------------------------------------------------------------------------
//Textures
//-------------------------------------------------------------------------------------------
texture screenTexture;
sampler screenTextureSampler = sampler_state
{
Texture = <screenTexture>;
MipFilter = LINEAR;
MinFilter = NONE;
MagFilter = LINEAR;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
AddressU = WRAP;
AddressV = WRAP;
AddressW = WRAP;
AddressU = MIRROR;
AddressV = MIRROR;
AddressW = MIRROR;
};
//-------------------------------------------------------------------------------------------
//Pixel Shader
//-------------------------------------------------------------------------------------------
float4 DefaultRender( in float2 textureUV : TEXCOORD0 ) : COLOR
{
//setup oval to render haze in
float2 displace = screenLocation - float2(textureUV.x,textureUV.y/2);
float range = saturate(1 - (length(displace) / (abs(-sin(radii * 8) * radii))))+0.0000001f;
//Alter the UV coordinates (position in the texture) for the current pixel,
//to achieve some image deformation, based on the 'time' parameter set by
//the regular script code.
textureUV.x += range*sin(time+textureUV.x*600)*0.001f;
textureUV.y += range*cos(time+textureUV.y*600)*0.002f;
//Read the pixel from the texture, from the altered UV location
float4 COLOR = tex2D(screenTextureSampler,textureUV);
COLOR+=COLOR*range*oCol;
textureUV = textureUV - Center;
float4 color= -0.5;
int nsamples = 30;
for(int i=0; i<nsamples; i++) {
float scale = BlurStart - BlurWidth*(i/(float) (nsamples-1));
color += tex2D(screenTextureSampler, textureUV*scale + Center);//(Center2/150) );
}
color /= nsamples;
return color;
}
//-------------------------------------------------------------------------------------------
//Technique
//-------------------------------------------------------------------------------------------
technique PostProcessing
{
pass P0
{
PixelShader = compile ps_3_0 DefaultRender();
}
}
HLSLEND*/
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//The following is our regular script code which sets and manipulates the shader above
float carMinSpeed=0;
float carMaxSpeed=260;
float maxBlurFactor=-0.05f;
float Time = 0;
int movingObject = OBJ_22;
void Main()
{
if (iInitializing())
{
iShaderSet(OBJ_0,"Heat Haze");
}
//Create some vectors to store location data in,
Vector3 targetLocation;
Vector3 screenLocation;
Vector3 camLoc;
//get fire and camera location
iObjectLocation(OBJ_22,targetLocation);
iObjectLocation(OBJ_0,camLoc);
//add some offset to fire location
targetLocation.y += 2.5;
//get corresponding screen location projected .
i3DLocationToScreen(screenLocation,targetLocation,OBJ_0); //cam
//interpolate loaction between 0.0f and 1.0f so we can send to shader
float x = iFloatInterpolate(screenLocation.x,-16.0f,16.0f,0.0f,1.0f,true);
float y = iFloatInterpolate(screenLocation.y,12.0f,-12.0f,0.0f,1.0f,true);
//Measure distance to fire from camera.
float radii=iVectorLength(targetLocation-camLoc);
//Increase haze radius as we approach fire
float range = 0.23-iFloatInterpolate(radii,0.0f,50.0f,0.01f,0.2299f,true);
//Update shader
iShaderFloatSet(OBJ_0,"time",Time);
iShaderFloat2Set(OBJ_0,"screenLocation",x,y/2);
iShaderFloatSet(OBJ_0,"radii",range);
Time += 0.4;
iShaderSet(OBJ_0,"Motion Radial Blur");
float blur = iFloatInterpolate(iObjectKmh(movingObject),carMinSpeed,carMaxSpeed,0,maxBlurFactor,true);
iShaderFloatSet(OBJ_0,"BlurWidth", blur);
}
It was really hard thoughhttp://www.youtube.com/watch?v=ssPe8dKOL7Y&feature=c4-overview&list=UUr0boUODFnZmY-PWnSyMokg