FILEVERSION = 2.3.0.0;
PLATFORM = DX9;

//////////////////////////////////////////////////////////////////////////////
SOURCECODE=$SOURCECODETAG{
//
#include <Shaders/VisionCommon.inc>

#ifdef _VISION_DX11
cbuffer g_GlobalConstantBufferObject : register (b1)
{
  float4x4  matMVP  : packoffset(c4);   // model view projection matrix
}
#else
  float4x4 matMVP : register(c8);
#endif

struct VS_IN
{
  float4 ObjPos   : POSITION;
  float2 UV0 : TEXCOORD0;
  float2 UV1 : TEXCOORD1;
  float3 Normal : NORMAL;
};

struct VS_OUT
{
  float4 ProjPos  : SV_Position;
  float2 UV0 : TEXCOORD0;
  float2 UV1 : TEXCOORD1;
  float3 Normal : TEXCOORD2;
};

VS_OUT vs_main( VS_IN In )
{
  VS_OUT Out;
  Out.ProjPos = mul( matMVP, In.ObjPos );
  Out.UV0 = In.UV0;
  Out.UV1 = In.UV1;
  Out.Normal = In.Normal;
  return Out;
}

//
#include <Shaders/VisionCommon.inc>

#ifdef _VISION_DX11
  Texture2D <float4> BaseTexture        : register(t0);
  sampler            BaseTextureSampler : register(s0);
  Texture2D <float4> Lightmap           : register(t0);
  sampler            LightmapSampler    : register(s0);
  
cbuffer g_GlobalConstantBufferFrame : register (b0)
{
  float4             lightmapMul        : packoffset(c22);  // lightmap multiplier (skalar) 
}
#else
  sampler2D          BaseTexture        : register(s0);
  sampler2D          Lightmap           : register(s1);
  float4             lightmapMul        : register(c0);
#endif

#if defined(_VISION_PS3) || defined(_VISION_PSP2) || defined(_VISION_GLES2) || defined(_VISION_WIIU)
  float    BlinkFade    : register(c32);
  float4   PrimaryColor : register(c33);
#elif defined(_VISION_DX11)
cbuffer g_GlobalConstantBufferUser : register (b2)
{
  float    BlinkFade    : packoffset(c0);
  float4   PrimaryColor : packoffset(c1);
}
#else
  float    BlinkFade;
  float4   PrimaryColor;
#endif

struct PS_IN
{
  float4 ProjPos  : SV_Position;
   float2 UV0 : TEXCOORD0;
   float2 UV1 : TEXCOORD1;
   float3 Normal : TEXCOORD2;
};

float4 ps_main( PS_IN In ) : SV_Target
{
  float4 tc = vTex2D(BaseTexture, BaseTextureSampler, In.UV0);
  return tc * float4(0.2,0.2,0.8,1.0);
}


float4 ps_blink( PS_IN In ) : SV_Target
{
  return float4(0.2,0.2,1.0,BlinkFade);
}

float4 ps_overdraw( PS_IN In ) : SV_Target
{
  return float4(1,1,1,0.2);
}

float4 ps_normal( PS_IN In ) : SV_Target
{
  return float4(In.Normal*0.5+0.5, 1);
}

float4 ps_lightmap( PS_IN In ) : SV_Target
{
  return vTex2D(Lightmap, LightmapSampler, In.UV1) * lightmapMul;
}

float4 ps_normalmap( PS_IN In ) : SV_Target
{
  return vTex2D(BaseTexture, BaseTextureSampler, In.UV0);
}

float4 ps_primcolor( PS_IN In ) : SV_Target
{
  return PrimaryColor;
}

float4 ps_visareacolor( PS_IN In ) : SV_Target
{
  return PrimaryColor * vTex2D(BaseTexture, BaseTextureSampler, In.UV0);
}
  }$SOURCECODETAG

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

RENDER_STATE RSC_0 {
  compiledClass = "VSurfaceShader";

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

  //------ Depth Stencil Group ------

  //------ Rasterizer State Group ------
  rst_flags = 1;

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

RENDER_STATE RSC_1 {
  compiledClass = "VSurfaceShader";

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

  //------ Depth Stencil Group ------

  //------ Rasterizer State Group ------
  rst_flags = 1;

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

RENDER_STATE RSC_2 {
  compiledClass = "VSurfaceShader";

  //------ Blend State Group ------
  alphatestref = 100;
  srcblend = src_alpha;
  alphatestfunc = less_or_equal;

  //------ Depth Stencil Group ------

  //------ Rasterizer State Group ------
  rst_flags = 1;

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

RENDER_STATE RSC_3 {
  compiledClass = "VSurfaceShader";

  //------ Blend State Group ------
  alphatestref = 100;
  srcblend = src_alpha;
  alphatestfunc = less_or_equal;

  //------ Depth Stencil Group ------

  //------ Rasterizer State Group ------
  rst_flags = 1;

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

RENDER_STATE RSC_4 {
  compiledClass = "VSurfaceShader";

  //------ Blend State Group ------
  alphatestref = 100;
  srcblend = src_alpha;
  alphatestfunc = less_or_equal;

  //------ Depth Stencil Group ------

  //------ Rasterizer State Group ------
  rst_flags = 1;

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

RENDER_STATE RSC_5 {
  compiledClass = "VSurfaceShader";

  //------ Blend State Group ------
  alphatestref = 100;
  srcblend = src_alpha;
  alphatestfunc = less_or_equal;

  //------ Depth Stencil Group ------

  //------ Rasterizer State Group ------
  rst_flags = 1;

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

RENDER_STATE RSC_6 {
  compiledClass = "VSurfaceShader";

  //------ Blend State Group ------
  alphatestref = 100;
  srcblend = src_alpha;
  alphatestfunc = less_or_equal;

  //------ Depth Stencil Group ------

  //------ Rasterizer State Group ------
  rst_flags = 1;

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

SHADER StandardBlink {
  RenderStateContainerID = 0;
  IsAutoGenerated = false;
  UsesPermutationVariables = false;
  streammask = 17;
  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 = 1;
  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;
  }
  numsamplers_cs = 0;

  //------ vertex shader source ------
  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_function = "ps_blink";
  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 Overdraw {
  RenderStateContainerID = 1;
  IsAutoGenerated = false;
  UsesPermutationVariables = false;
  streammask = 17;
  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 = 1;
  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;
  }
  numsamplers_cs = 0;

  //------ vertex shader source ------
  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_function = "ps_overdraw";
  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 ColorNormals {
  RenderStateContainerID = 2;
  IsAutoGenerated = false;
  UsesPermutationVariables = false;
  streammask = 17;
  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 = 1;
  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;
  }
  numsamplers_cs = 0;

  //------ vertex shader source ------
  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_function = "ps_normal";
  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 Lightmap {
  RenderStateContainerID = 3;
  IsAutoGenerated = false;
  UsesPermutationVariables = false;
  streammask = 17;
  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 = 2;
  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 = lightmap;
    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_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_function = "ps_lightmap";
  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 Normalmap {
  RenderStateContainerID = 4;
  IsAutoGenerated = false;
  UsesPermutationVariables = false;
  streammask = 17;
  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 = 1;
  SAMPLER_PS 0 = {
    samplername = "";
    texturetype = normalmap;
    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_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_function = "ps_normalmap";
  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 PrimColor {
  RenderStateContainerID = 5;
  IsAutoGenerated = false;
  UsesPermutationVariables = false;
  streammask = 17;
  RecompilationRequiredOnPlatforms = 0;
  supportedplatforms = 551;
  perprimitive_callback = "RandomPrimColor";
  compileflags = 0;
  hs_controlpoints = 3;

  //------ Texture samplers ------
  numsamplers_vs = 0;
  numsamplers_hs = 0;
  numsamplers_ds = 0;
  numsamplers_gs = 0;
  numsamplers_ps = 1;
  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;
  }
  numsamplers_cs = 0;

  //------ vertex shader source ------
  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_function = "ps_primcolor";
  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 VisAreaColor {
  RenderStateContainerID = 6;
  IsAutoGenerated = false;
  UsesPermutationVariables = false;
  streammask = 17;
  RecompilationRequiredOnPlatforms = 0;
  supportedplatforms = 551;
  perprimitive_callback = "PrimVisArea";
  compileflags = 0;
  hs_controlpoints = 3;

  //------ Texture samplers ------
  numsamplers_vs = 0;
  numsamplers_hs = 0;
  numsamplers_ds = 0;
  numsamplers_gs = 0;
  numsamplers_ps = 1;
  SAMPLER_PS 0 = {
    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_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_function = "ps_visareacolor";
  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 StandardBlink {
  DESCRIPTION = {};
  TECHNIQUE "all"
  {
    passes="StandardBlink";
    passtype = post_basepass;
    IsPermutationTechnique=false;
    IsAutoGenerated=false;
  }
}

EFFECT Overdraw {
  DESCRIPTION = {};
  TECHNIQUE "all"
  {
    passes="Overdraw";
    passtype = post_basepass;
    IsPermutationTechnique=false;
    IsAutoGenerated=false;
  }
}

EFFECT ColorNormals {
  DESCRIPTION = {};
  TECHNIQUE "all"
  {
    passes="ColorNormals";
    passtype = post_basepass;
    IsPermutationTechnique=false;
    IsAutoGenerated=false;
  }
}

EFFECT Lightmap {
  DESCRIPTION = {};
  TECHNIQUE "all"
  {
    passes="Lightmap";
    passtype = post_basepass;
    IsPermutationTechnique=false;
    IsAutoGenerated=false;
  }
}

EFFECT NormalMap {
  DESCRIPTION = {};
  TECHNIQUE "all"
  {
    passes="Normalmap";
    passtype = post_basepass;
    IsPermutationTechnique=false;
    IsAutoGenerated=false;
  }
}

EFFECT PrimColor {
  DESCRIPTION = {};
  TECHNIQUE "all"
  {
    passes="PrimColor";
    passtype = post_basepass;
    IsPermutationTechnique=false;
    IsAutoGenerated=false;
  }
}

EFFECT CollisionPrims {
  DESCRIPTION = {};
  TECHNIQUE "all"
  {
    passes="PrimColor";
    passtype = post_basepass;
    IsPermutationTechnique=false;
    IsAutoGenerated=false;
  }
}

EFFECT VisArea {
  DESCRIPTION = {};
  TECHNIQUE "all"
  {
    passes="VisAreaColor";
    passtype = post_basepass;
    IsPermutationTechnique=false;
    IsAutoGenerated=false;
  }
}

