// ---- Created with 3Dmigoto v1.2.29 on Wed Apr 13 13:43:47 2016

cbuffer dynamic_transforms : register(b0)
{
  row_major float4x4 m_WVP : packoffset(c0);
  row_major float3x4 m_WV : packoffset(c4);
  row_major float3x4 m_W : packoffset(c7);
  float4 L_material : packoffset(c10);
  float4 hemi_cube_pos_faces : packoffset(c11);
  float4 hemi_cube_neg_faces : packoffset(c12);
  float4 dt_params : packoffset(c13);
}

SamplerState smp_rtlinear_s : register(s0);
SamplerState smp_base_s : register(s1);
Texture2D<float4> s_base : register(t0);
Texture2D<float4> s_bump : register(t1);
Texture2D<float4> s_bumpX : register(t2);
Texture2D<float4> s_detail : register(t3);
Texture2D<float4> s_detailBump : register(t4);
Texture2D<float4> s_detailBumpX : register(t5);
Texture2D<float4> s_hemi : register(t6);


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


void main( 
  float2 v0 : TEXCOORD0,
  float2 w0 : TEXCOORD5,
  float4 v1 : TEXCOORD1,
  float4 v2 : TEXCOORD2,
  float4 v3 : TEXCOORD3,
  float4 v4 : TEXCOORD4,
  float2 v5 : TEXCOORD6,
  out float4 o0 : SV_Target0,
  out float4 o1 : SV_Target1)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyz = v3.xyz * -v1.yyy;
  r0.xyz = v2.xyz * -v1.xxx + r0.xyz;
  r0.xyz = v4.xyz * -v1.zzz + r0.xyz;
  r0.z = dot(r0.xyz, r0.xyz);
  r0.z = rsqrt(r0.z);
  r0.xy = r0.xy * r0.zz;
  r0.z = s_bumpX.Sample(smp_base_s, v0.xy).w;
  r0.z = r0.z * 0.0199999996 + -0.00999999978;
  r0.xy = r0.zz * r0.xy + v0.xy;
  r1.xyzw = s_base.Sample(smp_base_s, r0.xy).xyzw;
  r0.z = -0.784313738 + r1.w;
  r0.z = cmp(r0.z < 0);
  if (r0.z != 0) discard;
  r0.z = s_hemi.Sample(smp_rtlinear_s, v5.xy).w;
  r0.z = saturate(r0.z);
  r0.z = 255.899994 * r0.z;
  r0.z = (uint)r0.z;
  r0.z = (uint)r0.z << 13;
  bitmask.z = ((~(-1 << 30)) << 0) & 0xffffffff;
  r0.z = (((uint)r0.z << 0) & bitmask.z) | ((uint)0x40000000 & ~bitmask.z);
  r0.w = 23.25 * L_material.w;
  r0.w = (uint)r0.w;
  bitmask.z = ((~(-1 << 5)) << 21) & 0xffffffff;
  r0.z = (((uint)r0.w << 21) & bitmask.z) | ((uint)r0.z & ~bitmask.z);
  r0.w = (int)r0.w & 16;
  r1.w = (int)r0.z & 0x02000000;
  r2.x = (int)r0.z | 0x44000000;
  r0.z = r1.w ? r0.z : r2.x;
  r1.w = (int)r0.z | 0xc0000000;
  o0.w = r0.w ? r1.w : r0.z;
  r2.xyz = s_bumpX.Sample(smp_base_s, r0.xy).xyz;
  r0.xyzw = s_bump.Sample(smp_base_s, r0.xy).xyzw;
  r0.yzw = r2.xyz + r0.wzy;
  r0.x = r0.x * r0.x;
  r0.yzw = float3(-1,-1,-1) + r0.yzw;
  r2.xyz = s_detailBumpX.Sample(smp_base_s, w0.xy).xyz;
  r3.xyzw = s_detailBump.Sample(smp_base_s, w0.xy).xyzw;
  r2.xyz = r3.wzy + r2.xyz;
  o1.w = dot(r0.xx, r3.xx);
  r0.xyz = r2.xyz + r0.yzw;
  r0.xyz = float3(-1,-1,-1) + r0.xyz;
  r0.w = 0.5 * r0.z;
  r2.x = dot(v2.xyz, r0.xyw);
  r2.y = dot(v3.xyz, r0.xyw);
  r2.z = dot(v4.xyz, r0.xyw);
  r0.x = dot(r2.xyz, r2.xyz);
  r0.x = rsqrt(r0.x);
  r0.yz = r2.yz * r0.xx;
  r0.x = r2.x * r0.x + 1;
  r0.x = 0.5 * r0.x;
  r0.y = cmp(r0.y < 0);
  o0.x = r0.z;
  r0.y = r0.y ? -1 : 1;
  o0.y = r0.x * r0.y;
  o0.z = v1.z;
  r0.xyz = s_detail.Sample(smp_base_s, w0.xy).xyz;
  r0.xyz = r1.xyz * r0.xyz;
  o1.xyz = r0.xyz + r0.xyz;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022
//
//   using 3Dmigoto v1.2.29 on Wed Apr 13 13:43:47 2016
//
//
// Buffer Definitions: 
//
// cbuffer dynamic_transforms
// {
//
//   row_major float4x4 m_WVP;          // Offset:    0 Size:    64 [unused]
//   row_major float3x4 m_WV;           // Offset:   64 Size:    48 [unused]
//   row_major float3x4 m_W;            // Offset:  112 Size:    48 [unused]
//   float4 L_material;                 // Offset:  160 Size:    16
//   float4 hemi_cube_pos_faces;        // Offset:  176 Size:    16 [unused]
//   float4 hemi_cube_neg_faces;        // Offset:  192 Size:    16 [unused]
//   float4 dt_params;                  // Offset:  208 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// smp_rtlinear                      sampler      NA          NA    0        1
// smp_base                          sampler      NA          NA    1        1
// s_base                            texture  float4          2d    0        1
// s_bump                            texture  float4          2d    1        1
// s_bumpX                           texture  float4          2d    2        1
// s_detail                          texture  float4          2d    3        1
// s_detailBump                      texture  float4          2d    4        1
// s_detailBumpX                     texture  float4          2d    5        1
// s_hemi                            texture  float4          2d    6        1
// dynamic_transforms                cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xy          0     NONE   float   xy  
// TEXCOORD                 5     zw        0     NONE   float     zw
// TEXCOORD                 1   xyzw        1     NONE   float   xyz 
// TEXCOORD                 2   xyz         2     NONE   float   xyz 
// TEXCOORD                 3   xyz         3     NONE   float   xyz 
// TEXCOORD                 4   xyz         4     NONE   float   xyz 
// TEXCOORD                 6   xy          5     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
// SV_Target                1   xyzw        1   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[11], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, 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_resource_texture2d (float,float,float,float) t4
dcl_resource_texture2d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_input_ps linear v0.xy
dcl_input_ps linear v0.zw
dcl_input_ps linear v1.xyz
dcl_input_ps linear v2.xyz
dcl_input_ps linear v3.xyz
dcl_input_ps linear v4.xyz
dcl_input_ps linear v5.xy
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_temps 4
mul r0.xyz, -v1.yyyy, v3.xyzx
mad r0.xyz, v2.xyzx, -v1.xxxx, r0.xyzx
mad r0.xyz, v4.xyzx, -v1.zzzz, r0.xyzx
dp3 r0.z, r0.xyzx, r0.xyzx
rsq r0.z, r0.z
mul r0.xy, r0.zzzz, r0.xyxx
sample_indexable(texture2d)(float,float,float,float) r0.z, v0.xyxx, t2.xywz, s1
mad r0.z, r0.z, l(0.020000), l(-0.010000)
mad r0.xy, r0.zzzz, r0.xyxx, v0.xyxx
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r0.xyxx, t0.xyzw, s1
add r0.z, r1.w, l(-0.784313738)
lt r0.z, r0.z, l(0.000000)
discard_nz r0.z
sample_indexable(texture2d)(float,float,float,float) r0.z, v5.xyxx, t6.xywz, s0
mov_sat r0.z, r0.z
mul r0.z, r0.z, l(255.899994)
ftou r0.z, r0.z
ishl r0.z, r0.z, l(13)
bfi r0.z, l(30), l(0), r0.z, l(0x40000000)
mul r0.w, cb0[10].w, l(23.250000)
ftou r0.w, r0.w
bfi r0.z, l(5), l(21), r0.w, r0.z
and r0.w, r0.w, l(16)
and r1.w, r0.z, l(0x02000000)
or r2.x, r0.z, l(0x44000000)
movc r0.z, r1.w, r0.z, r2.x
or r1.w, r0.z, l(0xc0000000)
movc o0.w, r0.w, r1.w, r0.z
sample_indexable(texture2d)(float,float,float,float) r2.xyz, r0.xyxx, t2.xyzw, s1
sample_indexable(texture2d)(float,float,float,float) r0.xyzw, r0.xyxx, t1.xyzw, s1
add r0.yzw, r0.wwzy, r2.xxyz
mul r0.x, r0.x, r0.x
add r0.yzw, r0.yyzw, l(0.000000, -1.000000, -1.000000, -1.000000)
sample_indexable(texture2d)(float,float,float,float) r2.xyz, v0.zwzz, t5.xyzw, s1
sample_indexable(texture2d)(float,float,float,float) r3.xyzw, v0.zwzz, t4.xyzw, s1
add r2.xyz, r2.xyzx, r3.wzyw
dp2 o1.w, r0.xxxx, r3.xxxx
add r0.xyz, r0.yzwy, r2.xyzx
add r0.xyz, r0.xyzx, l(-1.000000, -1.000000, -1.000000, 0.000000)
mul r0.w, r0.z, l(0.500000)
dp3 r2.x, v2.xyzx, r0.xywx
dp3 r2.y, v3.xyzx, r0.xywx
dp3 r2.z, v4.xyzx, r0.xywx
dp3 r0.x, r2.xyzx, r2.xyzx
rsq r0.x, r0.x
mul r0.yz, r0.xxxx, r2.yyzy
mad r0.x, r2.x, r0.x, l(1.000000)
mul r0.x, r0.x, l(0.500000)
lt r0.y, r0.y, l(0.000000)
mov o0.x, r0.z
movc r0.y, r0.y, l(-1.000000), l(1.000000)
mul o0.y, r0.y, r0.x
mov o0.z, v1.z
sample_indexable(texture2d)(float,float,float,float) r0.xyz, v0.zwzz, t3.xyzw, s1
mul r0.xyz, r0.xyzx, r1.xyzx
add o1.xyz, r0.xyzx, r0.xyzx
ret 
// Approximately 57 instruction slots used

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