// ---- Created with 3Dmigoto v1.2.39 on Sun Jun 26 13:10:34 2016

cbuffer _Globals : register(b0)
{
  float4x4 LocalToWorld : packoffset(c0);
  float4x4 ScreenToWorldMatrix : packoffset(c4);
  bool bDecompressSceneColor : packoffset(c8);
  float4 PackedParameters : packoffset(c9);
  float4 MinMaxBlurClamp : packoffset(c10);
  float4 LightColorAndFalloffExponent : packoffset(c11);
  float3 DistanceFieldParameters : packoffset(c12);
  float4x4 ScreenToShadowMatrix : packoffset(c13);
  float4 ShadowBufferAndTexelSize : packoffset(c17);
  float ShadowOverrideFactor : packoffset(c18);
  float SSSMultiplier : packoffset(c18.y);
  bool bReceiveDynamicShadows : packoffset(c18.z);
  bool bEnableDistanceShadowFading : packoffset(c18.w);
  float2 DistanceFadeParameters : packoffset(c19);
  float4 IBLPositionAndWeight0 : packoffset(c20);
  float4 IBLPositionAndWeight1 : packoffset(c21);
  float4 IBLPositionAndWeight2 : packoffset(c22);
  float4 IBLPositionAndWeight3 : packoffset(c23);
  float4x4 IBLProxyOBB0 : packoffset(c24);
  float4x4 IBLProxyOBB1 : packoffset(c28);
  float4x4 IBLProxyOBB2 : packoffset(c32);
  float4 IBLUseProxyVolume : packoffset(c36);
  float4x4 IBLLastProxyOBB0 : packoffset(c37);
  float4x4 IBLLastProxyOBB1 : packoffset(c41);
  float4x4 IBLLastProxyOBB2 : packoffset(c45);
  float4 IBLUseLastProxyVolume : packoffset(c49);
  float ForcedIBLWeight : packoffset(c50);
  float AdditionalReflections : packoffset(c50.y);
  float4x4 InvViewProjectionMatrix : packoffset(c51);
  float3 CameraWorldPos : packoffset(c55);
  float3 ActorWorldPos : packoffset(c56);
  float4 ObjectWorldPositionAndRadius : packoffset(c57);
  float3 ObjectOrientation : packoffset(c58);
  float3 ObjectPostProjectionPosition : packoffset(c59);
  float3 ObjectNDCPosition : packoffset(c60);
  float4 ObjectMacroUVScales : packoffset(c61);
  float3 FoliageImpulseDirection : packoffset(c62);
  float4 FoliageNormalizedRotationAxisAndAngle : packoffset(c63);
  float4 WindDirectionAndSpeed : packoffset(c64);
  float3 FogVolumeDensityParameters : packoffset(c65);
  float4 FogVolumeHalfspaceParameters : packoffset(c66);
  float3 ApproxFogColor : packoffset(c67);
  float3 FogVolumeBoxMin : packoffset(c68);
  float3 FogVolumeBoxMax : packoffset(c69);
  float3x3 LocalToWorldMatrix : packoffset(c70);
  float3x3 WorldToLocalMatrix : packoffset(c73);
  float3x3 WorldToViewMatrix : packoffset(c76);
  float3x3 ViewToWorldMatrix : packoffset(c79);
  float4 UniformPixelVector_0 : packoffset(c82);
  float4 UniformPixelVector_1 : packoffset(c83);
  float4 UniformPixelVector_2 : packoffset(c84);
  float4 UniformPixelVector_3 : packoffset(c85);
  float4 UniformPixelScalars_0 : packoffset(c86);
  float4 UniformPixelScalars_1 : packoffset(c87);
  float4 UniformPixelScalars_2 : packoffset(c88);
  float3 TemporalAAParameters : packoffset(c89);
  float4x3 WorldToLocal : packoffset(c90);
  float4x4 PreviousLocalToWorld : packoffset(c93);
  float3 MeshOrigin : packoffset(c97);
  float3 MeshExtension : packoffset(c98);
  float4 BoneIndexOffsetAndScale : packoffset(c99);
  float SubSurfaceQuality : packoffset(c100);
  float4 WorldIncidentLighting[7] : packoffset(c101);
  float4 DeferredRenderingParameters : packoffset(c108);
  float2 TemporalAAParametersPS : packoffset(c109);
  float3 SpotDirection : packoffset(c110);
  float2 SpotAngles : packoffset(c111);
  float3 UpperSkyColor : packoffset(c112);
  float3 LowerSkyColor : packoffset(c113);
  float UseOnlyLightMapSpecular : packoffset(c113.w);
  float4 AmbientColorAndSkyFactor : packoffset(c114);
  float EmissiveMultiplier : packoffset(c115);
  float DiffuseMultiplier : packoffset(c115.y);
}

cbuffer VSOffsetConstants : register(b1)
{
  float4x4 ViewProjectionMatrix : packoffset(c0);
  float4 CameraPositionVS : packoffset(c4);
  float4 PreViewTranslation : packoffset(c5);
}

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 SceneColorTextureSampler_s : register(s0);
SamplerState AmbientReflectionCubemapSampler_s : register(s1);
SamplerState PixelTexture2D_0Sampler_s : register(s2);
Texture2D<float4> SceneColorTexture : register(t0);
TextureCube<float4> AmbientReflectionCubemap : register(t1);
Texture2D<float4> PixelTexture2D_0 : register(t2);


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


void main( 
  linear centroid float4 v0 : TEXCOORD10,
  linear centroid float4 v1 : TEXCOORD11,
  float4 v2 : COLOR0,
  float4 v3 : TEXCOORD0,
  float4 v4 : TEXCOORD3,
  float4 v5 : TEXCOORD4,
  float4 v6 : TEXCOORD6,
  float4 v7 : TEXCOORD7,
  float4 v8 : TEXCOORD5,
  uint v9 : SV_IsFrontFace0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = dot(v1.xyz, v1.xyz);
  r0.x = rsqrt(r0.x);
  r0.xyz = v1.xyz * r0.xxx;
  r0.w = dot(v0.xyz, v0.xyz);
  r0.w = rsqrt(r0.w);
  r1.xyz = v0.yxz * r0.www;
  r2.yz = r1.yz * r0.yz;
  r0.w = r0.x * r1.x + -r2.y;
  r0.y = v1.w * r0.w;
  r1.xyw = ViewProjectionMatrix._m01_m11_m31 * v8.yyy;
  r1.xyw = ViewProjectionMatrix._m00_m10_m30 * v8.xxx + r1.xyw;
  r1.xyw = ViewProjectionMatrix._m02_m12_m32 * v8.zzz + r1.xyw;
  r1.xyw = ViewProjectionMatrix._m03_m13_m33 * v8.www + r1.xyw;

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

  r0.w = dot(v6.xyz, v6.xyz);
  r0.w = rsqrt(r0.w);
  r3.xyz = v6.xyz * r0.www;
  r0.w = dot(v4.xyz, v4.xyz);
  r0.w = rsqrt(r0.w);
  r4.xyz = v4.xyz * r0.www;
  r3.xyw = r3.zzz * float3(0,0,2) + -r3.xyz;
  r5.xyzw = DiffuseOverrideParameter.yxyz * DiffuseMultiplier;
  r1.xy = r1.xy / r1.ww;
  r1.xy = r1.xy * ScreenPositionScaleBias.xy + ScreenPositionScaleBias.wz;
  r1.xyw = SceneColorTexture.Sample(SceneColorTextureSampler_s, r1.xy).xyz;
  r0.w = r1.x + r1.y;
  r0.w = r0.w + r1.w;
  r1.xy = cmp(float2(0.0240000002,0.600000024) < r0.ww);
  r6.xy = cmp(r0.ww < float2(0.600000024,3));
  r1.xy = r1.xy ? r6.xy : 0;
  r6.xyz = float3(0.280898869,0.225148901,0.132721543) * r0.www;
  r6.xyz = r1.yyy ? float3(0.421348304,0.337723345,0.199082315) : r6.xyz;
  r1.xyw = r1.xxx ? float3(0.126404494,0.101317003,0.059724696) : r6.xyz;
  r6.xy = UniformPixelVector_2.xy + v3.xy;
  r0.w = PixelTexture2D_0.SampleBias(PixelTexture2D_0Sampler_s, r6.xy, 0).y;
  r0.w = 1 + -r0.w;
  r6.xy = UniformPixelVector_3.xy + v3.xy;
  r4.w = PixelTexture2D_0.SampleBias(PixelTexture2D_0Sampler_s, r6.xy, 0).y;
  r4.w = 1 + -r4.w;
  r0.w = r4.w * r0.w;
  r4.w = PixelTexture2D_0.SampleBias(PixelTexture2D_0Sampler_s, v3.xy, 0).x;
  r0.w = r0.w * 0.200000003 + r4.w;
  r3.z = max(0, r3.z);
  r3.z = 1 + -r3.z;
  r4.w = cmp(abs(r3.z) < 9.99999997e-007);
  r3.z = abs(r3.z) * abs(r3.z);
  r6.x = r3.z * r3.z;
  r3.z = r6.x * r3.z;
  r3.z = r4.w ? 0 : r3.z;
  r0.w = r0.w * 0.600000024 + r3.z;
  r0.w = saturate(0.800000012 + r0.w);
  r1.xyw = -UniformPixelVector_1.xyz + r1.xyw;
  r1.xyw = r0.www * r1.xyw + UniformPixelVector_1.xyz;
  r1.xyw = UniformPixelVector_0.xyz + r1.xyw;
  r0.x = r1.z;
  r6.xyz = r0.yzy * r0.yzx;
  r2.x = r0.z * r0.y;
  r2.y = r6.y * 3 + -1;
  r2.w = r0.x * r0.x + -r6.x;
  r7.xyz = float3(-1.02332771,1.02332771,-1.02332771) * r0.yzx;
  r7.w = 0.858085215 * r6.z;
  r2.xyzw = float4(-0.858085215,0.247708291,-0.858085215,0.429042608) * r2.xyzw;
  r0.w = dot(WorldIncidentLighting[1].xyzw, r7.xyzw);
  r0.w = WorldIncidentLighting[0].x * 0.886227608 + r0.w;
  r1.z = dot(WorldIncidentLighting[2].xyzw, r2.xyzw);
  r6.x = r1.z + r0.w;
  r0.w = dot(WorldIncidentLighting[3].xyzw, r7.xyzw);
  r0.w = WorldIncidentLighting[0].y * 0.886227608 + r0.w;
  r1.z = dot(WorldIncidentLighting[4].xyzw, r2.xyzw);
  r6.y = r1.z + r0.w;
  r0.w = dot(WorldIncidentLighting[5].xyzw, r7.xyzw);
  r0.w = WorldIncidentLighting[0].z * 0.886227608 + r0.w;
  r1.z = dot(WorldIncidentLighting[6].xyzw, r2.xyzw);
  r6.z = r1.z + r0.w;
  r2.xyz = max(float3(0,0,0), r6.xyz);
  r2.xyz = DiffuseOverrideParameter.xyz * r2.xyz;
  r1.xyz = r1.xyw * EmissiveMultiplier + r2.xyz;
  r0.w = saturate(r4.z);
  r1.w = cmp(r0.w < 9.99999997e-007);
  r0.w = r1.w ? 0 : r0.w;
  r1.w = saturate(dot(r3.xyw, r4.xyz));
  r2.x = cmp(r1.w < 9.99999997e-007);
  r1.w = log2(r1.w);
  r1.w = 15 * r1.w;
  r1.w = exp2(r1.w);
  r2.yzw = SpecularOverrideParameter.xyz * r1.www;
  r2.xyz = r2.xxx ? float3(0,0,0) : r2.yzw;
  r2.xyz = r5.yzw * r0.www + r2.xyz;
  r1.xyz = r2.xyz * LightColorAndFalloffExponent.xyz + r1.xyz;
  r1.xyz = r5.yzw * AmbientColorAndSkyFactor.xyz + r1.xyz;
  r0.w = cmp(0 < AdditionalReflections);
  if (r0.w != 0) {
    r0.w = saturate(SpecularOverrideParameter.x + SpecularOverrideParameter.x);
    r2.xyzw = r5.xyzw * r0.wwww;
    r0.w = dot(v8.xyz, v8.xyz);
    r0.w = rsqrt(r0.w);
    r3.xyz = v8.xyz * r0.www;
    r0.w = dot(r3.xyz, r0.xyz);
    r0.w = r0.w + r0.w;
    r0.xyz = r0.xyz * -r0.www + r3.xyz;
    r0.xyz = AmbientReflectionCubemap.SampleLevel(AmbientReflectionCubemapSampler_s, r0.xyz, 5).xyz;
    r2.xyzw = float4(50,0.452399999,0.452399999,0.452399999) * r2.xyzw;
    r2.x = saturate(r2.x);
    r2.xyz = r2.xxx * float3(-0.00240000011,-0.00240000011,-0.00240000011) + r2.yzw;
    r0.xyz = r2.xyz * r0.xyz;
    r1.xyz = r0.xyz * AdditionalReflections + r1.xyz;
  }
  r0.x = cmp(AdditionalReflections < 0);
  r0.yzw = r1.xyz / -AdditionalReflections;
  r0.xyz = r0.xxx ? r0.yzw : r1.xyz;
  o0.xyz = r0.xyz * v5.www + v5.xyz;
  o0.w = UniformPixelScalars_2.y;
  return;
}