// ---- Created with 3Dmigoto v1.2.35 on Tue Apr 26 22:30:28 2016

cbuffer cbToneMap : register(b1)
{
  float3 g_ToneMapInvSceneLumScale : packoffset(c0);
  float3 g_ToneMapScaler : packoffset(c1);
  float4 g_ToneMapParam : packoffset(c2);
  float4 g_ToneMapSceneLumScale : packoffset(c3);
  float4 g_AdaptParam : packoffset(c4);
  float4 g_AdaptCenterWeight : packoffset(c5);
  float4 g_BrightPassThreshold : packoffset(c6);
  float4 g_GlareLuminance : packoffset(c7);
  float4 g_BloomBoostColor : packoffset(c8);
  float4 g_vBloomFinalColor : packoffset(c9);
  float4 g_vBloomScaleParam : packoffset(c10);
}

cbuffer cbToneMapSampleOffset : register(b2)
{
  float4 g_ToneMapSampleOffset[16] : packoffset(c0);
}

SamplerState SS_ClampLinear_s : register(s1);
Texture2D<float4> g_SourceTexture : register(t0);


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


void main( 
  float4 v0 : SV_Position0,
  float3 v1 : TEXCOORD0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xy = g_ToneMapSampleOffset[1].xy + v1.xy;
  r0.xyz = g_SourceTexture.SampleLevel(SS_ClampLinear_s, r0.xy, 0).xyz;
  r1.xyz = g_ToneMapSceneLumScale.xyz * v1.zzz;
  r0.xyz = r1.xyz * r0.xyz;
  r0.w = dot(r0.xyz, float3(0.298909992,0.586610019,0.114480004));
  r1.w = -g_BrightPassThreshold.x + r0.w;
  r0.w = 9.99999975e-005 + r0.w;
  r1.w = max(0, r1.w);
  r0.w = r1.w / r0.w;
  r0.xyz = r0.xyz * r0.www;
  r2.xy = g_ToneMapSampleOffset[0].xy + v1.xy;
  r2.xyz = g_SourceTexture.SampleLevel(SS_ClampLinear_s, r2.xy, 0).xyz;
  r2.xyz = r2.xyz * r1.xyz;
  r0.w = dot(r2.xyz, float3(0.298909992,0.586610019,0.114480004));
  r1.w = -g_BrightPassThreshold.x + r0.w;
  r0.w = 9.99999975e-005 + r0.w;
  r1.w = max(0, r1.w);
  r0.w = r1.w / r0.w;
  r0.xyz = r2.xyz * r0.www + r0.xyz;
  r2.xy = g_ToneMapSampleOffset[2].xy + v1.xy;
  r2.xyz = g_SourceTexture.SampleLevel(SS_ClampLinear_s, r2.xy, 0).xyz;
  r2.xyz = r2.xyz * r1.xyz;
  r0.w = dot(r2.xyz, float3(0.298909992,0.586610019,0.114480004));
  r1.w = -g_BrightPassThreshold.x + r0.w;
  r0.w = 9.99999975e-005 + r0.w;
  r1.w = max(0, r1.w);
  r0.w = r1.w / r0.w;
  r0.xyz = r2.xyz * r0.www + r0.xyz;
  r2.xy = g_ToneMapSampleOffset[3].xy + v1.xy;
  r2.xyz = g_SourceTexture.SampleLevel(SS_ClampLinear_s, r2.xy, 0).xyz;
  r1.xyz = r2.xyz * r1.xyz;
  r0.w = dot(r1.xyz, float3(0.298909992,0.586610019,0.114480004));
  r1.w = -g_BrightPassThreshold.x + r0.w;
  r0.w = 9.99999975e-005 + r0.w;
  r1.w = max(0, r1.w);
  r0.w = r1.w / r0.w;
  r0.xyz = r1.xyz * r0.www + r0.xyz;
  r1.xyz = float3(0.25,0.25,0.25) * r0.xyz;
  r0.w = dot(r1.xyz, float3(0.298909992,0.586610019,0.114480004));
  r0.xyz = -r0.xyz * float3(0.25,0.25,0.25) + r0.www;
  r0.xyz = g_BloomBoostColor.www * r0.xyz + r1.xyz;
  o0.xyz = g_BloomBoostColor.xyz * r0.xyz;
  o0.w = 1;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// cbuffer cbToneMap
// {
//
//   float3 g_ToneMapInvSceneLumScale;  // Offset:    0 Size:    12 [unused]
//   float3 g_ToneMapScaler;            // Offset:   16 Size:    12 [unused]
//   float4 g_ToneMapParam;             // Offset:   32 Size:    16 [unused]
//   float4 g_ToneMapSceneLumScale;     // Offset:   48 Size:    16
//   float4 g_AdaptParam;               // Offset:   64 Size:    16 [unused]
//   float4 g_AdaptCenterWeight;        // Offset:   80 Size:    16 [unused]
//   float4 g_BrightPassThreshold;      // Offset:   96 Size:    16
//   float4 g_GlareLuminance;           // Offset:  112 Size:    16 [unused]
//   float4 g_BloomBoostColor;          // Offset:  128 Size:    16
//   float4 g_vBloomFinalColor;         // Offset:  144 Size:    16 [unused]
//   float4 g_vBloomScaleParam;         // Offset:  160 Size:    16 [unused]
//
// }
//
// cbuffer cbToneMapSampleOffset
// {
//
//   float4 g_ToneMapSampleOffset[16];  // Offset:    0 Size:   256
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SS_ClampLinear                    sampler      NA          NA    1        1
// g_SourceTexture                   texture  float4          2d    0        1
// cbToneMap                         cbuffer      NA          NA    1        1
// cbToneMapSampleOffset             cbuffer      NA          NA    2        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float       
// TEXCOORD                 0   xyz         1     NONE   float   xyz 
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[4], immediateIndexed
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v1.xyz
dcl_output o0.xyzw
dcl_temps 3
add r0.xy, v1.xyxx, cb2[1].xyxx
sample_l_indexable(texture2d)(float,float,float,float) r0.xyz, r0.xyxx, t0.xyzw, s1, l(0.000000)
mul r1.xyz, v1.zzzz, cb1[3].xyzx
mul r0.xyz, r0.xyzx, r1.xyzx
dp3 r0.w, r0.xyzx, l(0.298910, 0.586610, 0.114480, 0.000000)
add r1.w, r0.w, -cb1[6].x
add r0.w, r0.w, l(0.000100)
max r1.w, r1.w, l(0.000000)
div r0.w, r1.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
add r2.xy, v1.xyxx, cb2[0].xyxx
sample_l_indexable(texture2d)(float,float,float,float) r2.xyz, r2.xyxx, t0.xyzw, s1, l(0.000000)
mul r2.xyz, r1.xyzx, r2.xyzx
dp3 r0.w, r2.xyzx, l(0.298910, 0.586610, 0.114480, 0.000000)
add r1.w, r0.w, -cb1[6].x
add r0.w, r0.w, l(0.000100)
max r1.w, r1.w, l(0.000000)
div r0.w, r1.w, r0.w
mad r0.xyz, r2.xyzx, r0.wwww, r0.xyzx
add r2.xy, v1.xyxx, cb2[2].xyxx
sample_l_indexable(texture2d)(float,float,float,float) r2.xyz, r2.xyxx, t0.xyzw, s1, l(0.000000)
mul r2.xyz, r1.xyzx, r2.xyzx
dp3 r0.w, r2.xyzx, l(0.298910, 0.586610, 0.114480, 0.000000)
add r1.w, r0.w, -cb1[6].x
add r0.w, r0.w, l(0.000100)
max r1.w, r1.w, l(0.000000)
div r0.w, r1.w, r0.w
mad r0.xyz, r2.xyzx, r0.wwww, r0.xyzx
add r2.xy, v1.xyxx, cb2[3].xyxx
sample_l_indexable(texture2d)(float,float,float,float) r2.xyz, r2.xyxx, t0.xyzw, s1, l(0.000000)
mul r1.xyz, r1.xyzx, r2.xyzx
dp3 r0.w, r1.xyzx, l(0.298910, 0.586610, 0.114480, 0.000000)
add r1.w, r0.w, -cb1[6].x
add r0.w, r0.w, l(0.000100)
max r1.w, r1.w, l(0.000000)
div r0.w, r1.w, r0.w
mad r0.xyz, r1.xyzx, r0.wwww, r0.xyzx
mul r1.xyz, r0.xyzx, l(0.250000, 0.250000, 0.250000, 0.000000)
dp3 r0.w, r1.xyzx, l(0.298910, 0.586610, 0.114480, 0.000000)
mad r0.xyz, -r0.xyzx, l(0.250000, 0.250000, 0.250000, 0.000000), r0.wwww
mad r0.xyz, cb1[8].wwww, r0.xyzx, r1.xyzx
mul o0.xyz, r0.xyzx, cb1[8].xyzx
mov o0.w, l(1.000000)
ret 
// Approximately 44 instruction slots used

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