// ---- Created with 3Dmigoto v1.2.39 on Mon Jun 20 06:43:37 2016

cbuffer _Globals : register(b0)
{
  float4x4 ScreenToWorldMatrix : packoffset(c0);
  bool bDecompressSceneColor : packoffset(c4);
  float4 ShadowModulateColor : packoffset(c5);
  float4 LightPosition : packoffset(c6);
  float4x4 ScreenToWorld : packoffset(c7);
  float3 FalloffParameters : packoffset(c11);
  float3 SpotDirection : packoffset(c12);
  float2 SpotAngles : packoffset(c13);
  float4 SampleOffsets[8] : packoffset(c14);
  float3 ShadowBufferSizeAndSoftTransitionScale : packoffset(c22);
  float2 ShadowTexelSize : packoffset(c23);
  float LightingChannelMask : packoffset(c23.z);
  float SkipModShadow : packoffset(c23.w);
  float4x4 ScreenToShadowMatrix : packoffset(c24);
}

cbuffer PSOffsetConstants : register(b2)
{
  float4 ScreenPositionScaleBias : packoffset(c0);
  float4 MinZ_MaxZRatio : packoffset(c1);
  float NvStereoEnabled : packoffset(c2);
  float4 DiffuseOverrideParameter : packoffset(c3);
  float4 SpecularOverrideParameter : packoffset(c4);
  float4 CameraPositionPS : packoffset(c5);
  float4 ScreenAndTexelSize : packoffset(c6);
}

SamplerState DiffuseGBufferTextureSampler_s : register(s0);
SamplerState SceneDepthTextureSampler_s : register(s1);
SamplerState NvStereoFixTextureSampler_s : register(s2);
SamplerState ShadowDepthTextureSampler_s : register(s3);
Texture2D<float4> DiffuseGBufferTexture : register(t0);
Texture2D<float4> SceneDepthTexture : register(t1);
Texture2D<float4> NvStereoFixTexture : register(t2);
Texture2D<float4> ShadowDepthTexture : register(t3);


// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);


void main( 
  float4 v0 : TEXCOORD0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r20;
  uint4 bitmask, uiDest;
  float4 fDest;

r20.xyw = v0.xyw;
float4 stereo = StereoParams.Load(0);
r20.x += stereo.x*(r20.w - stereo.y);

  r0.xy = r20.xy / v0.ww;
  r0.zw = r0.xy * ScreenPositionScaleBias.xy + ScreenPositionScaleBias.wz;
  r0.z = DiffuseGBufferTexture.SampleLevel(DiffuseGBufferTextureSampler_s, r0.zw, 0).w;
  r0.z = 64 * r0.z;
  r0.w = cmp(0 != SkipModShadow);
  r0.z = (int)r0.z;
  r1.x = LightingChannelMask;
  r0.z = (int)r0.z & (int)r1.x;
  r0.z = cmp((int)r0.z != 0);
  r0.z = (int)r0.z | (int)r0.w;
  if (r0.z != 0) {
    r0.z = cmp(0 != NvStereoEnabled);
    if (r0.z != 0) {
      r1.xy = NvStereoFixTexture.Sample(NvStereoFixTextureSampler_s, float2(0.0625,0)).xy;
      r0.w = v0.w + -r1.y;
      r1.x = r1.x * r0.w + v0.x;
      r1.yz = v0.yw;
    }
    r1.xyz = r0.zzz ? r1.xyz : v0.xyw;
    r0.zw = r1.xy / r1.zz;
    r0.zw = r0.zw * ScreenPositionScaleBias.xy + ScreenPositionScaleBias.wz;
    r0.z = SceneDepthTexture.SampleLevel(SceneDepthTextureSampler_s, r0.zw, 0).x;
    r0.z = min(0.999000013, r0.z);
    r0.z = r0.z * MinZ_MaxZRatio.z + -MinZ_MaxZRatio.w;
    r0.z = 1 / r0.z;
    r0.xy = r0.xy * r0.zz;

r0.x -= stereo.x*(r0.z - stereo.y);

    r1.xyzw = ScreenToShadowMatrix._m01_m11_m21_m31 * r0.yyyy;
    r1.xyzw = ScreenToShadowMatrix._m00_m10_m20_m30 * r0.xxxx + r1.xyzw;
    r1.xyzw = ScreenToShadowMatrix._m02_m12_m22_m32 * r0.zzzz + r1.xyzw;
    r1.xyzw = ScreenToShadowMatrix._m03_m13_m23_m33 + r1.xyzw;
    r1.xy = r1.xy / r1.ww;
    r0.w = min(0.999000013, r1.z);
    r1.zw = ShadowBufferSizeAndSoftTransitionScale.xy * r1.xy;
    r1.zw = frac(r1.zw);
    r1.xy = r1.xy * ShadowBufferSizeAndSoftTransitionScale.xy + float2(-1,-1);
    r1.xy = floor(r1.xy);
    r2.xy = ShadowTexelSize.xy * r1.xy;
    r2.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r2.xy, 0).x;
    r2.x = r2.x + -r0.w;
    r2.x = saturate(r2.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r3.xyzw = float4(1,0,2,0) + r1.xyxy;
    r3.xyzw = ShadowTexelSize.xyxy * r3.xyzw;
    r3.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r3.xy, 0).x;
    r3.x = r3.x + -r0.w;
    r4.x = saturate(r3.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r3.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r3.zw, 0).x;
    r3.x = r3.x + -r0.w;
    r3.x = saturate(r3.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.xyzw = float4(3,0,0,1) + r1.xyxy;
    r5.xyzw = ShadowTexelSize.xyxy * r5.xyzw;
    r5.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r5.xy, 0).x;
    r5.x = r5.x + -r0.w;
    r6.x = saturate(r5.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r5.zw, 0).x;
    r5.x = r5.x + -r0.w;
    r2.y = saturate(r5.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.xyzw = float4(1,1,2,1) + r1.xyxy;
    r5.xyzw = ShadowTexelSize.xyxy * r5.xyzw;
    r5.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r5.xy, 0).x;
    r5.x = r5.x + -r0.w;
    r4.y = saturate(r5.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r5.zw, 0).x;
    r5.x = r5.x + -r0.w;
    r3.y = saturate(r5.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.xyzw = float4(3,1,0,2) + r1.xyxy;
    r5.xyzw = ShadowTexelSize.xyxy * r5.xyzw;
    r5.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r5.xy, 0).x;
    r5.x = r5.x + -r0.w;
    r6.y = saturate(r5.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r5.zw, 0).x;
    r5.x = r5.x + -r0.w;
    r2.z = saturate(r5.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.xyzw = float4(1,2,2,2) + r1.xyxy;
    r5.xyzw = ShadowTexelSize.xyxy * r5.xyzw;
    r5.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r5.xy, 0).x;
    r5.x = r5.x + -r0.w;
    r4.z = saturate(r5.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r5.zw, 0).x;
    r5.x = r5.x + -r0.w;
    r3.z = saturate(r5.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.xyzw = float4(3,2,0,3) + r1.xyxy;
    r5.xyzw = ShadowTexelSize.xyxy * r5.xyzw;
    r5.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r5.xy, 0).x;
    r5.x = r5.x + -r0.w;
    r6.z = saturate(r5.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r5.zw, 0).x;
    r5.x = r5.x + -r0.w;
    r2.w = saturate(r5.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.xyzw = float4(1,3,2,3) + r1.xyxy;
    r5.xyzw = ShadowTexelSize.xyxy * r5.xyzw;
    r5.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r5.xy, 0).x;
    r5.x = r5.x + -r0.w;
    r4.w = saturate(r5.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r5.zw, 0).x;
    r5.x = r5.x + -r0.w;
    r3.w = saturate(r5.x * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r1.xy = float2(3,3) + r1.xy;
    r1.xy = ShadowTexelSize.xy * r1.xy;
    r1.x = ShadowDepthTexture.SampleLevel(ShadowDepthTextureSampler_s, r1.xy, 0).x;
    r0.w = r1.x + -r0.w;
    r6.w = saturate(r0.w * ShadowBufferSizeAndSoftTransitionScale.z + 1);
    r5.xyzw = r4.xyyz + -r2.xyyz;
    r5.xyzw = r1.zzzz * r5.xyzw + r2.xyyz;
    r1.xy = r5.yw + -r5.xz;
    r7.xyzw = -r4.xyyz + r3.xyyz;
    r7.xyzw = r1.zzzz * r7.xyzw + r4.xyyz;
    r2.xy = r7.yw + -r7.xz;
    r8.xyzw = r6.xyyz + -r3.xyyz;
    r8.xyzw = r1.zzzz * r8.xyzw + r3.xyyz;
    r3.xy = r8.yw + -r8.xz;
    r1.xy = r1.ww * r1.xy + r5.xz;
    r2.xy = r1.ww * r2.xy + r7.xz;
    r3.xy = r1.ww * r3.xy + r8.xz;
    r4.xy = r4.zw + -r2.zw;
    r2.zw = r1.zz * r4.xy + r2.zw;
    r0.w = r2.w + -r2.z;
    r0.w = r1.w * r0.w + r2.z;
    r2.zw = -r4.zw + r3.zw;
    r2.zw = r1.zz * r2.zw + r4.zw;
    r2.w = r2.w + -r2.z;
    r2.z = r1.w * r2.w + r2.z;
    r4.xy = r6.zw + -r3.zw;
    r3.zw = r1.zz * r4.xy + r3.zw;
    r1.z = r3.w + -r3.z;
    r1.z = r1.w * r1.z + r3.z;
    r1.x = r2.x + r1.x;
    r1.x = r1.x + r3.x;
    r1.x = r1.x + r1.y;
    r1.x = r1.x + r2.y;
    r1.x = r1.x + r3.y;
    r0.w = r1.x + r0.w;
    r0.w = r0.w + r2.z;
    r0.w = r0.w + r1.z;
    r0.w = saturate(0.111110002 * r0.w);
    r1.xyz = ScreenToWorld._m01_m11_m21 * r0.yyy;
    r1.xyz = ScreenToWorld._m00_m10_m20 * r0.xxx + r1.xyz;
    r0.xyz = ScreenToWorld._m02_m12_m22 * r0.zzz + r1.xyz;
    r0.xyz = ScreenToWorld._m03_m13_m23 + r0.xyz;
    r0.xyz = LightPosition.xyz + -r0.xyz;
    r0.xyz = LightPosition.www * r0.xyz;
    r1.x = dot(r0.xyz, r0.xyz);
    r1.y = sqrt(r1.x);
    r1.y = r1.y * FalloffParameters.y + FalloffParameters.z;
    r1.y = max(0, r1.y);
    r1.y = -r1.y * r1.y + 1;
    r1.y = max(0, r1.y);
    r1.y = log2(r1.y);
    r1.y = FalloffParameters.x * r1.y;
    r1.y = exp2(r1.y);
    r1.x = rsqrt(r1.x);
    r0.xyz = r1.xxx * r0.xyz;
    r0.x = dot(r0.xyz, -SpotDirection.xyz);
    r0.x = -SpotAngles.x + r0.x;
    r0.x = saturate(SpotAngles.y * r0.x);
    r0.x = r0.x * r0.x;
    r0.x = r1.y * r0.x;
    r1.xyzw = float4(-1,-1,-1,-1) + ShadowModulateColor.xyzw;
    r1.xyzw = r0.xxxx * r1.xyzw + float4(1,1,1,1);
    r0.x = r0.w * r0.w;
    r2.xyzw = float4(1,1,1,1) + -r1.xyzw;
    o0.xyzw = r0.xxxx * r2.xyzw + r1.xyzw;
  } else {
    o0.xyzw = float4(1,1,1,1);
  }
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.39 on Mon Jun 20 06:43:37 2016
//
//
// Note: shader requires additional functionality:
//       Early depth-stencil
//
//
// Buffer Definitions: 
//
// cbuffer $Globals
// {
//
//   float4x4 ScreenToWorldMatrix;      // Offset:    0 Size:    64 [unused]
//   bool bDecompressSceneColor;        // Offset:   64 Size:     4 [unused]
//   float4 ShadowModulateColor;        // Offset:   80 Size:    16
//   float4 LightPosition;              // Offset:   96 Size:    16
//   float4x4 ScreenToWorld;            // Offset:  112 Size:    64
//   float3 FalloffParameters;          // Offset:  176 Size:    12
//   float3 SpotDirection;              // Offset:  192 Size:    12
//   float2 SpotAngles;                 // Offset:  208 Size:     8
//   float4 SampleOffsets[8];           // Offset:  224 Size:   128 [unused]
//   float3 ShadowBufferSizeAndSoftTransitionScale;// Offset:  352 Size:    12
//   float2 ShadowTexelSize;            // Offset:  368 Size:     8
//   float LightingChannelMask;         // Offset:  376 Size:     4
//   float SkipModShadow;               // Offset:  380 Size:     4
//   float4x4 ScreenToShadowMatrix;     // Offset:  384 Size:    64
//
// }
//
// cbuffer PSOffsetConstants
// {
//
//   float4 ScreenPositionScaleBias;    // Offset:    0 Size:    16
//   float4 MinZ_MaxZRatio;             // Offset:   16 Size:    16
//   float NvStereoEnabled;             // Offset:   32 Size:     4
//   float4 DiffuseOverrideParameter;   // Offset:   48 Size:    16 [unused]
//   float4 SpecularOverrideParameter;  // Offset:   64 Size:    16 [unused]
//   float4 CameraPositionPS;           // Offset:   80 Size:    16 [unused]
//   float4 ScreenAndTexelSize;         // Offset:   96 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// DiffuseGBufferTextureSampler      sampler      NA          NA    0        1
// SceneDepthTextureSampler          sampler      NA          NA    1        1
// NvStereoFixTextureSampler         sampler      NA          NA    2        1
// ShadowDepthTextureSampler         sampler      NA          NA    3        1
// DiffuseGBufferTexture             texture  float4          2d    0        1
// SceneDepthTexture                 texture  float4          2d    1        1
// NvStereoFixTexture                texture  float4          2d    2        1
// ShadowDepthTexture                texture  float4          2d    3        1
// $Globals                          cbuffer      NA          NA    0        1
// PSOffsetConstants                 cbuffer      NA          NA    2        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xyzw        0     NONE   float   xy w
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed | forceEarlyDepthStencil
dcl_constantbuffer cb0[28], immediateIndexed
dcl_constantbuffer cb2[3], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t2
dcl_resource_texture2d (float,float,float,float) t3
dcl_input_ps linear v0.xyw
dcl_output o0.xyzw
dcl_temps 9
div r0.xy, v0.xyxx, v0.wwww
mad r0.zw, r0.xxxy, cb2[0].xxxy, cb2[0].wwwz
sample_l_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t0.xywz, s0, l(0.000000)
mul r0.z, r0.z, l(64.000000)
ne r0.w, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[23].w
ftoi r0.z, r0.z
ftoi r1.x, cb0[23].z
and r0.z, r0.z, r1.x
ine r0.z, r0.z, l(0)
or r0.z, r0.z, r0.w
if_nz r0.z
  ne r0.z, l(0.000000, 0.000000, 0.000000, 0.000000), cb2[2].x
  if_nz r0.z
    sample_indexable(texture2d)(float,float,float,float) r1.xy, l(0.062500, 0.000000, 0.000000, 0.000000), t2.xyzw, s2
    add r0.w, -r1.y, v0.w
    mad r1.x, r1.x, r0.w, v0.x
    mov r1.yz, v0.yywy
  endif 
  movc r1.xyz, r0.zzzz, r1.xyzx, v0.xywx
  div r0.zw, r1.xxxy, r1.zzzz
  mad r0.zw, r0.zzzw, cb2[0].xxxy, cb2[0].wwwz
  sample_l_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t1.yzxw, s1, l(0.000000)
  min r0.z, r0.z, l(0.999000)
  mad r0.z, r0.z, cb2[1].z, -cb2[1].w
  div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
  mul r0.xy, r0.zzzz, r0.xyxx
  mul r1.xyzw, r0.yyyy, cb0[25].xyzw
  mad r1.xyzw, cb0[24].xyzw, r0.xxxx, r1.xyzw
  mad r1.xyzw, cb0[26].xyzw, r0.zzzz, r1.xyzw
  add r1.xyzw, r1.xyzw, cb0[27].xyzw
  div r1.xy, r1.xyxx, r1.wwww
  min r0.w, r1.z, l(0.999000)
  mul r1.zw, r1.xxxy, cb0[22].xxxy
  frc r1.zw, r1.zzzw
  mad r1.xy, r1.xyxx, cb0[22].xyxx, l(-1.000000, -1.000000, 0.000000, 0.000000)
  round_ni r1.xy, r1.xyxx
  mul r2.xy, r1.xyxx, cb0[23].xyxx
  sample_l_indexable(texture2d)(float,float,float,float) r2.x, r2.xyxx, t3.xyzw, s3, l(0.000000)
  add r2.x, -r0.w, r2.x
  mad_sat r2.x, r2.x, cb0[22].z, l(1.000000)
  add r3.xyzw, r1.xyxy, l(1.000000, 0.000000, 2.000000, 0.000000)
  mul r3.xyzw, r3.xyzw, cb0[23].xyxy
  sample_l_indexable(texture2d)(float,float,float,float) r3.x, r3.xyxx, t3.xyzw, s3, l(0.000000)
  add r3.x, -r0.w, r3.x
  mad_sat r4.x, r3.x, cb0[22].z, l(1.000000)
  sample_l_indexable(texture2d)(float,float,float,float) r3.x, r3.zwzz, t3.xyzw, s3, l(0.000000)
  add r3.x, -r0.w, r3.x
  mad_sat r3.x, r3.x, cb0[22].z, l(1.000000)
  add r5.xyzw, r1.xyxy, l(3.000000, 0.000000, 0.000000, 1.000000)
  mul r5.xyzw, r5.xyzw, cb0[23].xyxy
  sample_l_indexable(texture2d)(float,float,float,float) r5.x, r5.xyxx, t3.xyzw, s3, l(0.000000)
  add r5.x, -r0.w, r5.x
  mad_sat r6.x, r5.x, cb0[22].z, l(1.000000)
  sample_l_indexable(texture2d)(float,float,float,float) r5.x, r5.zwzz, t3.xyzw, s3, l(0.000000)
  add r5.x, -r0.w, r5.x
  mad_sat r2.y, r5.x, cb0[22].z, l(1.000000)
  add r5.xyzw, r1.xyxy, l(1.000000, 1.000000, 2.000000, 1.000000)
  mul r5.xyzw, r5.xyzw, cb0[23].xyxy
  sample_l_indexable(texture2d)(float,float,float,float) r5.x, r5.xyxx, t3.xyzw, s3, l(0.000000)
  add r5.x, -r0.w, r5.x
  mad_sat r4.y, r5.x, cb0[22].z, l(1.000000)
  sample_l_indexable(texture2d)(float,float,float,float) r5.x, r5.zwzz, t3.xyzw, s3, l(0.000000)
  add r5.x, -r0.w, r5.x
  mad_sat r3.y, r5.x, cb0[22].z, l(1.000000)
  add r5.xyzw, r1.xyxy, l(3.000000, 1.000000, 0.000000, 2.000000)
  mul r5.xyzw, r5.xyzw, cb0[23].xyxy
  sample_l_indexable(texture2d)(float,float,float,float) r5.x, r5.xyxx, t3.xyzw, s3, l(0.000000)
  add r5.x, -r0.w, r5.x
  mad_sat r6.y, r5.x, cb0[22].z, l(1.000000)
  sample_l_indexable(texture2d)(float,float,float,float) r5.x, r5.zwzz, t3.xyzw, s3, l(0.000000)
  add r5.x, -r0.w, r5.x
  mad_sat r2.z, r5.x, cb0[22].z, l(1.000000)
  add r5.xyzw, r1.xyxy, l(1.000000, 2.000000, 2.000000, 2.000000)
  mul r5.xyzw, r5.xyzw, cb0[23].xyxy
  sample_l_indexable(texture2d)(float,float,float,float) r5.x, r5.xyxx, t3.xyzw, s3, l(0.000000)
  add r5.x, -r0.w, r5.x
  mad_sat r4.z, r5.x, cb0[22].z, l(1.000000)
  sample_l_indexable(texture2d)(float,float,float,float) r5.x, r5.zwzz, t3.xyzw, s3, l(0.000000)
  add r5.x, -r0.w, r5.x
  mad_sat r3.z, r5.x, cb0[22].z, l(1.000000)
  add r5.xyzw, r1.xyxy, l(3.000000, 2.000000, 0.000000, 3.000000)
  mul r5.xyzw, r5.xyzw, cb0[23].xyxy
  sample_l_indexable(texture2d)(float,float,float,float) r5.x, r5.xyxx, t3.xyzw, s3, l(0.000000)
  add r5.x, -r0.w, r5.x
  mad_sat r6.z, r5.x, cb0[22].z, l(1.000000)
  sample_l_indexable(texture2d)(float,float,float,float) r5.x, r5.zwzz, t3.xyzw, s3, l(0.000000)
  add r5.x, -r0.w, r5.x
  mad_sat r2.w, r5.x, cb0[22].z, l(1.000000)
  add r5.xyzw, r1.xyxy, l(1.000000, 3.000000, 2.000000, 3.000000)
  mul r5.xyzw, r5.xyzw, cb0[23].xyxy
  sample_l_indexable(texture2d)(float,float,float,float) r5.x, r5.xyxx, t3.xyzw, s3, l(0.000000)
  add r5.x, -r0.w, r5.x
  mad_sat r4.w, r5.x, cb0[22].z, l(1.000000)
  sample_l_indexable(texture2d)(float,float,float,float) r5.x, r5.zwzz, t3.xyzw, s3, l(0.000000)
  add r5.x, -r0.w, r5.x
  mad_sat r3.w, r5.x, cb0[22].z, l(1.000000)
  add r1.xy, r1.xyxx, l(3.000000, 3.000000, 0.000000, 0.000000)
  mul r1.xy, r1.xyxx, cb0[23].xyxx
  sample_l_indexable(texture2d)(float,float,float,float) r1.x, r1.xyxx, t3.xyzw, s3, l(0.000000)
  add r0.w, -r0.w, r1.x
  mad_sat r6.w, r0.w, cb0[22].z, l(1.000000)
  add r5.xyzw, -r2.xyyz, r4.xyyz
  mad r5.xyzw, r1.zzzz, r5.xyzw, r2.xyyz
  add r1.xy, -r5.xzxx, r5.ywyy
  add r7.xyzw, r3.xyyz, -r4.xyyz
  mad r7.xyzw, r1.zzzz, r7.xyzw, r4.xyyz
  add r2.xy, -r7.xzxx, r7.ywyy
  add r8.xyzw, -r3.xyyz, r6.xyyz
  mad r8.xyzw, r1.zzzz, r8.xyzw, r3.xyyz
  add r3.xy, -r8.xzxx, r8.ywyy
  mad r1.xy, r1.wwww, r1.xyxx, r5.xzxx
  mad r2.xy, r1.wwww, r2.xyxx, r7.xzxx
  mad r3.xy, r1.wwww, r3.xyxx, r8.xzxx
  add r4.xy, -r2.zwzz, r4.zwzz
  mad r2.zw, r1.zzzz, r4.xxxy, r2.zzzw
  add r0.w, -r2.z, r2.w
  mad r0.w, r1.w, r0.w, r2.z
  add r2.zw, r3.zzzw, -r4.zzzw
  mad r2.zw, r1.zzzz, r2.zzzw, r4.zzzw
  add r2.w, -r2.z, r2.w
  mad r2.z, r1.w, r2.w, r2.z
  add r4.xy, -r3.zwzz, r6.zwzz
  mad r3.zw, r1.zzzz, r4.xxxy, r3.zzzw
  add r1.z, -r3.z, r3.w
  mad r1.z, r1.w, r1.z, r3.z
  add r1.x, r1.x, r2.x
  add r1.x, r3.x, r1.x
  add r1.x, r1.y, r1.x
  add r1.x, r2.y, r1.x
  add r1.x, r3.y, r1.x
  add r0.w, r0.w, r1.x
  add r0.w, r2.z, r0.w
  add r0.w, r1.z, r0.w
  mul_sat r0.w, r0.w, l(0.111110)
  mul r1.xyz, r0.yyyy, cb0[8].xyzx
  mad r1.xyz, cb0[7].xyzx, r0.xxxx, r1.xyzx
  mad r0.xyz, cb0[9].xyzx, r0.zzzz, r1.xyzx
  add r0.xyz, r0.xyzx, cb0[10].xyzx
  add r0.xyz, -r0.xyzx, cb0[6].xyzx
  mul r0.xyz, r0.xyzx, cb0[6].wwww
  dp3 r1.x, r0.xyzx, r0.xyzx
  sqrt r1.y, r1.x
  mad r1.y, r1.y, cb0[11].y, cb0[11].z
  max r1.y, r1.y, l(0.000000)
  mad r1.y, -r1.y, r1.y, l(1.000000)
  max r1.y, r1.y, l(0.000000)
  log r1.y, r1.y
  mul r1.y, r1.y, cb0[11].x
  exp r1.y, r1.y
  rsq r1.x, r1.x
  mul r0.xyz, r0.xyzx, r1.xxxx
  dp3 r0.x, r0.xyzx, -cb0[12].xyzx
  add r0.x, r0.x, -cb0[13].x
  mul_sat r0.x, r0.x, cb0[13].y
  mul r0.x, r0.x, r0.x
  mul r0.x, r0.x, r1.y
  add r1.xyzw, cb0[5].xyzw, l(-1.000000, -1.000000, -1.000000, -1.000000)
  mad r1.xyzw, r0.xxxx, r1.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
  mul r0.x, r0.w, r0.w
  add r2.xyzw, -r1.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
  mad o0.xyzw, r0.xxxx, r2.xyzw, r1.xyzw
else 
  mov o0.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif 
ret 
// Approximately 165 instruction slots used

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