I’ve hacked together a simpler version of a heat haze/stealth field filter.
It has a very simple setup, all you need to do is hide some geometry from the main camera, override a shader input for it (np.setShaderInput(“mask”, 0.0)), an optional masking texture can be used if needed and that’s about it.
Screen:
Code:
[in the attachment]
EDIT:
If you want the distortion not to affect things in front of it (more or less), use this shader as ‘normals.cg’:
//Cg
void vshader(in float4 vtx_position : POSITION,
in float4 vtx_normal : NORMAL,
in float4 vtx_texcoord0 : TEXCOORD0,
out float4 l_position : POSITION,
out float4 l_color0 : COLOR0,
out float3 l_normal : TEXCOORD0,
out float4 l_texcoord : TEXCOORD1,
uniform float4x4 itp_modelview,
uniform float4x4 mat_modelproj)
{
l_position = mul(mat_modelproj, vtx_position);
l_normal = normalize(mul(itp_modelview, vtx_normal));
l_texcoord = vtx_texcoord0;
}
void fshader(float4 l_color0 : COLOR0,
float3 l_normal : TEXCOORD0,
float3 l_texcoord : TEXCOORD1,
uniform float mask,
uniform float useMap,
uniform sampler2D tex_0,
out float4 o_color : COLOR)
{
float4 map = tex2D(tex_0, l_texcoord.xy);
if (mask>0.9)
o_color=float4(0.0, 0.0, 0.0, map.a);
else
o_color=float4(l_normal, 1.0-map.r*useMap);
}
demo.zip (1.99 MB)