// ---- Created with 3Dmigoto v1.3.11 on Thu Nov 22 18:41:35 2018

cbuffer SFrameCBLayout : register(b0)
{
  float4 u_vHandTunedParams : packoffset(c0);
  row_major float4x4 u_mModelViewProj3d : packoffset(c1);
  row_major float4x4 u_mProjectionInverse3d : packoffset(c5);
  row_major float4x4 u_mModelViewProj2d : packoffset(c9);
  row_major float4x4 u_mCameraFacingMatrix : packoffset(c13);
  row_major float4x4 u_mWorldToViewMatrix : packoffset(c17);
  float3 u_vCameraPosition : packoffset(c21);
  float3 u_vCameraDirection : packoffset(c22);
  float3 u_vLodRefPosition : packoffset(c23);
  float2 u_vViewport : packoffset(c24);
  float2 u_vViewportInverse : packoffset(c24.z);
  float u_fWallTime : packoffset(c25);
  float u_fFarClip : packoffset(c25.y);

  struct
  {
    float3 m_vAmbient;
    float3 m_vDiffuse;
    float3 m_vSpecular;
    float3 m_vTransmission;
    float3 m_vDir;
  } u_sDirLight : packoffset(c26);


  struct
  {
    float4 m_vMapRanges;
    float4 m_avSmoothingTable[3];
    row_major float4x4 m_amLightModelViewProjs[4];
    float2 m_vTexelOffset;
    float m_fFadeStartPercent;
    float m_fFadeInverseDistance;
    float m_fTerrainAmbientOcclusion;
  } u_sShadows : packoffset(c31);

}

cbuffer SInstancingCBLayout : register(b2)
{

  struct
  {
    float4 m_vPosAndScalar;
    float4 m_vUpVectorAndLod0;
    float4 m_vRightVectorAndLod1;
  } g_avInstanceData[1000] : packoffset(c0);

}

cbuffer SWindDynamicsCBLayout : register(b4)
{
  float4 u_vDirection : packoffset(c0);
  float4 u_vAnchor : packoffset(c1);

  struct
  {
    float m_fTime;
    float m_fDistance;
    float m_fHeight;
    float m_fHeightExponent;
    float m_fAdherence;
  } u_sGlobal : packoffset(c2);


  struct
  {
    float m_fBranchTime;
    float m_fBranchDistance;
    float m_fTwitch;
    float m_fTwitchFreqScale;
    float m_fWhip;
    float m_fDirectionAdherence;
    float m_fTurbulence;
  } u_sBranch1 : packoffset(c4);


  struct
  {
    float m_fBranchTime;
    float m_fBranchDistance;
    float m_fTwitch;
    float m_fTwitchFreqScale;
    float m_fWhip;
    float m_fDirectionAdherence;
    float m_fTurbulence;
  } u_sBranch2 : packoffset(c6);


  struct
  {
    float m_fRippleTime;
    float m_fRippleDistance;
    float m_fLeewardScalar;
    float m_fTumbleTime;
    float m_fTumbleFlip;
    float m_fTumbleTwist;
    float m_fTumbleDirectionAdherence;
    float m_fTwitchThrow;
    float m_fTwitchSharpness;
    float m_fTwitchTime;
  } u_sLeaf1 : packoffset(c8);


  struct
  {
    float m_fRippleTime;
    float m_fRippleDistance;
    float m_fLeewardScalar;
    float m_fTumbleTime;
    float m_fTumbleFlip;
    float m_fTumbleTwist;
    float m_fTumbleDirectionAdherence;
    float m_fTwitchThrow;
    float m_fTwitchSharpness;
    float m_fTwitchTime;
  } u_sLeaf2 : packoffset(c11);


  struct
  {
    float m_fFrondTime;
    float m_fFrondDistance;
    float m_fTile;
    float m_fLightingScalar;
  } u_sFrondRipple : packoffset(c14);

  float u_fStrength : packoffset(c15);

  struct
  {
    float m_fBranchFieldMin;
    float m_fBranchLightingAdjust;
    float m_fBranchVerticalOffset;
    float m_fLeafRippleMin;
    float m_fLeafTumbleMin;
    float m_fNoisePeriod;
    float m_fNoiseSize;
    float m_fNoiseTurbulence;
    float m_fNoiseTwist;
    float m_fOffsetX;
    float m_fOffsetY;
    float m_fBranchRipple;
  } u_sRolling : packoffset(c16);

}



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


void main(
  uint v0 : SV_InstanceID0,
  float4 v1 : POSITION0,
  float4 v2 : TEXCOORD0,
  float4 v3 : TEXCOORD1,
  float4 v4 : TEXCOORD2,
  float4 v5 : TEXCOORD3,
  float4 v6 : TEXCOORD4,
  out float4 o0 : SV_POSITION0,
  out float2 o1 : TEXCOORD0)
{
// Needs manual fix for instruction:
// unknown dcl_: dcl_input_sgv v0.x, instance_id
  float4 r0,r1,r2,r3,r4,r5;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyz = float3(0.0625,1,16) * v3.yyy;
  r0.xyz = frac(r0.xyz);
  r0.xyz = r0.xyz * float3(2,2,2) + float3(-1,-1,-1);
  r0.xyz = v3.xxx * r0.xyz;
  r1.xz = float2(-1,1);
  r0.w = (int)v0.x * 3;
  r2.x = g_avInstanceData[r0.w].m_vPosAndScalar.x + g_avInstanceData[r0.w].m_vPosAndScalar.y;
  r2.y = u_sBranch1.m_fBranchTime + r2.x;
  r2.x = u_sBranch2.m_fBranchTime + r2.x;
  r3.x = v3.y + r2.y;
  r3.y = r2.y * u_sBranch1.m_fTwitchFreqScale + v3.y;
  r2.y = u_sBranch1.m_fTwitchFreqScale * r3.x;
  r3.z = 0.5 * r2.y;
  r3.w = -v3.x + r3.x;
  r3.xyzw = float4(0.5,0.5,0.5,1.5) + r3.xyzw;
  r3.xyzw = frac(r3.xyzw);
  r3.xyzw = r3.xyzw * float4(2,2,2,2) + float4(-1,-1,-1,-1);
  r4.xyzw = abs(r3.xyzw) * abs(r3.xyzw);
  r3.xyzw = -abs(r3.xyzw) * float4(2,2,2,2) + float4(3,3,3,3);
  r3.xyzw = r4.xyzw * r3.xyzw + float4(-0.5,-0.5,-0.5,-0.5);
  r2.yzw = float3(2,2,2) * r3.xyz;
  r3.x = u_sBranch1.m_fWhip * r3.w;
  r3.x = dot(r3.xx, v3.xx);
  r3.x = 1 + r3.x;
  r1.w = r2.z * r2.w;
  r3.y = cmp(r1.w < 0);
  r1.y = -r1.w;
  r1.xy = r3.yy ? r1.xy : r1.zw;
  r1.z = -r2.z * r2.w + r1.x;
  r1.z = r1.y * r1.z + r1.w;
  r1.x = r1.x + -r1.z;
  r1.x = r1.y * r1.x + r1.z;
  r1.x = u_sBranch1.m_fTwitch * r1.x;
  r1.y = 1 + -u_sBranch1.m_fTwitch;
  r1.y = r2.y * r1.y;
  r1.z = 1 + -u_fStrength;
  r1.x = r1.x * r1.z + r1.y;
  r1.x = r1.x * r3.x;
  r0.xyz = r1.xxx * r0.xyz;
  r1.xyw = g_avInstanceData[r0.w].m_vRightVectorAndLod1.yzx * g_avInstanceData[r0.w].m_vUpVectorAndLod0.zxy;
  r1.xyw = g_avInstanceData[r0.w].m_vUpVectorAndLod0.yzx * g_avInstanceData[r0.w].m_vRightVectorAndLod1.zxy + -r1.xyw;
  r2.y = dot(r1.xyw, r1.xyw);
  r2.y = rsqrt(r2.y);
  r1.xyw = r2.yyy * r1.xyw;
  r3.x = v1.w;
  r3.yz = v2.zw;
  r2.yzw = v1.xyz + -r3.xyz;
  r2.yzw = g_avInstanceData[r0.w].m_vUpVectorAndLod0.www * r2.yzw + r3.xyz;
  r3.xyz = r2.zzz * r1.xyw;
  r3.xyz = g_avInstanceData[r0.w].m_vRightVectorAndLod1.xyz * r2.yyy + r3.xyz;
  r2.yzw = g_avInstanceData[r0.w].m_vUpVectorAndLod0.xyz * r2.www + r3.xyz;
  r0.xyz = r0.xyz * u_sBranch1.m_fBranchDistance + r2.yzw;
  r3.x = v3.w + r2.x;
  r4.x = u_sBranch2.m_fTwitchFreqScale * r3.x;
  r3.z = 0.5 * r4.x;
  r3.y = r2.x * u_sBranch2.m_fTwitchFreqScale + v3.w;
  r4.x = r2.x * 0.100000001 + v3.w;
  r3.w = -v3.z + r3.x;
  r3.xyzw = float4(0.5,0.5,0.5,1.5) + r3.xyzw;
  r3.xyzw = frac(r3.xyzw);
  r3.xyzw = r3.xyzw * float4(2,2,2,2) + float4(-1,-1,-1,-1);
  r5.xyzw = abs(r3.xyzw) * abs(r3.xyzw);
  r3.xyzw = -abs(r3.xyzw) * float4(2,2,2,2) + float4(3,3,3,3);
  r3.xyzw = r5.xyzw * r3.xyzw + float4(-0.5,-0.5,-0.5,-0.5);
  r3.xyzw = r3.xyzw + r3.xyzw;
  r5.xz = float2(-1,1);
  r5.w = r3.y * r3.z;
  r2.x = cmp(r5.w < 0);
  r5.y = -r5.w;
  r4.zw = r2.xx ? r5.xy : r5.zw;
  r2.x = -r3.y * r3.z + r4.z;
  r2.x = r4.w * r2.x + r5.w;
  r3.y = r4.z + -r2.x;
  r2.x = r4.w * r3.y + r2.x;
  r2.x = u_sBranch2.m_fTwitch * r2.x;
  r3.y = 1 + -u_sBranch2.m_fTwitch;
  r3.x = r3.x * r3.y;
  r1.z = r2.x * r1.z + r3.x;
  r2.x = u_sBranch2.m_fWhip * r3.w;
  r3.x = u_fStrength * r3.w;
  r2.x = r2.x * v3.z + 1;
  r1.z = r2.x * r1.z;
  r3.yzw = float3(0.0625,1,16) * v3.www;
  r3.yzw = frac(r3.yzw);
  r3.yzw = r3.yzw * float3(2,2,2) + float3(-1,-1,-1);
  r3.yzw = v3.zzz * r3.yzw;
  r3.yzw = r3.yzw * r1.zzz;
  r0.xyz = r3.yzw * u_sBranch2.m_fBranchDistance + r0.xyz;
  r1.z = u_sBranch2.m_fTurbulence * u_fWallTime;
  r4.y = r1.z * 0.100000001 + v3.w;
  r3.yz = float2(0.5,0.5) + r4.xy;
  r3.yz = frac(r3.yz);
  r3.yz = r3.yz * float2(2,2) + float2(-1,-1);
  r4.xy = abs(r3.yz) * abs(r3.yz);
  r3.yz = -abs(r3.yz) * float2(2,2) + float2(3,3);
  r3.yz = r4.xy * r3.yz + float2(-0.5,-0.5);
  r3.yz = r3.yz + r3.yz;
  r3.yz = r3.yz * r3.yz;
  r1.z = r3.z * r3.y;
  r1.z = -r1.z * u_sBranch2.m_fTurbulence + 1;
  r1.z = r3.x * u_sBranch2.m_fWhip + r1.z;
  r3.xyz = u_sBranch2.m_fDirectionAdherence * u_vDirection.xyz;
  r3.xyz = r3.xyz * r1.zzz;
  r0.xyz = r3.xyz * v3.zzz + r0.xyz;
  r0.xyz = r0.xyz + -r2.yzw;
  r3.x = g_avInstanceData[r0.w].m_vPosAndScalar.x + u_sGlobal.m_fTime;
  r3.y = u_sGlobal.m_fTime * 0.800000012 + g_avInstanceData[r0.w].m_vPosAndScalar.y;
  r3.xy = float2(0.5,0.5) + r3.xy;
  r3.xy = frac(r3.xy);
  r3.xy = r3.xy * float2(2,2) + float2(-1,-1);
  r3.zw = abs(r3.xy) * abs(r3.xy);
  r3.xy = -abs(r3.xy) * float2(2,2) + float2(3,3);
  r3.xy = r3.zw * r3.xy + float2(-0.5,-0.5);
  r3.xy = r3.xy + r3.xy;
  r1.z = r3.y * r3.y + r3.x;
  r2.x = u_sGlobal.m_fAdherence / u_sGlobal.m_fHeight;
  r1.z = u_sGlobal.m_fDistance * r1.z + r2.x;
  r2.x = 1 / u_sGlobal.m_fHeight;
  r2.x = -r2.x * 0.25 + r2.w;
  r2.x = max(0, r2.x);
  r2.x = u_sGlobal.m_fHeight * r2.x;
  r3.x = log2(abs(r2.x));
  r3.x = u_sGlobal.m_fHeightExponent * r3.x;
  r3.x = exp2(r3.x);
  r3.y = cmp(r2.x != 0.000000);
  r2.x = r3.y ? r3.x : r2.x;
  r1.z = r2.x * r1.z;
  r3.xy = u_vDirection.xy * r1.zz + r2.yz;
  r3.z = r2.w;
  r1.z = dot(r3.xyz, r3.xyz);
  r1.z = rsqrt(r1.z);
  r3.xyz = r3.xyz * r1.zzz;
  r1.z = dot(r2.yzw, r2.yzw);
  r1.z = sqrt(r1.z);
  r3.xyz = r3.xyz * r1.zzz + -r2.yzw;
  r0.xyz = r3.xyz + r0.xyz;
  r3.xyz = v5.xyz * float3(2,2,2) + float3(-1,-1,-1);
  r1.xyz = r3.yyy * r1.xyw;
  r1.xyz = g_avInstanceData[r0.w].m_vRightVectorAndLod1.xyz * r3.xxx + r1.xyz;
  r1.xyz = g_avInstanceData[r0.w].m_vUpVectorAndLod0.xyz * r3.zzz + r1.xyz;
  r1.w = cmp(v2.x < 0.5);
  r1.w = r1.w ? 0.750000 : 0;
  r2.x = u_sFrondRipple.m_fFrondTime * v2.y;
  r1.w = r2.x * u_sFrondRipple.m_fTile + r1.w;
  r1.w = 0.5 + r1.w;
  r1.w = frac(r1.w);
  r1.w = r1.w * 2 + -1;
  r2.x = abs(r1.w) * abs(r1.w);
  r1.w = -abs(r1.w) * 2 + 3;
  r1.w = r2.x * r1.w + -0.5;
  r1.w = v4.y * r1.w;
  r1.w = dot(u_sFrondRipple.m_fFrondDistance, r1.ww);
  r1.xyz = r1.www * r1.xyz;
  r0.xyz = r1.xyz * g_avInstanceData[r0.w].m_vUpVectorAndLod0.www + r0.xyz;
  r0.xyz = r2.yzw + r0.xyz;
  r0.xyz = r0.xyz * g_avInstanceData[r0.w].m_vPosAndScalar.www + g_avInstanceData[r0.w].m_vPosAndScalar.xyz;
  r0.xyz = -u_vCameraPosition.xyz + r0.xyz;
  r0.w = 1;
  o0.x = dot(u_mModelViewProj3d._m00_m01_m02_m03, r0.xyzw);
  o0.y = dot(u_mModelViewProj3d._m10_m11_m12_m13, r0.xyzw);
  o0.z = dot(u_mModelViewProj3d._m20_m21_m22_m23, r0.xyzw);
  o0.w = dot(u_mModelViewProj3d._m30_m31_m32_m33, r0.xyzw);
  o1.xy = v2.xy;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.0.10011.16384
//
//   using 3Dmigoto v1.3.11 on Thu Nov 22 18:41:35 2018
//
//
// Buffer Definitions:
//
// cbuffer SFrameCBLayout
// {
//
//   float4 u_vHandTunedParams;         // Offset:    0 Size:    16 [unused]
//   row_major float4x4 u_mModelViewProj3d;// Offset:   16 Size:    64
//   row_major float4x4 u_mProjectionInverse3d;// Offset:   80 Size:    64 [unused]
//   row_major float4x4 u_mModelViewProj2d;// Offset:  144 Size:    64 [unused]
//   row_major float4x4 u_mCameraFacingMatrix;// Offset:  208 Size:    64 [unused]
//   row_major float4x4 u_mWorldToViewMatrix;// Offset:  272 Size:    64 [unused]
//   float3 u_vCameraPosition;          // Offset:  336 Size:    12
//   float3 u_vCameraDirection;         // Offset:  352 Size:    12 [unused]
//   float3 u_vLodRefPosition;          // Offset:  368 Size:    12 [unused]
//   float2 u_vViewport;                // Offset:  384 Size:     8 [unused]
//   float2 u_vViewportInverse;         // Offset:  392 Size:     8 [unused]
//   float u_fWallTime;                 // Offset:  400 Size:     4
//   float u_fFarClip;                  // Offset:  404 Size:     4 [unused]
//
//   struct SDirLight
//   {
//
//       float3 m_vAmbient;             // Offset:  416
//       float3 m_vDiffuse;             // Offset:  432
//       float3 m_vSpecular;            // Offset:  448
//       float3 m_vTransmission;        // Offset:  464
//       float3 m_vDir;                 // Offset:  480
//
//   } u_sDirLight;                     // Offset:  416 Size:    76 [unused]
//
//   struct SShadows
//   {
//
//       float4 m_vMapRanges;           // Offset:  496
//       float4 m_avSmoothingTable[3];  // Offset:  512
//       row_major float4x4 m_amLightModelViewProjs[4];// Offset:  560
//       float2 m_vTexelOffset;         // Offset:  816
//       float m_fFadeStartPercent;     // Offset:  824
//       float m_fFadeInverseDistance;  // Offset:  828
//       float m_fTerrainAmbientOcclusion;// Offset:  832
//
//   } u_sShadows;                      // Offset:  496 Size:   340 [unused]
//
// }
//
// cbuffer SInstancingCBLayout
// {
//
//   struct SInstanceData
//   {
//
//       float4 m_vPosAndScalar;        // Offset:    0
//       float4 m_vUpVectorAndLod0;     // Offset:   16
//       float4 m_vRightVectorAndLod1;  // Offset:   32
//
//   } g_avInstanceData[1000];          // Offset:    0 Size: 48000
//
// }
//
// cbuffer SWindDynamicsCBLayout
// {
//
//   float4 u_vDirection;               // Offset:    0 Size:    16
//   float4 u_vAnchor;                  // Offset:   16 Size:    16 [unused]
//
//   struct SGlobalWind
//   {
//
//       float m_fTime;                 // Offset:   32
//       float m_fDistance;             // Offset:   36
//       float m_fHeight;               // Offset:   40
//       float m_fHeightExponent;       // Offset:   44
//       float m_fAdherence;            // Offset:   48
//
//   } u_sGlobal;                       // Offset:   32 Size:    20
//
//   struct SBranchWind
//   {
//
//       float m_fBranchTime;           // Offset:   64
//       float m_fBranchDistance;       // Offset:   68
//       float m_fTwitch;               // Offset:   72
//       float m_fTwitchFreqScale;      // Offset:   76
//       float m_fWhip;                 // Offset:   80
//       float m_fDirectionAdherence;   // Offset:   84
//       float m_fTurbulence;           // Offset:   88
//
//   } u_sBranch1;                      // Offset:   64 Size:    28
//
//   struct SBranchWind
//   {
//
//       float m_fBranchTime;           // Offset:   96
//       float m_fBranchDistance;       // Offset:  100
//       float m_fTwitch;               // Offset:  104
//       float m_fTwitchFreqScale;      // Offset:  108
//       float m_fWhip;                 // Offset:  112
//       float m_fDirectionAdherence;   // Offset:  116
//       float m_fTurbulence;           // Offset:  120
//
//   } u_sBranch2;                      // Offset:   96 Size:    28
//
//   struct SLeafWind
//   {
//
//       float m_fRippleTime;           // Offset:  128
//       float m_fRippleDistance;       // Offset:  132
//       float m_fLeewardScalar;        // Offset:  136
//       float m_fTumbleTime;           // Offset:  140
//       float m_fTumbleFlip;           // Offset:  144
//       float m_fTumbleTwist;          // Offset:  148
//       float m_fTumbleDirectionAdherence;// Offset:  152
//       float m_fTwitchThrow;          // Offset:  156
//       float m_fTwitchSharpness;      // Offset:  160
//       float m_fTwitchTime;           // Offset:  164
//
//   } u_sLeaf1;                        // Offset:  128 Size:    40 [unused]
//
//   struct SLeafWind
//   {
//
//       float m_fRippleTime;           // Offset:  176
//       float m_fRippleDistance;       // Offset:  180
//       float m_fLeewardScalar;        // Offset:  184
//       float m_fTumbleTime;           // Offset:  188
//       float m_fTumbleFlip;           // Offset:  192
//       float m_fTumbleTwist;          // Offset:  196
//       float m_fTumbleDirectionAdherence;// Offset:  200
//       float m_fTwitchThrow;          // Offset:  204
//       float m_fTwitchSharpness;      // Offset:  208
//       float m_fTwitchTime;           // Offset:  212
//
//   } u_sLeaf2;                        // Offset:  176 Size:    40 [unused]
//
//   struct SFrondRipple
//   {
//
//       float m_fFrondTime;            // Offset:  224
//       float m_fFrondDistance;        // Offset:  228
//       float m_fTile;                 // Offset:  232
//       float m_fLightingScalar;       // Offset:  236
//
//   } u_sFrondRipple;                  // Offset:  224 Size:    16
//   float u_fStrength;                 // Offset:  240 Size:     4
//
//   struct SRollingWind
//   {
//
//       float m_fBranchFieldMin;       // Offset:  256
//       float m_fBranchLightingAdjust; // Offset:  260
//       float m_fBranchVerticalOffset; // Offset:  264
//       float m_fLeafRippleMin;        // Offset:  268
//       float m_fLeafTumbleMin;        // Offset:  272
//       float m_fNoisePeriod;          // Offset:  276
//       float m_fNoiseSize;            // Offset:  280
//       float m_fNoiseTurbulence;      // Offset:  284
//       float m_fNoiseTwist;           // Offset:  288
//       float m_fOffsetX;              // Offset:  292
//       float m_fOffsetY;              // Offset:  296
//       float m_fBranchRipple;         // Offset:  300
//
//   } u_sRolling;                      // Offset:  256 Size:    48 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SFrameCBLayout                    cbuffer      NA          NA    0        1
// SInstancingCBLayout               cbuffer      NA          NA    2        1
// SWindDynamicsCBLayout             cbuffer      NA          NA    4        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_InstanceID            0   x           0   INSTID    uint   x
// POSITION                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 0   xyzw        2     NONE   float   xyzw
// TEXCOORD                 1   xyzw        3     NONE   float   xyzw
// TEXCOORD                 2   xyzw        4     NONE   float    y
// TEXCOORD                 3   xyzw        5     NONE   float   xyz
// TEXCOORD                 4   xyzw        6     NONE   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 0   xy          1     NONE   float   xy
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[26], immediateIndexed
dcl_constantbuffer cb2[3000], dynamicIndexed
dcl_constantbuffer cb4[16], immediateIndexed
dcl_input_sgv v0.x, instance_id
dcl_input v1.xyzw
dcl_input v2.xyzw
dcl_input v3.xyzw
dcl_input v4.y
dcl_input v5.xyz
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_temps 6
mul r0.xyz, v3.yyyy, l(0.062500, 1.000000, 16.000000, 0.000000)
frc r0.xyz, r0.xyzx
mad r0.xyz, r0.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mul r0.xyz, r0.xyzx, v3.xxxx
mov r1.xz, l(-1.000000,0,1.000000,0)
imul null, r0.w, v0.x, l(3)
add r2.x, cb2[r0.w + 0].y, cb2[r0.w + 0].x
add r2.y, r2.x, cb4[4].x
add r2.x, r2.x, cb4[6].x
add r3.x, r2.y, v3.y
mad r3.y, r2.y, cb4[4].w, v3.y
mul r2.y, r3.x, cb4[4].w
mul r3.z, r2.y, l(0.500000)
add r3.w, r3.x, -v3.x
add r3.xyzw, r3.xyzw, l(0.500000, 0.500000, 0.500000, 1.500000)
frc r3.xyzw, r3.xyzw
mad r3.xyzw, r3.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000), l(-1.000000, -1.000000, -1.000000, -1.000000)
mul r4.xyzw, |r3.xyzw|, |r3.xyzw|
mad r3.xyzw, -|r3.xyzw|, l(2.000000, 2.000000, 2.000000, 2.000000), l(3.000000, 3.000000, 3.000000, 3.000000)
mad r3.xyzw, r4.xyzw, r3.xyzw, l(-0.500000, -0.500000, -0.500000, -0.500000)
mul r2.yzw, r3.xxyz, l(0.000000, 2.000000, 2.000000, 2.000000)
mul r3.x, r3.w, cb4[5].x
dp2 r3.x, r3.xxxx, v3.xxxx
add r3.x, r3.x, l(1.000000)
mul r1.w, r2.w, r2.z
lt r3.y, r1.w, l(0.000000)
mov r1.y, -r1.w
movc r1.xy, r3.yyyy, r1.xyxx, r1.zwzz
mad r1.z, -r2.z, r2.w, r1.x
mad r1.z, r1.y, r1.z, r1.w
add r1.x, -r1.z, r1.x
mad r1.x, r1.y, r1.x, r1.z
mul r1.x, r1.x, cb4[4].z
add r1.y, -cb4[4].z, l(1.000000)
mul r1.y, r1.y, r2.y
add r1.z, -cb4[15].x, l(1.000000)
mad r1.x, r1.x, r1.z, r1.y
mul r1.x, r3.x, r1.x
mul r0.xyz, r0.xyzx, r1.xxxx
mul r1.xyw, cb2[r0.w + 1].zxzy, cb2[r0.w + 2].yzyx
mad r1.xyw, cb2[r0.w + 1].yzyx, cb2[r0.w + 2].zxzy, -r1.xyxw
dp3 r2.y, r1.xywx, r1.xywx
rsq r2.y, r2.y
mul r1.xyw, r1.xyxw, r2.yyyy
mov r3.x, v1.w
mov r3.yz, v2.zzwz
add r2.yzw, -r3.xxyz, v1.xxyz
mad r2.yzw, cb2[r0.w + 1].wwww, r2.yyzw, r3.xxyz
mul r3.xyz, r1.xywx, r2.zzzz
mad r3.xyz, cb2[r0.w + 2].xyzx, r2.yyyy, r3.xyzx
mad r2.yzw, cb2[r0.w + 1].xxyz, r2.wwww, r3.xxyz
mad r0.xyz, r0.xyzx, cb4[4].yyyy, r2.yzwy
add r3.x, r2.x, v3.w
mul r4.x, r3.x, cb4[6].w
mul r3.z, r4.x, l(0.500000)
mad r3.y, r2.x, cb4[6].w, v3.w
mad r4.x, r2.x, l(0.100000), v3.w
add r3.w, r3.x, -v3.z
add r3.xyzw, r3.xyzw, l(0.500000, 0.500000, 0.500000, 1.500000)
frc r3.xyzw, r3.xyzw
mad r3.xyzw, r3.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000), l(-1.000000, -1.000000, -1.000000, -1.000000)
mul r5.xyzw, |r3.xyzw|, |r3.xyzw|
mad r3.xyzw, -|r3.xyzw|, l(2.000000, 2.000000, 2.000000, 2.000000), l(3.000000, 3.000000, 3.000000, 3.000000)
mad r3.xyzw, r5.xyzw, r3.xyzw, l(-0.500000, -0.500000, -0.500000, -0.500000)
add r3.xyzw, r3.xyzw, r3.xyzw
mov r5.xz, l(-1.000000,0,1.000000,0)
mul r5.w, r3.z, r3.y
lt r2.x, r5.w, l(0.000000)
mov r5.y, -r5.w
movc r4.zw, r2.xxxx, r5.xxxy, r5.zzzw
mad r2.x, -r3.y, r3.z, r4.z
mad r2.x, r4.w, r2.x, r5.w
add r3.y, -r2.x, r4.z
mad r2.x, r4.w, r3.y, r2.x
mul r2.x, r2.x, cb4[6].z
add r3.y, -cb4[6].z, l(1.000000)
mul r3.x, r3.y, r3.x
mad r1.z, r2.x, r1.z, r3.x
mul r2.x, r3.w, cb4[7].x
mul r3.x, r3.w, cb4[15].x
mad r2.x, r2.x, v3.z, l(1.000000)
mul r1.z, r1.z, r2.x
mul r3.yzw, v3.wwww, l(0.000000, 0.062500, 1.000000, 16.000000)
frc r3.yzw, r3.yyzw
mad r3.yzw, r3.yyzw, l(0.000000, 2.000000, 2.000000, 2.000000), l(0.000000, -1.000000, -1.000000, -1.000000)
mul r3.yzw, r3.yyzw, v3.zzzz
mul r3.yzw, r1.zzzz, r3.yyzw
mad r0.xyz, r3.yzwy, cb4[6].yyyy, r0.xyzx
mul r1.z, cb0[25].x, cb4[7].z
mad r4.y, r1.z, l(0.100000), v3.w
add r3.yz, r4.xxyx, l(0.000000, 0.500000, 0.500000, 0.000000)
frc r3.yz, r3.yyzy
mad r3.yz, r3.yyzy, l(0.000000, 2.000000, 2.000000, 0.000000), l(0.000000, -1.000000, -1.000000, 0.000000)
mul r4.xy, |r3.yzyy|, |r3.yzyy|
mad r3.yz, -|r3.yyzy|, l(0.000000, 2.000000, 2.000000, 0.000000), l(0.000000, 3.000000, 3.000000, 0.000000)
mad r3.yz, r4.xxyx, r3.yyzy, l(0.000000, -0.500000, -0.500000, 0.000000)
add r3.yz, r3.yyzy, r3.yyzy
mul r3.yz, r3.yyzy, r3.yyzy
mul r1.z, r3.y, r3.z
mad r1.z, -r1.z, cb4[7].z, l(1.000000)
mad r1.z, r3.x, cb4[7].x, r1.z
mul r3.xyz, cb4[0].xyzx, cb4[7].yyyy
mul r3.xyz, r1.zzzz, r3.xyzx
mad r0.xyz, r3.xyzx, v3.zzzz, r0.xyzx
add r0.xyz, -r2.yzwy, r0.xyzx
add r3.x, cb4[2].x, cb2[r0.w + 0].x
mad r3.y, cb4[2].x, l(0.800000), cb2[r0.w + 0].y
add r3.xy, r3.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
frc r3.xy, r3.xyxx
mad r3.xy, r3.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r3.zw, |r3.xxxy|, |r3.xxxy|
mad r3.xy, -|r3.xyxx|, l(2.000000, 2.000000, 0.000000, 0.000000), l(3.000000, 3.000000, 0.000000, 0.000000)
mad r3.xy, r3.zwzz, r3.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
add r3.xy, r3.xyxx, r3.xyxx
mad r1.z, r3.y, r3.y, r3.x
div r2.x, cb4[3].x, cb4[2].z
mad r1.z, cb4[2].y, r1.z, r2.x
div r2.x, l(1.000000, 1.000000, 1.000000, 1.000000), cb4[2].z
mad r2.x, -r2.x, l(0.250000), r2.w
max r2.x, r2.x, l(0.000000)
mul r2.x, r2.x, cb4[2].z
log r3.x, |r2.x|
mul r3.x, r3.x, cb4[2].w
exp r3.x, r3.x
ne r3.y, r2.x, l(0.000000)
movc r2.x, r3.y, r3.x, r2.x
mul r1.z, r1.z, r2.x
mad r3.xy, cb4[0].xyxx, r1.zzzz, r2.yzyy
mov r3.z, r2.w
dp3 r1.z, r3.xyzx, r3.xyzx
rsq r1.z, r1.z
mul r3.xyz, r1.zzzz, r3.xyzx
dp3 r1.z, r2.yzwy, r2.yzwy
sqrt r1.z, r1.z
mad r3.xyz, r3.xyzx, r1.zzzz, -r2.yzwy
add r0.xyz, r0.xyzx, r3.xyzx
mad r3.xyz, v5.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mul r1.xyz, r1.xywx, r3.yyyy
mad r1.xyz, cb2[r0.w + 2].xyzx, r3.xxxx, r1.xyzx
mad r1.xyz, cb2[r0.w + 1].xyzx, r3.zzzz, r1.xyzx
lt r1.w, v2.x, l(0.500000)
and r1.w, r1.w, l(0x3f400000)
mul r2.x, v2.y, cb4[14].x
mad r1.w, r2.x, cb4[14].z, r1.w
add r1.w, r1.w, l(0.500000)
frc r1.w, r1.w
mad r1.w, r1.w, l(2.000000), l(-1.000000)
mul r2.x, |r1.w|, |r1.w|
mad r1.w, -|r1.w|, l(2.000000), l(3.000000)
mad r1.w, r2.x, r1.w, l(-0.500000)
mul r1.w, r1.w, v4.y
dp2 r1.w, cb4[14].yyyy, r1.wwww
mul r1.xyz, r1.xyzx, r1.wwww
mad r0.xyz, r1.xyzx, cb2[r0.w + 1].wwww, r0.xyzx
add r0.xyz, r0.xyzx, r2.yzwy
mad r0.xyz, r0.xyzx, cb2[r0.w + 0].wwww, cb2[r0.w + 0].xyzx
add r0.xyz, r0.xyzx, -cb0[21].xyzx
mov r0.w, l(1.000000)
dp4 o0.x, cb0[1].xyzw, r0.xyzw
dp4 o0.y, cb0[2].xyzw, r0.xyzw
dp4 o0.z, cb0[3].xyzw, r0.xyzw
dp4 o0.w, cb0[4].xyzw, r0.xyzw
mov o1.xy, v2.xyxx
ret
// Approximately 164 instruction slots used

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