
cbuffer PER_BATCH : register(b0)
{
  float3 slHazeColPartialMieInScatter : packoffset(c0);
  float4 miscCamFront : packoffset(c1);
  float3 vfColGradDelta : packoffset(c2);
  float4 vfRampParams : packoffset(c3);
  float4 PS_NearFarClipDist : packoffset(c4);
  float3 slSunDirection : packoffset(c5);
  float4 CameraFrontVector : packoffset(c6);
  float3 vfColGradBase : packoffset(c7);
  float3 slHazeColPartialRayleighInScatter : packoffset(c8);
  float3 vfFogColor : packoffset(c9);
  float3 slPhaseFunctionConstants : packoffset(c10);
  float4 vfParams : packoffset(c11);
  float4 vfViewPos : packoffset(c12);
}

cbuffer PER_INSTANCE : register(b1)
{
  float4 TexTileSize : packoffset(c0);
  float4 ParticleParams : packoffset(c1);
}

cbuffer PER_FRAME : register(b3)
{
  row_major float4x4 g_VS_ViewProjMatr : packoffset(c0);
  float4 g_VS_WorldViewPos : packoffset(c6);
}

Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);

void main( 
  float4 v0 : POSITION0,
  float4 v1 : COLOR0,
  float4 v2 : COLOR1,
  float4 v3 : PSIZE0,
  out float4 o0 : SV_Position0,
  out float4 o1 : TEXCOORD0,
  out float4 o2 : TEXCOORD1,
  out float4 o3 : TEXCOORD2,
  out float o4 : TEXCOORD3,
  out float p4 : COLOR1,
  out float4 o5 : TEXCOORD4,
  out float4 o6 : TEXCOORD5,
  out float4 o7 : COLOR0)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyz = vfViewPos.zxy + -v0.zxy;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  r1.xyz = -CameraFrontVector.zxy * CameraFrontVector.zzz + float3(1,0,0);
  r2.xyz = r1.xyz * r0.zxy;
  r1.xyz = r1.zxy * r0.xyz + -r2.xyz;
  r0.w = dot(r1.xyz, r1.xyz);
  r0.w = rsqrt(r0.w);
  r1.xyz = r1.xyz * r0.www;
  r2.xyz = r1.yzx * r0.xyz;
  r0.xyz = r0.zxy * r1.zxy + -r2.xyz;
  r2.xyzw = v2.xxyy * float4(2,2,-2,-2) + float4(-1,-1,1,1);
  r2.xyzw = v3.xyzw * r2.xyzw;
  r3.xyz = r2.yyy * r0.xyz;
  r0.xyz = r2.www * r0.xyz;
  r0.xyz = r1.xyz * r2.zzz + r0.xyz;
  r1.xyz = r1.xyz * r2.xxx + r3.xyz;
  r0.xyz = r1.xyz + r0.xyz;
  r0.xyz = v0.xyz + r0.xyz;
  r0.w = abs(v3.x) + abs(v3.y);
  r0.w = 0 < r0.w;
  r0.w = (int)-r0.w;
  r0.w = 0 != r0.w;
  r1.xyz = r0.www ? r0.xyz : v0.xyz;
  r1.w = 1;
  r3.x = dot(g_VS_ViewProjMatr._m00_m01_m02_m03, r1.xyzw);
  r3.y = dot(g_VS_ViewProjMatr._m10_m11_m12_m13, r1.xyzw);
  r3.z = dot(g_VS_ViewProjMatr._m20_m21_m22_m23, r1.xyzw);
  r3.w = dot(g_VS_ViewProjMatr._m30_m31_m32_m33, r1.xyzw);
  o0.xyzw = r3.xyzw;
  
  float4 stereo = StereoParams.Load(0);
  r3.x += stereo.x * (r3.w - stereo.y);
  
  r0.xy = r3.xy * float2(1,-1) + r3.ww;
  o3.zw = r3.zw;
  o3.xy = float2(0.5,0.5) * r0.xy;
  r0.x = v2.z * TexTileSize.z + TexTileSize.w;
  r0.x = floor(r0.x);
  r0.x = TexTileSize.x * r0.x;
  r0.y = floor(r0.x);
  r0.x = frac(r0.x);
  o1.x = v2.x * TexTileSize.x + r0.x;
  r0.x = TexTileSize.y * v2.y;
  o1.y = r0.y * TexTileSize.y + r0.x;
  o1.z = ParticleParams.y;
  o1.w = 0;
  o2.xyz = r1.xyz;
  o2.w = 0;
  r0.x = r2.y * r2.z;
  r0.x = r2.x * r2.w + -r0.x;
  r0.x = sqrt(abs(r0.x));
  o4.x = 3 / r0.x;
  p4.x = v2.w;
  r0.xyz = -g_VS_WorldViewPos.xyz + r1.xyz;
  r1.w = vfParams.x * r0.z;
  r2.x = -1.44269502 * r1.w;
  r2.x = exp2(r2.x);
  r2.x = 1 + -r2.x;
  r1.w = r2.x / r1.w;
  r2.x = 0.00999999978 < abs(r0.z);
  r1.w = r2.x ? r1.w : 1;
  r0.x = dot(r0.xyz, r0.xyz);
  r0.y = sqrt(r0.x);
  r0.x = rsqrt(r0.x);
  r0.x = saturate(r0.z * r0.x);
  o5.xyz = r0.xxx * vfColGradDelta.xyz + vfColGradBase.xyz;
  r0.x = vfParams.y * r0.y;
  r0.y = saturate(r0.y * vfRampParams.x + vfRampParams.y);
  r0.x = r1.w * r0.x + -vfParams.w;
  r0.x = exp2(-r0.x);
  r0.x = min(1, r0.x);
  r0.x = 1 + -r0.x;
  r0.z = 2 + -r0.y;
  r0.y = r0.y * r0.z;
  r0.y = r0.y * vfRampParams.z + vfRampParams.w;
  o5.w = -r0.x * r0.y + 1;
  r0.xyz = -v0.xyz + r1.xyz;
  r1.xyz = vfViewPos.xyz + -r1.xyz;
  r1.w = dot(r1.xyz, r0.xyz);
  r2.x = dot(r1.xyz, r1.xyz);
  r1.w = r1.w / r2.x;
  r0.xyz = -r1.xyz * r1.www + r0.xyz;
  r0.xyz = r0.www ? r0.xyz : r1.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  o6.xyz = r0.xyz * r0.www;
  o6.w = 0;
  o7.w = ParticleParams.x * v1.w;
  o7.xyz = v1.zyx;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022
//
//   using 3Dmigoto v1.2.1 on Sun Aug 30 15:16:23 2015
//
//
// Buffer Definitions: 
//
// cbuffer PER_BATCH
// {
//
//   float3 slHazeColPartialMieInScatter;// Offset:    0 Size:    12 [unused]
//   float4 miscCamFront;               // Offset:   16 Size:    16 [unused]
//   float3 vfColGradDelta;             // Offset:   32 Size:    12
//   float4 vfRampParams;               // Offset:   48 Size:    16
//   float4 PS_NearFarClipDist;         // Offset:   64 Size:    16 [unused]
//   float3 slSunDirection;             // Offset:   80 Size:    12 [unused]
//   float4 CameraFrontVector;          // Offset:   96 Size:    16
//   float3 vfColGradBase;              // Offset:  112 Size:    12
//   float3 slHazeColPartialRayleighInScatter;// Offset:  128 Size:    12 [unused]
//   float3 vfFogColor;                 // Offset:  144 Size:    12 [unused]
//   float3 slPhaseFunctionConstants;   // Offset:  160 Size:    12 [unused]
//   float4 vfParams;                   // Offset:  176 Size:    16
//   float4 vfViewPos;                  // Offset:  192 Size:    16
//
// }
//
// cbuffer PER_INSTANCE
// {
//
//   float4 TexTileSize;                // Offset:    0 Size:    16
//   float4 ParticleParams;             // Offset:   16 Size:    16
//
// }
//
// cbuffer PER_FRAME
// {
//
//   row_major float4x4 g_VS_ViewProjMatr;// Offset:    0 Size:    64
//   float4 g_VS_WorldViewPos;          // Offset:   96 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// PER_BATCH                         cbuffer      NA          NA    0        1
// PER_INSTANCE                      cbuffer      NA          NA    1        1
// PER_FRAME                         cbuffer      NA          NA    3        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz 
// COLOR                    0   xyzw        1     NONE   float   xyzw
// COLOR                    1   xyzw        2     NONE   float   xyzw
// PSIZE                    0   xyzw        3     NONE   float   xyzw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 1   xyzw        2     NONE   float   xyzw
// TEXCOORD                 2   xyzw        3     NONE   float   xyzw
// TEXCOORD                 3   x           4     NONE   float   x   
// COLOR                    1    y          4     NONE   float    y  
// TEXCOORD                 4   xyzw        5     NONE   float   xyzw
// TEXCOORD                 5   xyzw        6     NONE   float   xyzw
// COLOR                    0   xyzw        7     NONE   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[13], immediateIndexed
dcl_constantbuffer cb1[2], immediateIndexed
dcl_constantbuffer cb3[7], immediateIndexed
dcl_input v0.xyz
dcl_input v1.xyzw
dcl_input v2.xyzw
dcl_input v3.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output o4.x
dcl_output o4.y
dcl_output o5.xyzw
dcl_output o6.xyzw
dcl_output o7.xyzw
dcl_temps 4
add r0.xyz, -v0.zxyz, cb0[12].zxyz
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
mad r1.xyz, -cb0[6].zxyz, cb0[6].zzzz, l(1.000000, 0.000000, 0.000000, 0.000000)
mul r2.xyz, r0.zxyz, r1.xyzx
mad r1.xyz, r1.zxyz, r0.xyzx, -r2.xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
mul r2.xyz, r0.xyzx, r1.yzxy
mad r0.xyz, r0.zxyz, r1.zxyz, -r2.xyzx
mad r2.xyzw, v2.xxyy, l(2.000000, 2.000000, -2.000000, -2.000000), l(-1.000000, -1.000000, 1.000000, 1.000000)
mul r2.xyzw, r2.xyzw, v3.xyzw
mul r3.xyz, r0.xyzx, r2.yyyy
mul r0.xyz, r0.xyzx, r2.wwww
mad r0.xyz, r1.xyzx, r2.zzzz, r0.xyzx
mad r1.xyz, r1.xyzx, r2.xxxx, r3.xyzx
add r0.xyz, r0.xyzx, r1.xyzx
add r0.xyz, r0.xyzx, v0.xyzx
add r0.w, |v3.y|, |v3.x|
lt r0.w, l(0.000000), r0.w
itof r0.w, -r0.w
ne r0.w, l(0.000000, 0.000000, 0.000000, 0.000000), r0.w
movc r1.xyz, r0.wwww, r0.xyzx, v0.xyzx
mov r1.w, l(1.000000)
dp4 r3.x, cb3[0].xyzw, r1.xyzw
dp4 r3.y, cb3[1].xyzw, r1.xyzw
dp4 r3.z, cb3[2].xyzw, r1.xyzw
dp4 r3.w, cb3[3].xyzw, r1.xyzw
mov o0.xyzw, r3.xyzw
mad r0.xy, r3.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000), r3.wwww
mov o3.zw, r3.zzzw
mul o3.xy, r0.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
mad r0.x, v2.z, cb1[0].z, cb1[0].w
round_ni r0.x, r0.x
mul r0.x, r0.x, cb1[0].x
round_ni r0.y, r0.x
frc r0.x, r0.x
mad o1.x, v2.x, cb1[0].x, r0.x
mul r0.x, v2.y, cb1[0].y
mad o1.y, r0.y, cb1[0].y, r0.x
mov o1.z, cb1[1].y
mov o1.w, l(0)
mov o2.xyz, r1.xyzx
mov o2.w, l(0)
mul r0.x, r2.z, r2.y
mad r0.x, r2.x, r2.w, -r0.x
sqrt r0.x, |r0.x|
div o4.x, l(3.000000), r0.x
mov o4.y, v2.w
add r0.xyz, r1.xyzx, -cb3[6].xyzx
mul r1.w, r0.z, cb0[11].x
mul r2.x, r1.w, l(-1.442695)
exp r2.x, r2.x
add r2.x, -r2.x, l(1.000000)
div r1.w, r2.x, r1.w
lt r2.x, l(0.010000), |r0.z|
movc r1.w, r2.x, r1.w, l(1.000000)
dp3 r0.x, r0.xyzx, r0.xyzx
sqrt r0.y, r0.x
rsq r0.x, r0.x
mul_sat r0.x, r0.x, r0.z
mad o5.xyz, r0.xxxx, cb0[2].xyzx, cb0[7].xyzx
mul r0.x, r0.y, cb0[11].y
mad_sat r0.y, r0.y, cb0[3].x, cb0[3].y
mad r0.x, r1.w, r0.x, -cb0[11].w
exp r0.x, -r0.x
min r0.x, r0.x, l(1.000000)
add r0.x, -r0.x, l(1.000000)
add r0.z, -r0.y, l(2.000000)
mul r0.y, r0.z, r0.y
mad r0.y, r0.y, cb0[3].z, cb0[3].w
mad o5.w, -r0.x, r0.y, l(1.000000)
add r0.xyz, r1.xyzx, -v0.xyzx
add r1.xyz, -r1.xyzx, cb0[12].xyzx
dp3 r1.w, r1.xyzx, r0.xyzx
dp3 r2.x, r1.xyzx, r1.xyzx
div r1.w, r1.w, r2.x
mad r0.xyz, -r1.xyzx, r1.wwww, r0.xyzx
movc r0.xyz, r0.wwww, r0.xyzx, r1.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul o6.xyz, r0.wwww, r0.xyzx
mov o6.w, l(0)
mul o7.w, v1.w, cb1[1].x
mov o7.xyz, v1.zyxz
ret 
// Approximately 88 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
