// Ambient Lighting (unconfirmed, uses DownsampledDepthTexture__SampObj__, similar to environment=normal shader)
// PS 1201619760848612 551a826bfb659595 c146fc4db7b97968 ff8ee214288e8819

//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.31 on Wed Mar 02 08:06:44 2016
//
//
// Buffer Definitions: 
//
// cbuffer CViewportShaderParameterProvider
// {
//
//   float4x4 InvProjectionMatrix;      // Offset:    0 Size:    64 [unused]
//   float4x4 InvViewMatrix;            // Offset:   64 Size:    64 [unused]
//   float4x4 ProjectionMatrix;         // Offset:  128 Size:    64 [unused]
//   float4x4 ViewMatrix;               // Offset:  192 Size:    64 [unused]
//   float4x4 ViewProjectionMatrix;     // Offset:  256 Size:    64 [unused]
//   float4x4 ViewRotProjectionMatrix;  // Offset:  320 Size:    64 [unused]
//   float4x4 ViewRotProjectionMatrix_Previous;// Offset:  384 Size:    64 [unused]
//   float4 AmbientSHR;                 // Offset:  448 Size:    16 [unused]
//   float4 AmbientSHG;                 // Offset:  464 Size:    16 [unused]
//   float4 AmbientSHB;                 // Offset:  480 Size:    16 [unused]
//   float4 CameraDistances;            // Offset:  496 Size:    16
//   float4 CameraNearPlaneSize;        // Offset:  512 Size:    16 [unused]
//   float4 DepthScale;                 // Offset:  528 Size:    16 [unused]
//   float4 DepthTextureScaleOffset;    // Offset:  544 Size:    16 [unused]
//   float4 FogParams;                  // Offset:  560 Size:    16 [unused]
//   float4 FogSHB;                     // Offset:  576 Size:    16 [unused]
//   float4 FogSHG;                     // Offset:  592 Size:    16 [unused]
//   float4 FogSHR;                     // Offset:  608 Size:    16 [unused]
//   float4 HeightFogParams;            // Offset:  624 Size:    16 [unused]
//   float4 ViewportSize;               // Offset:  640 Size:    16 [unused]
//   float3 ViewPoint;                  // Offset:  656 Size:    12 [unused]
//   float3 CameraPosition;             // Offset:  672 Size:    12
//   float3 CameraPosition_Previous;    // Offset:  688 Size:    12 [unused]
//   float3 CameraPositionFractions;    // Offset:  704 Size:    12 [unused]
//   float3 CameraPositionFractions_Previous;// Offset:  720 Size:    12 [unused]
//   float3 CameraRight;                // Offset:  736 Size:    12 [unused]
//   float3 CameraUp;                   // Offset:  752 Size:    12 [unused]
//   float3 CameraDirection;            // Offset:  768 Size:    12 [unused]
//   float3 EnvironmentMapColorOffset;  // Offset:  784 Size:    12 [unused]
//   float3 EnvironmentMapColorScale;   // Offset:  800 Size:    12 [unused]
//   float3 AmbientOcclusionRanges;     // Offset:  816 Size:    12 [unused]
//   float3 DepthTextureRcpSize;        // Offset:  832 Size:    12 [unused]
//   float2 MotionVectorOffsets;        // Offset:  848 Size:     8 [unused]
//   float2 DepthRangeCompression;      // Offset:  856 Size:     8 [unused]
//   float ShadowProjDepthMinValue;     // Offset:  864 Size:     4 [unused]
//   float DistanceScale;               // Offset:  868 Size:     4 [unused]
//   float WorldSpaceZOffset;           // Offset:  872 Size:     4 [unused]
//   float WorldSpaceZOffset_Previous;  // Offset:  876 Size:     4 [unused]
//   float CameraFOVDeg;                // Offset:  880 Size:     4 [unused]
//   float EffectsEmissiveEVBias;       // Offset:  884 Size:     4 [unused]
//   float ShadowCSMLastSliceIndex;     // Offset:  888 Size:     4 [unused]
//   float UseNormalization;            // Offset:  892 Size:     4 [unused]
//   float FogUndergroundColorScale;    // Offset:  896 Size:     4 [unused]
//
// }
//
// cbuffer CSceneTerrainSkyOcclusionAtlasPrivateData
// {
//
//   float4 SectorOcclusion_OffsetScale;// Offset:    0 Size:    16
//   float3 SectorOcclusion_DistanceFade;// Offset:   16 Size:    12
//   float2 SectorOcclusion_HeightOffsetScale;// Offset:   32 Size:     8
//
// }
//
// cbuffer CAmbientProvider
// {
//
//   float4 CascadeDistanceScales[5];   // Offset:    0 Size:    80
//   float4 CascadeNearFarSnappedOffsetCamera[5];// Offset:   80 Size:    80
//   float4 CascadeNearFarRcpUVSize[5]; // Offset:  160 Size:    80
//   float4 UndergroundSHR;             // Offset:  240 Size:    16
//   float4 UndergroundSHG;             // Offset:  256 Size:    16
//   float4 UndergroundSHB;             // Offset:  272 Size:    16
//   float InvUndergroundBlendEndHeight;// Offset:  288 Size:     4
//   float IndirectLightingScale;       // Offset:  292 Size:     4
//
// }
//
// cbuffer CCommonDeferredAmbientProvider
// {
//
//   float4x4 InvViewRotProjectionMatrix;// Offset:    0 Size:    64
//   float4 GlobalSHB;                  // Offset:   64 Size:    16 [unused]
//   float4 GlobalSHG;                  // Offset:   80 Size:    16 [unused]
//   float4 GlobalSHR;                  // Offset:   96 Size:    16 [unused]
//   float4 LerpDistance_RCP;           // Offset:  112 Size:    16 [unused]
//   float3 SnappedCameraC0;            // Offset:  128 Size:    12 [unused]
//   float3 SnappedCameraC1;            // Offset:  144 Size:    12 [unused]
//   float3 SnappedCameraC2;            // Offset:  160 Size:    12 [unused]
//   float3 UVScale;                    // Offset:  176 Size:    12 [unused]
//
// }
//
// Resource bind info for ExposureBuffer
// {
//
//   float4 $Element;                   // Offset:    0 Size:    16
//
// }
//
// Resource bind info for SkyParamBuffer
// {
//
//   struct ComputedSkyParameters
//   {
//       
//       float r[9];                    // Offset:    0
//       float g[9];                    // Offset:   36
//       float b[9];                    // Offset:   72
//       float3 sunColor;               // Offset:  108
//       float3 moonColor;              // Offset:  120
//
//   } $Element;                        // Offset:    0 Size:   132
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// LinearVolumeSamplerState          sampler      NA          NA    0        1
// SectorOcclusion_HeightTexture__SampObj__    sampler      NA          NA    1        1
// SectorHemiMapSamplerStateLinear    sampler      NA          NA    2        1
// DownsampledDepthTexture__SampObj__    sampler      NA          NA    3        1
// NormalWSTexture_Point__SampObj__    sampler      NA          NA    4        1
// SHTextureR                        texture  float4          3d    0        1
// SHTextureG                        texture  float4          3d    1        1
// SHTextureB                        texture  float4          3d    2        1
// ExposureBuffer                    texture  struct         r/o    3        1
// SkyParamBuffer                    texture  struct         r/o    4        1
// SectorOcclusion_HeightTexture__TexObj__    texture  float4          2d    5        1
// DownsampledDepthTexture__TexObj__    texture  float4          2d    6        1
// NormalWSTexture_Point__TexObj__    texture  float4          2d    7        1
// CViewportShaderParameterProvider    cbuffer      NA          NA    0        1
// CSceneTerrainSkyOcclusionAtlasPrivateData    cbuffer      NA          NA    1        1
// CAmbientProvider                  cbuffer      NA          NA    2        1
// CCommonDeferredAmbientProvider    cbuffer      NA          NA    3        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float       
// TEXCOORD                 0   xy          1     NONE   float   xy  
// TEXCOORD                 1     zw        1     NONE   float     zw
// SV_IsFrontFace           0   x           2    FFACE    uint       
//
//
// 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[43], immediateIndexed
dcl_constantbuffer cb1[3], immediateIndexed
dcl_constantbuffer cb2[19], dynamicIndexed
dcl_constantbuffer cb3[4], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_resource_texture3d (float,float,float,float) t0
dcl_resource_texture3d (float,float,float,float) t1
dcl_resource_texture3d (float,float,float,float) t2
dcl_resource_structured t3, 16 
dcl_resource_structured t4, 132 
dcl_resource_texture2d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_resource_texture2d (float,float,float,float) t7
dcl_input_ps linear v1.xy
dcl_input_ps linear v1.zw
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_temps 11
dcl_resource_texture2d (float,float,float,float) t125

ld_indexable(texture2d)(float,float,float,float) r8.xyzw, l(0, 0, 0, 0), t125.xyzw

sample_indexable(texture2d)(float,float,float,float) r0.xyzw, v1.zwzz, t7.xyzw, s4
mul r0.w, r0.w, l(3.000000)
mad r0.xyz, r0.xyzx, l(1.41421354, 1.41421354, 1.41421354, 0.000000), l(-0.707106769, -0.707106769, -0.707106769, 0.000000)
ftou r0.w, r0.w
dp3 r1.x, r0.xyzx, r0.xyzx
min r1.x, r1.x, l(1.000000)
add r1.x, -r1.x, l(1.000000)
sqrt r1.x, r1.x
swapc r0.x, r2.x, r0.w, r0.x, r1.x
ieq r1.yz, r0.wwww, l(0, 1, 2, 0)
movc r3.xy, r1.yzyy, r1.xxxx, r0.yzyy
movc r0.x, r1.y, r0.y, r0.x
movc r3.z, r1.z, r0.z, r0.x
mov r0.z, r2.x
mov r0.yw, l(0,2.000000,0,2.000000)
mul r0.xyz, r2.xxxx, r0.yzwy
mov r3.w, l(-2.000000)
mad r0.xyz, r0.xyzx, r3.zwyz, l(0.000000, 1.000000, 0.000000, 0.000000)
mov r1.zw, r3.xxxz
mul r2.xyz, r3.xxxx, r3.ywwy
mov r1.y, l(2.000000)
mad r0.yzw, r2.xxyz, r1.yyzw, r0.xxyz
mul r1.xyz, r0.yzyy, r0.zzyz
mad r1.z, r0.w, r0.w, -r1.z
mad r1.y, r1.y, l(3.000000), l(-1.000000)
mul r1.xyz, r1.xyzx, l(0.858085513, 0.247707963, 0.429042757, 0.000000)
mul r2.xyzw, r0.wzyw, l(1.09254849, 1.02332675, 1.02332675, 1.02332675)
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r3.xyzw, l(0), l(72), t4.xyzw
mul r1.w, r2.z, r3.y
mad r1.w, r3.x, l(0.886226952), r1.w
mad r1.w, r3.z, r2.y, r1.w
mad r1.w, r3.w, r2.w, r1.w
mul r3.xy, r0.yzyy, r2.xxxx
mul r3.xy, r3.xyxx, l(0.785398185, 0.785398185, 0.000000, 0.000000)
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r4.xyzw, l(0), l(88), t4.xyzw
mad r1.w, r4.x, r3.x, r1.w
mad r1.w, r4.y, r1.x, r1.w
mad r1.w, r4.z, r1.y, r1.w
mad r1.w, r4.w, r3.y, r1.w
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r3.z, l(0), l(104), t4.xxxx
mad r4.z, r3.z, r1.z, r1.w
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r5.xyzw, l(0), l(0), t4.xyzw
mul r1.w, r2.z, r5.y
mad r1.w, r5.x, l(0.886226952), r1.w
mad r1.w, r5.z, r2.y, r1.w
mad r1.w, r5.w, r2.w, r1.w
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r5.xyzw, l(0), l(16), t4.xyzw
mad r1.w, r5.x, r3.x, r1.w
mad r1.w, r5.y, r1.x, r1.w
mad r1.w, r5.z, r1.y, r1.w
mad r1.w, r5.w, r3.y, r1.w
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r3.zw, l(0), l(32), t4.xxxy
mad r4.x, r3.z, r1.z, r1.w
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r5.xyzw, l(0), l(36), t4.xyzw
mul r1.w, r2.z, r5.y
mad r1.w, r5.x, l(0.886226952), r1.w
mad r1.w, r5.z, r2.y, r1.w
mad r1.w, r5.w, r2.w, r1.w
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r5.xyzw, l(0), l(52), t4.xyzw
mad r1.w, r5.x, r3.x, r1.w
mad r1.x, r5.y, r1.x, r1.w
mad r1.x, r5.z, r1.y, r1.x
mad r1.x, r5.w, r3.y, r1.x
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r1.yw, l(0), l(68), t4.xxxy
mad r4.y, r1.y, r1.z, r1.x
max r1.x, r1.w, r3.w
max r1.yzw, r4.xxyz, l(0.000000, 0.000000, 0.000000, 0.000000)
sample_indexable(texture2d)(float,float,float,float) r2.z, v1.xyxx, t6.yzxw, s3
mul r2.z, |r2.z|, cb0[31].z

// Depth (DownsampledDepthTexture__TexObj__ * CameraDistances.z):
mov r9.w, r2.z

mul r2.w, cb0[31].y, cb0[31].x
div r2.z, r2.w, r2.z
add r2.z, -r2.z, cb0[31].y
mad r3.z, -r2.z, cb0[31].w, l(1.000000)
mad r3.xy, v1.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000)
mov r3.w, l(1.000000)
dp4 r4.x, r3.xyzw, cb3[0].xyzw
dp4 r4.y, r3.xyzw, cb3[1].xyzw
dp4 r4.z, r3.xyzw, cb3[2].xyzw
dp4 r2.z, r3.xyzw, cb3[3].xyzw
div r3.xyz, r4.xyzx, r2.zzzz

// Correction:
add r8.w, r9.w, -r8.y
mul r9.x, r8.w, r8.x
mov r9.yzw, l(0.0)

// InvProjectionMatrix:
dp4 r10.x, r9.xyzw, cb0[0].xyzw
dp4 r10.y, r9.xyzw, cb0[1].xyzw
dp4 r10.z, r9.xyzw, cb0[2].xyzw
dp4 r10.w, r9.xyzw, cb0[3].xyzw
// InvViewMatrix:
dp4 r9.x, r10.xyzw, cb0[4].xyzw
dp4 r9.y, r10.xyzw, cb0[5].xyzw
dp4 r9.z, r10.xyzw, cb0[6].xyzw

// Adjust coord:
add r3.xyz, r3.xyz, -r9.xyz

add r4.xyz, r3.xyzx, cb0[42].xyzx
dp2 r2.z, r3.xyxx, r3.xyxx
mad r3.xy, r4.yxyy, cb1[0].yxyy, cb1[0].wzww
sample_l_indexable(texture2d)(float,float,float,float) r3.zw, r3.xyxx, t5.zwxy, s1, l(0.000000)
sample_l_indexable(texture2d)(float,float,float,float) r2.w, r3.xyxx, t5.xzwy, s2, l(0.000000)
mad r2.w, r2.w, cb1[2].x, cb1[2].y
add r2.w, -r2.w, r4.z
mul_sat r2.w, -r2.w, cb2[18].x
sqrt r2.w, r2.w
mad r3.xy, r3.zwzz, cb1[2].xxxx, cb1[2].yyyy
add r3.z, -r3.y, r4.z
add r3.x, -r3.y, r3.x
max r3.x, r3.x, l(1.000000)
add r3.xy, r3.xzxx, l(-0.300000, -0.300000, 0.000000, 0.000000)
max r3.y, r3.y, l(0.000000)
div r3.x, r3.y, r3.x
min r3.x, r3.x, l(1.000000)
mul r3.x, r3.x, r3.x
mul r3.x, r3.x, r3.x
mad r3.xy, r3.xxxx, l(0.772453845, 1.53499007, 0.000000, 0.000000), l(1.000000, 0.000000, 0.000000, 0.000000)
dp2 r3.z, cb1[1].zzzz, cb1[1].zzzz
add r3.z, r3.z, l(-1.000000)
add r3.z, -r3.z, l(1.000000)
mul r5.y, r3.z, l(0.767495036)
mad r5.x, cb1[1].z, l(-1.77245390), l(1.77245390)
add r3.xy, r3.xyxx, -r5.xyxx
mad r3.z, cb1[1].x, r2.z, cb1[1].y
sqrt r2.z, r2.z
mov_sat r3.w, r3.z
mul_sat r3.z, r3.z, l(3.000000)
mul r2.w, r2.w, r3.z
mad r3.xy, r3.wwww, r3.xyxx, r5.xyxx
mov r2.x, l(0.886226952)
dp2 r2.x, r3.xyxx, r2.xyxx
mul_sat r2.x, r2.x, l(0.318309873)
mul r1.yzw, r1.yyzw, r2.xxxx
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r2.x, l(0), l(0), t4.xxxx
max r1.x, r1.x, r2.x
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r3.xy, l(0), l(124), t4.xyxx
ld_structured_indexable(structured_buffer, stride=132)(mixed,mixed,mixed,mixed) r5.xyzw, l(0), l(108), t4.xyzw
mov r3.z, r5.w
dp3 r2.x, r5.xyzx, l(0.212600, 0.715200, 0.072200, 0.000000)
dp3 r2.y, r3.zxyz, l(0.212600, 0.715200, 0.072200, 0.000000)
max r2.x, r2.y, r2.x
add r1.x, r1.x, r2.x
lt r2.x, r2.z, cb2[2].y
movc r2.x, r2.x, l(2), l(3)
lt r2.y, r2.z, cb2[1].y
movc r2.x, r2.y, l(1), r2.x
lt r2.y, r2.z, cb2[0].y
movc r2.x, r2.y, l(0), r2.x
mad_sat r2.y, r2.z, cb2[r2.x + 0].z, cb2[r2.x + 0].w
add r3.xyzw, r4.xyxy, -cb2[r2.x + 5].xyzw
mul r3.xyzw, r3.zwxy, cb2[r2.x + 10].yyxx
utof r2.x, r2.x
add r2.xz, r2.xxxx, l(0.500000, 0.000000, 1.500000, 0.000000)
mul r4.xy, r2.xzxx, l(0.200000, 0.200000, 0.000000, 0.000000)
mov r4.zw, r3.zzzw
sample_l_indexable(texture3d)(float,float,float,float) r5.xyzw, r4.zwxz, t0.xyzw, s0, l(0.000000)
mov r3.z, r4.y
sample_l_indexable(texture3d)(float,float,float,float) r6.xyzw, r3.xyzx, t0.xyzw, s0, l(0.000000)
add r6.xyzw, -r5.xyzw, r6.xyzw
mad r5.xyzw, r2.yyyy, r6.xyzw, r5.xyzw
mul r5.xyzw, r1.xxxx, r5.xyzw
mov r0.x, l(1.000000)
mul r0.xyzw, r0.xyzw, l(0.282094806, 0.488602519, 0.488602519, 0.488602519)
dp4 r5.x, r5.xyzw, r0.xyzw
sample_l_indexable(texture3d)(float,float,float,float) r6.xyzw, r4.zwxz, t1.xyzw, s0, l(0.000000)
sample_l_indexable(texture3d)(float,float,float,float) r4.xyzw, r4.zwxz, t2.xyzw, s0, l(0.000000)
sample_l_indexable(texture3d)(float,float,float,float) r7.xyzw, r3.xyzx, t1.xyzw, s0, l(0.000000)
sample_l_indexable(texture3d)(float,float,float,float) r3.xyzw, r3.xyzx, t2.xyzw, s0, l(0.000000)
add r3.xyzw, -r4.xyzw, r3.xyzw
mad r3.xyzw, r2.yyyy, r3.xyzw, r4.xyzw
mul r3.xyzw, r1.xxxx, r3.xyzw
dp4 r5.z, r3.xyzw, r0.xyzw
add r3.xyzw, -r6.xyzw, r7.xyzw
mad r3.xyzw, r2.yyyy, r3.xyzw, r6.xyzw
mul r3.xyzw, r1.xxxx, r3.xyzw
dp4 r5.y, r3.xyzw, r0.xyzw
max r2.xyz, r5.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
mad r1.xyz, r2.xyzx, cb2[18].yyyy, r1.yzwy
dp4 r2.x, cb2[15].xyzw, r0.xyzw
dp4 r2.y, cb2[16].xyzw, r0.xyzw
dp4 r2.z, cb2[17].xyzw, r0.xyzw
max r0.xyz, r2.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
add r0.xyz, -r1.xyzx, r0.xyzx
mad r0.xyz, r2.wwww, r0.xyzx, r1.xyzx
ld_structured_indexable(structured_buffer, stride=16)(mixed,mixed,mixed,mixed) r0.w, l(0), l(0), t3.xxxx
mul o0.xyz, r0.wwww, r0.xyzx
mov o0.w, l(1.000000)
mov o1.xyzw, l(0,0,0,0)
ret 
// Approximately 172 instruction slots used