// Letterboxing

cbuffer GUIConstant : register(b0)
{
  row_major float4x4 guiViewMatrix : packoffset(c0);
  row_major float4x4 guiProjMatrix : packoffset(c4);
  row_major float4x4 guiWorldMat : packoffset(c8);
  float guiIntensity : packoffset(c12);
  float guiSaturation : packoffset(c12.y);
  float guiSoftParticleDist : packoffset(c12.z);
  float guiFilterParam : packoffset(c12.w);
  float guiFilterMipLevel : packoffset(c13);
  float guiAlphaBlendRate : packoffset(c13.y);
}

SamplerState primSampler_s : register(s0);
Texture2D<float4> primTex : register(t0);


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


void main(
  float4 v0 : SV_Position0,
  float4 v1 : Color0,
  float2 v2 : TexCoord0,
  float2 w2 : TexCoord1,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

  float4 tex_filter = IniParams.Load(int2(3,0));
  
  r0.xyzw = primTex.Sample(primSampler_s, v2.xy).xyzw;
  r1.xyzw = v1.xyzw * r0.xyzw;
  r2.xy = cmp(r1.ww < float2(0,1));
  if (r2.x != 0) discard;
  r0.w = dot(r1.xyz, float3(0.298900008,0.586600006,0.114500001));
  r0.xyz = -v1.xyz * r0.xyz + r0.www;
  r0.xyz = guiSaturation * r0.xyz + r1.xyz;
  r1.xyz = r0.xyz * r1.www;
  r0.x = cmp(guiAlphaBlendRate != 0.000000);
  r0.x = r2.y ? r0.x : 0;
  if (r0.x != 0) {
    r0.x = guiAlphaBlendRate * r1.w;
    r1.xyz = r1.xyz * r0.xxx;
  }
  o0.xyzw = r1.xyzw;
  
  //////////////////////////////////////////////////////
  // Disable FIX
  if (IniParams[0].w == 0)
	return;
  
  if (tex_filter.x == 20)
  {
	if (o0.w == 1.0 && v0.x > 1.0)
		o0.w = 0.01;
	return;
  }
  
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//   using 3Dmigoto v1.3.12 on Sat Jan 26 01:21:26 2019
//
//
// Buffer Definitions:
//
// cbuffer GUIConstant
// {
//
//   row_major float4x4 guiViewMatrix;  // Offset:    0 Size:    64 [unused]
//   row_major float4x4 guiProjMatrix;  // Offset:   64 Size:    64 [unused]
//   row_major float4x4 guiWorldMat;    // Offset:  128 Size:    64 [unused]
//   float guiIntensity;                // Offset:  192 Size:     4 [unused]
//   float guiSaturation;               // Offset:  196 Size:     4
//   float guiSoftParticleDist;         // Offset:  200 Size:     4 [unused]
//   float guiFilterParam;              // Offset:  204 Size:     4 [unused]
//   float guiFilterMipLevel;           // Offset:  208 Size:     4 [unused]
//   float guiAlphaBlendRate;           // Offset:  212 Size:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// primSampler                       sampler      NA          NA    0        1
// primTex                           texture  float4          2d    0        1
// GUIConstant                       cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float
// Color                    0   xyzw        1     NONE   float   xyzw
// TexCoord                 0   xy          2     NONE   float   xy
// TexCoord                 1     zw        2     NONE   float
//
//
// 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 cb0[14], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v2.xy
dcl_output o0.xyzw
dcl_temps 3
sample_indexable(texture2d)(float,float,float,float) r0.xyzw, v2.xyxx, t0.xyzw, s0
mul r1.xyzw, r0.xyzw, v1.xyzw
lt r2.xy, r1.wwww, l(0.000000, 1.000000, 0.000000, 0.000000)
discard_nz r2.x
dp3 r0.w, r1.xyzx, l(0.298900, 0.586600, 0.114500, 0.000000)
mad r0.xyz, -v1.xyzx, r0.xyzx, r0.wwww
mad r0.xyz, cb0[12].yyyy, r0.xyzx, r1.xyzx
mul r1.xyz, r1.wwww, r0.xyzx
ne r0.x, cb0[13].y, l(0.000000)
and r0.x, r2.y, r0.x
if_nz r0.x
  mul r0.x, r1.w, cb0[13].y
  mul r1.xyz, r0.xxxx, r1.xyzx
endif
mov o0.xyzw, r1.xyzw
ret
// Approximately 16 instruction slots used

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