FILEVERSION = 2.3.0.0;
PLATFORM = DX9;

RENDER_STATE RSC_0 {
  trackingmask = 512;
  compiledClass = "HeatHazeShader";

  //------ Blend State Group ------
  blendenable = 255;
  alphatestref = 100;
  srcblend = src_alpha;
  dstblend = one_minus_src_alpha;
  alphatestfunc = less_or_equal;

  //------ Depth Stencil Group ------
  depthwriteenabled = false;

  //------ Rasterizer State Group ------
  rst_flags = 0;
  cullmode = none;

  //------ Tesselation State Group ------
}

RENDER_STATE RSC_1 {
  trackingmask = 512;
  compiledClass = "HeatHazeShader";

  //------ Blend State Group ------
  blendenable = 255;
  alphatestref = 100;
  srcblend = src_alpha;
  dstblend = one_minus_src_alpha;
  alphatestfunc = less_or_equal;

  //------ Depth Stencil Group ------
  depthwriteenabled = false;

  //------ Rasterizer State Group ------
  rst_flags = 0;
  cullmode = none;

  //------ Tesselation State Group ------
}

RENDER_STATE RSC_2 {
  trackingmask = 512;
  compiledClass = "HeatHazeShader";

  //------ Blend State Group ------
  blendenable = 255;
  alphatestref = 100;
  srcblend = src_alpha;
  dstblend = one_minus_src_alpha;
  alphatestfunc = less_or_equal;

  //------ Depth Stencil Group ------
  depthwriteenabled = false;

  //------ Rasterizer State Group ------
  rst_flags = 0;
  cullmode = none;

  //------ Tesselation State Group ------
}

RENDER_STATE RSC_3 {
  trackingmask = 512;
  compiledClass = "HeatHazeShader";

  //------ Blend State Group ------
  blendenable = 255;
  alphatestref = 100;
  srcblend = src_alpha;
  dstblend = one_minus_src_alpha;
  alphatestfunc = less_or_equal;

  //------ Depth Stencil Group ------
  depthwriteenabled = false;

  //------ Rasterizer State Group ------
  rst_flags = 0;
  cullmode = none;

  //------ Tesselation State Group ------
}

SHADER HeatHaze {
  RenderStateContainerID = 0;
  IsAutoGenerated = false;
  UsesPermutationVariables = true;
  streammask = 119;
  RecompilationRequiredOnPlatforms = 0;
  supportedplatforms = 551;
  compileflags = 0;
  hs_controlpoints = 3;

  //------ Texture samplers ------
  numsamplers_vs = 0;
  numsamplers_hs = 0;
  numsamplers_ds = 0;
  numsamplers_gs = 0;
  numsamplers_ps = 3;
  SAMPLER_PS 0 = {
    samplername = "";
    texturetype = base_texture;
    textureindex = 0;
    texturefile = "";
    filtermode = min_mag_mip_linear;
    textureaddressmode = wrap,wrap,wrap;
    m_fLodBias = 0.000000;
    m_iMaxAnisotropy = 1;
    comparisonfunc = less;
    bordercolor = 0.000000,0.000000,0.000000,1.000000;
    minlod = 0.000000;
    maxlod = 1024.000000;
  }
  SAMPLER_PS 1 = {
    samplername = "";
    texturetype = custom;
    textureindex = 0;
    texturefile = "";
    filtermode = min_mag_mip_linear;
    textureaddressmode = clamp,clamp,clamp;
    m_fLodBias = 0.000000;
    m_iMaxAnisotropy = 1;
    comparisonfunc = less;
    bordercolor = 0.000000,0.000000,0.000000,1.000000;
    minlod = 0.000000;
    maxlod = 1024.000000;
  }
  SAMPLER_PS 2 = {
    samplername = "";
    texturetype = custom;
    textureindex = 0;
    texturefile = "";
    filtermode = min_mag_mip_linear;
    textureaddressmode = wrap,wrap,wrap;
    m_fLodBias = 0.000000;
    m_iMaxAnisotropy = 1;
    comparisonfunc = less;
    bordercolor = 0.000000,0.000000,0.000000,1.000000;
    minlod = 0.000000;
    maxlod = 1024.000000;
  }
  numsamplers_cs = 0;

  //------ vertex shader source ------

  vs_sourcecode=$SOURCECODETAG{
//

#define PARTICLES_USE_PROJECTION

#include <Shaders/Particles.inc>
  }$SOURCECODETAG

  vs_function = "vs_main";
  vs_mintarget = vs_2_0;
  vs_mintargetDX11 = vs_4_0_level_9_1;
  svs_mintarget = vs_2_0;
  svs_mintargetDX11 = vs_4_0_level_9_1;

  //------ hull shader source ------
  hs_mintarget = hs_5_0;

  //------ domain shader source ------
  ds_mintarget = ds_5_0;

  //------ geometry shader source ------
  gs_mintarget = gs_4_0;
  gs_mintargetDX11 = gs_4_0;

  //------ pixel shader source ------

  ps_sourcecode=$SOURCECODETAG{
//

#define PARTICLES_USE_PROJECTION

#include <Shaders/Particles.inc>

#ifdef _VISION_DX11
  Texture2D <float4> FrameBufferTex        : register(t1);
  sampler            FrameBufferTexSampler : register(s1);
  Texture2D <float4> OffsetMap             : register(t2);
  sampler            OffsetMapSampler      : register(s2);
#else
  sampler2D          FrameBufferTex        : register(s1);
  sampler2D          OffsetMap             : register(s2);
#endif

#ifdef _VISION_PS3
  float2 distortionScale : register(c32);
#elif defined(_VISION_DX11)
cbuffer g_GlobalConstantBufferUserPS : register (b2)
{
  float2 distortionScale : packoffset(c0);
}
#else
  float2 distortionScale;
#endif

// haze shader that distorts the frame buffer
float4 ps_main_Haze( VS_OUT In ) : SV_Target
{
  float2 offset = (vTex2D(OffsetMap, OffsetMapSampler, In.UV).xy-0.5) * distortionScale*0.025;
  float4 frame = vTex2D(FrameBufferTex, FrameBufferTexSampler, In.UVProj + offset);
  float4 basetex = vTex2D(BaseTexture, BaseTextureSampler, In.UV)*In.Color;
  //return float4(In.UVProj.x, In.UVProj.y, 0.0f, 0.5f) + 0.01f*float4(frame.x,frame.y,frame.z,basetex.a);
  return float4(frame.x,frame.y,frame.z,basetex.a);
}
  }$SOURCECODETAG

  ps_function = "ps_main_Haze";
  ps_mintarget = ps_2_0;
  ps_mintargetDX11 = ps_4_0_level_9_1;

  //------ compute shader source ------
  cs_mintarget = cs_4_0;

  //------ platform specific bytecode ------
}

SHADER HeatHaze_Intensity {
  RenderStateContainerID = 1;
  IsAutoGenerated = false;
  UsesPermutationVariables = true;
  streammask = 119;
  RecompilationRequiredOnPlatforms = 0;
  supportedplatforms = 551;
  compileflags = 0;
  hs_controlpoints = 3;

  //------ Texture samplers ------
  numsamplers_vs = 0;
  numsamplers_hs = 0;
  numsamplers_ds = 0;
  numsamplers_gs = 0;
  numsamplers_ps = 3;
  SAMPLER_PS 0 = {
    samplername = "";
    texturetype = base_texture;
    textureindex = 0;
    texturefile = "";
    filtermode = min_mag_mip_linear;
    textureaddressmode = wrap,wrap,wrap;
    m_fLodBias = 0.000000;
    m_iMaxAnisotropy = 1;
    comparisonfunc = less;
    bordercolor = 0.000000,0.000000,0.000000,1.000000;
    minlod = 0.000000;
    maxlod = 1024.000000;
  }
  SAMPLER_PS 1 = {
    samplername = "";
    texturetype = custom;
    textureindex = 0;
    texturefile = "";
    filtermode = min_mag_mip_linear;
    textureaddressmode = clamp,clamp,clamp;
    m_fLodBias = 0.000000;
    m_iMaxAnisotropy = 1;
    comparisonfunc = less;
    bordercolor = 0.000000,0.000000,0.000000,1.000000;
    minlod = 0.000000;
    maxlod = 1024.000000;
  }
  SAMPLER_PS 2 = {
    samplername = "";
    texturetype = custom;
    textureindex = 0;
    texturefile = "";
    filtermode = min_mag_mip_linear;
    textureaddressmode = wrap,wrap,wrap;
    m_fLodBias = 0.000000;
    m_iMaxAnisotropy = 1;
    comparisonfunc = less;
    bordercolor = 0.000000,0.000000,0.000000,1.000000;
    minlod = 0.000000;
    maxlod = 1024.000000;
  }
  numsamplers_cs = 0;

  //------ vertex shader source ------

  vs_sourcecode=$SOURCECODETAG{
//

#define PARTICLES_USE_PROJECTION

#include <Shaders/Particles.inc>
  }$SOURCECODETAG

  vs_function = "vs_main";
  vs_mintarget = vs_2_0;
  vs_mintargetDX11 = vs_4_0_level_9_1;
  svs_mintarget = vs_2_0;
  svs_mintargetDX11 = vs_4_0_level_9_1;

  //------ hull shader source ------
  hs_mintarget = hs_5_0;

  //------ domain shader source ------
  ds_mintarget = ds_5_0;

  //------ geometry shader source ------
  gs_mintarget = gs_4_0;
  gs_mintargetDX11 = gs_4_0;

  //------ pixel shader source ------

  ps_sourcecode=$SOURCECODETAG{
//

#define PARTICLES_USE_PROJECTION

#include <Shaders/Particles.inc>

// Debug version of the pixel shader that displays the distortion intensity
float4 ps_DbgIntensity( VS_OUT In ) : SV_Target
{
  float4 basetex = vTex2D(BaseTexture, BaseTextureSampler, In.UV);
  return float4(In.Color.r,In.Color.g,In.Color.b,basetex.a*In.Color.a);
}
  }$SOURCECODETAG

  ps_function = "ps_DbgIntensity";
  ps_mintarget = ps_2_0;
  ps_mintargetDX11 = ps_4_0_level_9_1;

  //------ compute shader source ------
  cs_mintarget = cs_4_0;

  //------ platform specific bytecode ------
}

SHADER HeatHaze_Normal {
  RenderStateContainerID = 2;
  IsAutoGenerated = false;
  UsesPermutationVariables = true;
  streammask = 119;
  RecompilationRequiredOnPlatforms = 0;
  supportedplatforms = 551;
  compileflags = 0;
  hs_controlpoints = 3;

  //------ Texture samplers ------
  numsamplers_vs = 0;
  numsamplers_hs = 0;
  numsamplers_ds = 0;
  numsamplers_gs = 0;
  numsamplers_ps = 3;
  SAMPLER_PS 0 = {
    samplername = "";
    texturetype = base_texture;
    textureindex = 0;
    texturefile = "";
    filtermode = min_mag_mip_linear;
    textureaddressmode = wrap,wrap,wrap;
    m_fLodBias = 0.000000;
    m_iMaxAnisotropy = 1;
    comparisonfunc = less;
    bordercolor = 0.000000,0.000000,0.000000,1.000000;
    minlod = 0.000000;
    maxlod = 1024.000000;
  }
  SAMPLER_PS 1 = {
    samplername = "";
    texturetype = custom;
    textureindex = 0;
    texturefile = "";
    filtermode = min_mag_mip_linear;
    textureaddressmode = clamp,clamp,clamp;
    m_fLodBias = 0.000000;
    m_iMaxAnisotropy = 1;
    comparisonfunc = less;
    bordercolor = 0.000000,0.000000,0.000000,1.000000;
    minlod = 0.000000;
    maxlod = 1024.000000;
  }
  SAMPLER_PS 2 = {
    samplername = "";
    texturetype = custom;
    textureindex = 0;
    texturefile = "";
    filtermode = min_mag_mip_linear;
    textureaddressmode = wrap,wrap,wrap;
    m_fLodBias = 0.000000;
    m_iMaxAnisotropy = 1;
    comparisonfunc = less;
    bordercolor = 0.000000,0.000000,0.000000,1.000000;
    minlod = 0.000000;
    maxlod = 1024.000000;
  }
  numsamplers_cs = 0;

  //------ vertex shader source ------

  vs_sourcecode=$SOURCECODETAG{
//

#define PARTICLES_USE_PROJECTION

#include <Shaders/Particles.inc>
  }$SOURCECODETAG

  vs_function = "vs_main";
  vs_mintarget = vs_2_0;
  vs_mintargetDX11 = vs_4_0_level_9_1;
  svs_mintarget = vs_2_0;
  svs_mintargetDX11 = vs_4_0_level_9_1;

  //------ hull shader source ------
  hs_mintarget = hs_5_0;

  //------ domain shader source ------
  ds_mintarget = ds_5_0;

  //------ geometry shader source ------
  gs_mintarget = gs_4_0;
  gs_mintargetDX11 = gs_4_0;

  //------ pixel shader source ------

  ps_sourcecode=$SOURCECODETAG{
//

#define PARTICLES_USE_PROJECTION

#include <Shaders/Particles.inc>

#ifdef _VISION_DX11
  Texture2D <float4> OffsetMap             : register(t2);
  sampler            OffsetMapSampler      : register(s2);
#else
  sampler2D          OffsetMap             : register(s2);
#endif

// Debug version of the pixel shader that displays the offset map
float4 ps_DbgNormal( VS_OUT In ) : SV_Target
{
  float4 offset = vTex2D(OffsetMap, OffsetMapSampler, In.UV);
  float4 basetex = vTex2D(BaseTexture, BaseTextureSampler, In.UV) * In.Color;
  return float4(offset.x,offset.y,offset.z,basetex.a);
}
  }$SOURCECODETAG

  ps_function = "ps_DbgNormal";
  ps_mintarget = ps_2_0;
  ps_mintargetDX11 = ps_4_0_level_9_1;

  //------ compute shader source ------
  cs_mintarget = cs_4_0;

  //------ platform specific bytecode ------
}

SHADER HeatHaze_Smoke {
  RenderStateContainerID = 3;
  IsAutoGenerated = false;
  UsesPermutationVariables = true;
  streammask = 119;
  RecompilationRequiredOnPlatforms = 0;
  supportedplatforms = 551;
  compileflags = 0;
  hs_controlpoints = 3;

  //------ Texture samplers ------
  numsamplers_vs = 0;
  numsamplers_hs = 0;
  numsamplers_ds = 0;
  numsamplers_gs = 0;
  numsamplers_ps = 3;
  SAMPLER_PS 0 = {
    samplername = "";
    texturetype = base_texture;
    textureindex = 0;
    texturefile = "";
    filtermode = min_mag_mip_linear;
    textureaddressmode = wrap,wrap,wrap;
    m_fLodBias = 0.000000;
    m_iMaxAnisotropy = 1;
    comparisonfunc = less;
    bordercolor = 0.000000,0.000000,0.000000,1.000000;
    minlod = 0.000000;
    maxlod = 1024.000000;
  }
  SAMPLER_PS 1 = {
    samplername = "";
    texturetype = custom;
    textureindex = 0;
    texturefile = "";
    filtermode = min_mag_mip_linear;
    textureaddressmode = clamp,clamp,clamp;
    m_fLodBias = 0.000000;
    m_iMaxAnisotropy = 1;
    comparisonfunc = less;
    bordercolor = 0.000000,0.000000,0.000000,1.000000;
    minlod = 0.000000;
    maxlod = 1024.000000;
  }
  SAMPLER_PS 2 = {
    samplername = "";
    texturetype = custom;
    textureindex = 0;
    texturefile = "";
    filtermode = min_mag_mip_linear;
    textureaddressmode = wrap,wrap,wrap;
    m_fLodBias = 0.000000;
    m_iMaxAnisotropy = 1;
    comparisonfunc = less;
    bordercolor = 0.000000,0.000000,0.000000,1.000000;
    minlod = 0.000000;
    maxlod = 1024.000000;
  }
  numsamplers_cs = 0;

  //------ vertex shader source ------

  vs_sourcecode=$SOURCECODETAG{
//

#define PARTICLES_USE_PROJECTION

#include <Shaders/Particles.inc>
  }$SOURCECODETAG

  vs_function = "vs_main";
  vs_mintarget = vs_2_0;
  vs_mintargetDX11 = vs_4_0_level_9_1;
  svs_mintarget = vs_2_0;
  svs_mintargetDX11 = vs_4_0_level_9_1;

  //------ hull shader source ------
  hs_mintarget = hs_5_0;

  //------ domain shader source ------
  ds_mintarget = ds_5_0;

  //------ geometry shader source ------
  gs_mintarget = gs_4_0;
  gs_mintargetDX11 = gs_4_0;

  //------ pixel shader source ------

  ps_sourcecode=$SOURCECODETAG{
//

#define PARTICLES_USE_PROJECTION

#include <Shaders/Particles.inc>

#ifdef _VISION_DX11
  Texture2D <float4> FrameBufferTex        : register(t1);
  sampler            FrameBufferTexSampler : register(s1);
  Texture2D <float4> OffsetMap             : register(t2);
  sampler            OffsetMapSampler      : register(s2);
#else
  sampler2D          FrameBufferTex        : register(s1);
  sampler2D          OffsetMap             : register(s2);
#endif

#ifdef _VISION_PS3
  float2 distortionScale : register(c32);
#elif defined(_VISION_DX11)
cbuffer g_GlobalConstantBufferUserPS : register (b2)
{
  float2 distortionScale : packoffset(c0);
}
#else
  float2 distortionScale;
#endif

// haze shader that distorts the frame buffer
float4 ps_main_HazeSmoke( VS_OUT In ) : SV_Target
{
  float2 offset = (vTex2D(OffsetMap, OffsetMapSampler, In.UV).xy-0.5) * distortionScale*0.025;
  float4 frame = vTex2D(FrameBufferTex, FrameBufferTexSampler, In.UVProj + offset);
  float4 particle = vTex2D(BaseTexture, BaseTextureSampler, In.UV)*In.Color;
  float4 result = 0.4*frame + 0.6*particle;
  return float4(result.x,result.y,result.z,particle.a);
}
  }$SOURCECODETAG

  ps_function = "ps_main_HazeSmoke";
  ps_mintarget = ps_2_0;
  ps_mintargetDX11 = ps_4_0_level_9_1;

  //------ compute shader source ------
  cs_mintarget = cs_4_0;

  //------ platform specific bytecode ------
}

//////////////////////////////////////////////////////////////////////////////

EFFECT HeatHaze {
  DESCRIPTION = {};
  PARAMCOMMENT={"TextureRange","Defines the ratio between the screen resolution and the next power of two","",float2,none};
  PARAMCOMMENT={"OffsetMap","A normalmap that defines the distortion offset in xy","noise_Normal.tga",texture,none};
  PARAMCOMMENT={"distortionScale","a scaling factor for the distortion","0.01,0.01",float2,none};
  TECHNIQUE "all"
  {
    passes="HeatHaze";
    passtype = post_basepass;
    IsPermutationTechnique=true;
    IsAutoGenerated=false;
    PermutationConfigFile="shaders\Misc_00\HeatHazeHWS.Shaderbin\HeatHazeHWS.lua";
  }
}

EFFECT HeatHazeSmoke {
  DESCRIPTION = {};
  PARAMCOMMENT={"TextureRange","","",float2,none};
  PARAMCOMMENT={"OffsetMap","A normalmap that defines the distortion offset in xy","noise_Normal.tga",texture,none};
  PARAMCOMMENT={"distortionScale","","",float2,none};
  TECHNIQUE "all"
  {
    passes="HeatHaze_Smoke";
    passtype = post_basepass;
    IsPermutationTechnique=true;
    IsAutoGenerated=false;
    PermutationConfigFile="shaders\Misc_00\HeatHazeHWS.Shaderbin\HeatHazeHWS.lua";
  }
}

EFFECT DEBUG_Normal {
  DESCRIPTION = {};
  PARAMCOMMENT={"OffsetMap","A normalmap that defines the distortion offset in xy","noise_Normal.tga",texture,none};
  TECHNIQUE "all"
  {
    passes="HeatHaze_Normal";
    passtype = post_basepass;
    IsPermutationTechnique=true;
    IsAutoGenerated=false;
    PermutationConfigFile="shaders\Misc_00\HeatHazeHWS.Shaderbin\HeatHazeHWS.lua";
  }
}

EFFECT DEBUG_Intensity {
  DESCRIPTION = {};
  PARAMCOMMENT={"TextureRange","","",float2,none};
  TECHNIQUE "all"
  {
    passes="HeatHaze_Intensity";
    passtype = post_basepass;
    IsPermutationTechnique=true;
    IsAutoGenerated=false;
    PermutationConfigFile="shaders\Misc_00\HeatHazeHWS.Shaderbin\HeatHazeHWS.lua";
  }
}

