//P5S cel shading PS 2.
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.16 on Wed Mar 09 23:51:12 2022
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   float4 ambLit;                     // Index:    0.xyzw           Components:     4
//   int hFogType[3];                   // Index:    1-3.x            Components:     9
//   float4 cHFog[3];                   // Index:    4 5 6            Components:    12
//   float4 hFogParam[3];               // Index:    7 8 9            Components:    12
//   float hFogFlucPrms[60];            // Index:   10-69.x           Components:   237
//   float fOLLtEfFade;                 // Index:   69.y              Components:     1
//      = 0x00000000
//   float3 vOLAmbEfScaler;             // Index:   70.xyz            Components:     3
//      = 0x3f800000 0x3f800000 0x3f800000
//   float3 vOLColorScaler;             // Index:   71.xyz            Components:     3
//      = 0x3f800000 0x3f800000 0x3f800000
//   float fOLCSatFade;                 // Index:   71.w              Components:     1
//      = 0x00000000
//   float fOLPtnFade;                  // Index:   72.x              Components:     1
//      = 0x00000000
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// __smpsLit                         sampler      NA          NA    3        1
// __smpsOutlineColor                sampler      NA          NA    4        1
// sLit                              texture  float4          2d    3        1
// sOutlineColor                     texture  float4          2d    4        1
// sOutlineAutoHDRScaleExposure      texture  float4          2d    6        1
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float
// TEXCOORD                 0   xyzw        1     NONE   float      w
// TEXCOORD                 1   xyzw        2     NONE   float   xyz
// TEXCOORD                 2   xy          3     NONE   float   xy
// TEXCOORD                 3   x           4     NONE     int   x
//
//
// 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[73], dynamicIndexed
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_resource_texture2d (float,float,float,float) t3
dcl_resource_texture2d (float,float,float,float) t4
dcl_resource_texture2d (float,float,float,float) t6
dcl_input_ps linear v1.w
dcl_input_ps linear v2.xyz
dcl_input_ps linear v3.xy
dcl_input_ps constant v4.x
dcl_output o0.xyzw
dcl_temps 24
dcl_resource_texture1d (float,float,float,float) t120
ld_indexable(texture1d)(float,float,float,float) r20.xyzw, l(6, 0, 0, 0), t120.xyzw

discard_nz r20.x

itof r0.x, v4.x
add r0.x, r0.x, l(0.500000)
mul r0.x, r0.x, l(0.00390625000)
mov r0.y, l(0.500000)
sample_indexable(texture2d)(float,float,float,float) r0.xyz, r0.xyxx, t4.xyzw, s4
sample_indexable(texture2d)(float,float,float,float) r0.w, v3.xyxx, t3.yzwx, s3
mul r0.xyz, r0.xyzx, cb0[71].xyzx
mov_sat r1.x, cb0[69].y
mad r1.yzw, cb0[0].xxyz, cb0[70].xxyz, l(0.000000, -1.000000, -1.000000, -1.000000)
mad r1.xyz, r1.xxxx, r1.yzwy, l(1.000000, 1.000000, 1.000000, 0.000000)
mul r0.xyz, r0.xyzx, r1.xyzx
mov_sat r1.x, cb0[72].x
add r0.w, r0.w, l(-1.000000)
mad r0.w, r1.x, r0.w, l(1.000000)
mul r0.xyz, r0.wwww, r0.xyzx
max r0.w, r0.z, r0.y
max r0.w, r0.w, r0.x
add_sat r0.w, r0.w, l(-0.001960)
ge r1.xyz, r0.xyzx, r0.wwww
and r1.xyz, r1.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0)
mov_sat r0.w, cb0[71].w
mad r1.xyz, r0.xyzx, r1.xyzx, -r0.xyzx
mad r0.xyz, r0.wwww, r1.xyzx, r0.xyzx
ld_indexable(texture2d)(float,float,float,float) r0.w, l(0, 0, 0, 0), t6.yzwx
div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.w
min r0.w, r0.w, l(340282306073709650000000000000000000000.000000)
mul r1.xyz, r0.wwww, r0.xyzx
mov r1.w, l(0)
mov r2.x, l(0)
loop
  ige r2.y, r2.x, l(20)
  breakc_nz r2.y
  mad r2.y, v2.x, cb0[r2.x + 11].x, cb0[r2.x + 12].x
  mul r2.y, r2.y, l(6.283185)
  mad r2.z, v2.z, cb0[r2.x + 13].x, cb0[r2.x + 14].x
  mul r2.z, r2.z, l(6.283185)
  sincos null, r2.yz, r2.yyzy
  add r2.y, r2.z, r2.y
  mad r1.w, r2.y, cb0[r2.x + 10].x, r1.w
  iadd r2.x, r2.x, l(5)
endloop
add r1.w, r1.w, v2.y
mad_sat r1.w, r1.w, cb0[7].x, cb0[7].y
mul r2.x, r1.w, l(-1.442695)
exp r2.x, r2.x
ieq r2.yz, cb0[1].xxxx, l(0, 1, 2, 0)
mul r2.w, r1.w, r1.w
mul r2.w, r2.w, l(-1.442695)
exp r2.w, r2.w
add r2.xw, -r2.xxxw, l(1.000000, 0.000000, 0.000000, 1.000000)
and r2.z, r2.w, r2.z
movc r2.x, r2.y, r2.x, r2.z
movc r1.w, cb0[1].x, r2.x, r1.w
mov_sat r2.x, cb0[4].w
mul r1.w, r1.w, r2.x
mad_sat r2.x, v1.w, cb0[7].z, cb0[7].w
mul r1.w, r1.w, r2.x
mad r0.xyz, -r0.xyzx, r0.wwww, cb0[4].xyzx
mad r0.xyz, r1.wwww, r0.xyzx, r1.xyzx
mov r0.w, l(0)
mov r1.x, l(0)
loop
  ige r1.y, r1.x, l(20)
  breakc_nz r1.y
  mad r1.y, v2.x, cb0[r1.x + 31].x, cb0[r1.x + 32].x
  mul r1.y, r1.y, l(6.283185)
  mad r1.z, v2.z, cb0[r1.x + 33].x, cb0[r1.x + 34].x
  mul r1.z, r1.z, l(6.283185)
  sincos null, r1.yz, r1.yyzy
  add r1.y, r1.z, r1.y
  mad r0.w, r1.y, cb0[r1.x + 30].x, r0.w
  iadd r1.x, r1.x, l(5)
endloop
add r0.w, r0.w, v2.y
mad_sat r0.w, r0.w, cb0[8].x, cb0[8].y
mul r1.x, r0.w, l(-1.442695)
exp r1.x, r1.x
ieq r1.yz, cb0[2].xxxx, l(0, 1, 2, 0)
mul r1.w, r0.w, r0.w
mul r1.w, r1.w, l(-1.442695)
exp r1.w, r1.w
add r1.xw, -r1.xxxw, l(1.000000, 0.000000, 0.000000, 1.000000)
and r1.z, r1.w, r1.z
movc r1.x, r1.y, r1.x, r1.z
movc r0.w, cb0[2].x, r1.x, r0.w
mov_sat r1.x, cb0[5].w
mul r0.w, r0.w, r1.x
mad_sat r1.x, v1.w, cb0[8].z, cb0[8].w
mul r0.w, r0.w, r1.x
add r1.xyz, -r0.xyzx, cb0[5].xyzx
mad r0.xyz, r0.wwww, r1.xyzx, r0.xyzx
mov r0.w, l(0)
mov r1.x, l(0)
loop
  ige r1.y, r1.x, l(20)
  breakc_nz r1.y
  mad r1.y, v2.x, cb0[r1.x + 51].x, cb0[r1.x + 52].x
  mul r1.y, r1.y, l(6.283185)
  mad r1.z, v2.z, cb0[r1.x + 53].x, cb0[r1.x + 54].x
  mul r1.z, r1.z, l(6.283185)
  sincos null, r1.yz, r1.yyzy
  add r1.y, r1.z, r1.y
  mad r0.w, r1.y, cb0[r1.x + 50].x, r0.w
  iadd r1.x, r1.x, l(5)
endloop
add r0.w, r0.w, v2.y
mad_sat r0.w, r0.w, cb0[9].x, cb0[9].y
mul r1.x, r0.w, l(-1.442695)
exp r1.x, r1.x
ieq r1.yz, cb0[3].xxxx, l(0, 1, 2, 0)
mul r1.w, r0.w, r0.w
mul r1.w, r1.w, l(-1.442695)
exp r1.w, r1.w
add r1.xw, -r1.xxxw, l(1.000000, 0.000000, 0.000000, 1.000000)
and r1.z, r1.w, r1.z
movc r1.x, r1.y, r1.x, r1.z
movc r0.w, cb0[3].x, r1.x, r0.w
mov_sat r1.x, cb0[6].w
mul r0.w, r0.w, r1.x
mad_sat r1.x, v1.w, cb0[9].z, cb0[9].w
mul r0.w, r0.w, r1.x
add r1.xyz, -r0.xyzx, cb0[6].xyzx
mad o0.xyz, r0.wwww, r1.xyzx, r0.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 125 instruction slots used

///////////////////////////////// HLSL Code /////////////////////////////////
// // ---- Created with 3Dmigoto v1.3.16 on Wed Mar 09 23:51:12 2022
//
// cbuffer _Globals : register(b0)
// {
//   float4 ambLit : packoffset(c0);
//   int hFogType[3] : packoffset(c1);
//   float4 cHFog[3] : packoffset(c4);
//   float4 hFogParam[3] : packoffset(c7);
//   float hFogFlucPrms[60] : packoffset(c10);
//   float fOLLtEfFade : packoffset(c69.y) = {0};
//   float3 vOLAmbEfScaler : packoffset(c70) = {1,1,1};
//   float3 vOLColorScaler : packoffset(c71) = {1,1,1};
//   float fOLCSatFade : packoffset(c71.w) = {0};
//   float fOLPtnFade : packoffset(c72) = {0};
// }
//
// SamplerState __smpsLit_s : register(s3);
// SamplerState __smpsOutlineColor_s : register(s4);
// Texture2D<float4> sLit : register(t3);
// Texture2D<float4> sOutlineColor : register(t4);
// Texture2D<float4> sOutlineAutoHDRScaleExposure : register(t6);
//
//
// // 3Dmigoto declarations
// #define cmp -
// Texture1D<float4> IniParams : register(t120);
// Texture2D<float4> StereoParams : register(t125);
//
//
// void main(
//   float4 v0 : SV_Position0,
//   float4 v1 : TEXCOORD0,
//   float4 v2 : TEXCOORD1,
//   float4 v3 : TEXCOORD2,
//   nointerpolation int v4 : TEXCOORD3,
//   out float4 o0 : SV_Target0)
// {
//   float4 r0,r1,r2;
//   uint4 bitmask, uiDest;
//   float4 fDest;
//
//   r0.x = (int)v4.x;
//   r0.x = 0.5 + r0.x;
//   r0.x = 0.00390625 * r0.x;
//   r0.y = 0.5;
//   r0.xyz = sOutlineColor.Sample(__smpsOutlineColor_s, r0.xy).xyz;
//   r0.w = sLit.Sample(__smpsLit_s, v3.xy).x;
//   r0.xyz = vOLColorScaler.xyz * r0.xyz;
//   r1.x = saturate(fOLLtEfFade);
//   r1.yzw = ambLit.xyz * vOLAmbEfScaler.xyz + float3(-1,-1,-1);
//   r1.xyz = r1.xxx * r1.yzw + float3(1,1,1);
//   r0.xyz = r1.xyz * r0.xyz;
//   r1.x = saturate(fOLPtnFade);
//   r0.w = -1 + r0.w;
//   r0.w = r1.x * r0.w + 1;
//   r0.xyz = r0.xyz * r0.www;
//   r0.w = max(r0.y, r0.z);
//   r0.w = max(r0.x, r0.w);
//   r0.w = saturate(-0.00196000002 + r0.w);
//   r1.xyz = cmp(r0.xyz >= r0.www);
//   r1.xyz = r1.xyz ? float3(1,1,1) : 0;
//   r0.w = saturate(fOLCSatFade);
//   r1.xyz = r0.xyz * r1.xyz + -r0.xyz;
//   r0.xyz = r0.www * r1.xyz + r0.xyz;
//   r0.w = sOutlineAutoHDRScaleExposure.Load(float4(0,0,0,0)).x;
//   r0.w = 1 / r0.w;
//   r0.w = min(3.40282306e+038, r0.w);
//   r1.xyz = r0.xyz * r0.www;
//   r1.w = 0;
//   r2.x = 0;
//   while (true) {
//     r2.y = cmp((int)r2.x >= 20);
//     if (r2.y != 0) break;
//     r2.y = v2.x * hFogFlucPrms[r2.x+11] + hFogFlucPrms[r2.x+12];
//     r2.y = 6.28318501 * r2.y;
//     r2.z = v2.z * hFogFlucPrms[r2.x+13] + hFogFlucPrms[r2.x+14];
//     r2.z = 6.28318501 * r2.z;
//     r2.yz = cos(r2.yz);
//     r2.y = r2.y + r2.z;
//     r1.w = r2.y * hFogFlucPrms[r2.x] + r1.w;
//     r2.x = (int)r2.x + 5;
//   }
//   r1.w = v2.y + r1.w;
//   r1.w = saturate(r1.w * hFogParam[0].x + hFogParam[0].y);
//   r2.x = -1.44269502 * r1.w;
//   r2.x = exp2(r2.x);
//   r2.yz = cmp(hFogType[0] == int2(1,2));
//   r2.w = r1.w * r1.w;
//   r2.w = -1.44269502 * r2.w;
//   r2.w = exp2(r2.w);
//   r2.xw = float2(1,1) + -r2.xw;
//   r2.z = r2.z ? r2.w : 0;
//   r2.x = r2.y ? r2.x : r2.z;
//   r1.w = hFogType[0] ? r2.x : r1.w;
//   r2.x = saturate(cHFog[0].w);
//   r1.w = r2.x * r1.w;
//   r2.x = saturate(v1.w * hFogParam[0].z + hFogParam[0].w);
//   r1.w = r2.x * r1.w;
//   r0.xyz = -r0.xyz * r0.www + cHFog[0].xyz;
//   r0.xyz = r1.www * r0.xyz + r1.xyz;
//   r0.w = 0;
//   r1.x = 0;
//   while (true) {
//     r1.y = cmp((int)r1.x >= 20);
//     if (r1.y != 0) break;
//     r1.y = v2.x * hFogFlucPrms[r1.x+31] + hFogFlucPrms[r1.x+32];
//     r1.y = 6.28318501 * r1.y;
//     r1.z = v2.z * hFogFlucPrms[r1.x+33] + hFogFlucPrms[r1.x+34];
//     r1.z = 6.28318501 * r1.z;
//     r1.yz = cos(r1.yz);
//     r1.y = r1.y + r1.z;
//     r0.w = r1.y * hFogFlucPrms[r1.x+30] + r0.w;
//     r1.x = (int)r1.x + 5;
//   }
//   r0.w = v2.y + r0.w;
//   r0.w = saturate(r0.w * hFogParam[1].x + hFogParam[1].y);
//   r1.x = -1.44269502 * r0.w;
//   r1.x = exp2(r1.x);
//   r1.yz = cmp(hFogType[1] == int2(1,2));
//   r1.w = r0.w * r0.w;
//   r1.w = -1.44269502 * r1.w;
//   r1.w = exp2(r1.w);
//   r1.xw = float2(1,1) + -r1.xw;
//   r1.z = r1.z ? r1.w : 0;
//   r1.x = r1.y ? r1.x : r1.z;
//   r0.w = hFogType[1] ? r1.x : r0.w;
//   r1.x = saturate(cHFog[1].w);
//   r0.w = r1.x * r0.w;
//   r1.x = saturate(v1.w * hFogParam[1].z + hFogParam[1].w);
//   r0.w = r1.x * r0.w;
//   r1.xyz = cHFog[1].xyz + -r0.xyz;
//   r0.xyz = r0.www * r1.xyz + r0.xyz;
//   r0.w = 0;
//   r1.x = 0;
//   while (true) {
//     r1.y = cmp((int)r1.x >= 20);
//     if (r1.y != 0) break;
//     r1.y = v2.x * hFogFlucPrms[r1.x+51] + hFogFlucPrms[r1.x+52];
//     r1.y = 6.28318501 * r1.y;
//     r1.z = v2.z * hFogFlucPrms[r1.x+53] + hFogFlucPrms[r1.x+54];
//     r1.z = 6.28318501 * r1.z;
//     r1.yz = cos(r1.yz);
//     r1.y = r1.y + r1.z;
//     r0.w = r1.y * hFogFlucPrms[r1.x+50] + r0.w;
//     r1.x = (int)r1.x + 5;
//   }
//   r0.w = v2.y + r0.w;
//   r0.w = saturate(r0.w * hFogParam[2].x + hFogParam[2].y);
//   r1.x = -1.44269502 * r0.w;
//   r1.x = exp2(r1.x);
//   r1.yz = cmp(hFogType[2] == int2(1,2));
//   r1.w = r0.w * r0.w;
//   r1.w = -1.44269502 * r1.w;
//   r1.w = exp2(r1.w);
//   r1.xw = float2(1,1) + -r1.xw;
//   r1.z = r1.z ? r1.w : 0;
//   r1.x = r1.y ? r1.x : r1.z;
//   r0.w = hFogType[2] ? r1.x : r0.w;
//   r1.x = saturate(cHFog[2].w);
//   r0.w = r1.x * r0.w;
//   r1.x = saturate(v1.w * hFogParam[2].z + hFogParam[2].w);
//   r0.w = r1.x * r0.w;
//   r1.xyz = cHFog[2].xyz + -r0.xyz;
//   o0.xyz = r0.www * r1.xyz + r0.xyz;
//   o0.w = 1;
//   return;
// }
//////////////////////////////// HLSL Errors ////////////////////////////////
// F:\SteamLibrary\steamapps\common\P5S\ShaderFixes\d27ba4290111b2c2-ps_replace.txt(65,10-59): warning X3206: 'Load': implicit truncation of vector type
// F:\SteamLibrary\steamapps\common\P5S\ShaderFixes\d27ba4290111b2c2-ps_replace.txt(144,19-39): error X3504: literal loop terminated early due to out of bounds array access
// F:\SteamLibrary\steamapps\common\P5S\ShaderFixes\d27ba4290111b2c2-ps_replace.txt(135,10-13): error X3696: infinite loop detected - loop never exits
/////////////////////////////////////////////////////////////////////////////
