//Characters PS 3. Background of station.
// ---- Created with 3Dmigoto v1.3.16 on Sun Sep 04 12:53:40 2022

cbuffer perMaterialBuffer : register(b0)
{
  float4 g_fogColor : packoffset(c0);
  float4 g_fogParam : packoffset(c1);
  float4 g_ambientColor : packoffset(c2);
  float4 g_lightColor : packoffset(c3);
  float4 g_lightDirection : packoffset(c4);
  row_major float4x4 g_matWorldViewProj : packoffset(c5);
  float4 g_commonParam : packoffset(c9);
  float4 g_lightingParam : packoffset(c10);
  float4 g_msParam0 : packoffset(c11);
  float4 g_specularParam : packoffset(c12);
  float4 g_hatchingParam : packoffset(c13);
  float4 g_outline0Param : packoffset(c14);
  float4 g_outemiParam : packoffset(c15);
  float4 g_waterParam0 : packoffset(c16);
  float4 g_waterParam1 : packoffset(c17);
  row_major float4x4 g_matWorldInvTrans : packoffset(c18);
  float4 g_uvOffset0 : packoffset(c22);
  float3 g_eyePos : packoffset(c23);
  float4 g_ScreenToUV : packoffset(c24);
  row_major float4x4 g_matWorld : packoffset(c25);
}

SamplerState g_sampler0_s : register(s0);
Texture2D<float4> g_texture0 : register(t0);


// 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,
  float4 v4 : TEXCOORD3,
  float4 v5 : TEXCOORD7,
  float4 v6 : TEXCOORD8,
  float4 v7 : COLOR0,
  out float4 o0 : SV_Target0,
  out float4 o1 : SV_Target1)
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 iniparams10 = IniParams.Load(int2(10,0));
  
  r0.xy = g_ScreenToUV.xy * v0.xy;
  r0.xy = r0.xy * float2(1,-1) + float2(0,1);
  r1.xyzw = g_texture0.Sample(g_sampler0_s, v2.xy).xyzw;
  r0.z = saturate(-0.5 + v7.y);
  r0.z = r0.z * 1.00999999 + 0.5;
  r0.xy = floor(r0.xy);
  r0.xy = float2(0.5,0.5) * r0.xy;
  r2.xy = cmp(r0.xy >= -r0.xy);
  r0.xy = frac(abs(r0.xy));
  r0.xy = r2.xy ? r0.xy : -r0.xy;
  r2.xy = r0.xy + r0.xy;
  r0.xy = -r0.xy * float2(2,2) + float2(1,1);
  r0.x = r0.x * r0.y;
  r0.x = r2.x * r2.y + r0.x;
  r0.x = r0.x * 0.99000001 + r0.z;
  r0.x = saturate(trunc(r0.x));
  r0.x = r1.w * r0.x;
  r0.y = cmp(v7.x >= r0.x);
  if (r0.y != 0) discard;
  r0.y = 1 / g_lightingParam.x;
  r0.z = dot(v5.xyz, v3.xyz);
  r0.z = g_lightingParam.y + r0.z;
  r0.y = r0.z * r0.y;
  r0.y = max(-1, r0.y);
  r0.y = min(1, r0.y);
  r0.z = r0.y * 0.5 + 0.5;
  r0.y = -r0.y * 0.5 + 0.5;
  r2.xyz = g_ambientColor.xyz * r0.yyy;
  r0.yzw = r0.zzz * g_lightColor.xyz + r2.xyz;
  r2.x = dot(v5.xyz, v4.xyz);
  r2.x = -g_outline0Param.x * iniparams10.w + r2.x;
  r2.y = 1 * iniparams10.w / g_outline0Param.y;
  r2.x = saturate(r2.x * r2.y);
  r2.x = 1 + -r2.x;
  r2.x = -r2.x * g_outline0Param.w * iniparams10.w + 1;
  r0.yzw = r0.yzw * r1.xyz;
  o0.xyz = r0.yzw * r2.xxx;
  o0.w = r0.x;
  o1.xy = v7.wz;
  o1.z = 1;
  o1.w = r1.w;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.16 on Sun Sep 04 12:53:40 2022
//
//
// Buffer Definitions:
//
// cbuffer perMaterialBuffer
// {
//
//   float4 g_fogColor;                 // Offset:    0 Size:    16 [unused]
//   float4 g_fogParam;                 // Offset:   16 Size:    16 [unused]
//   float4 g_ambientColor;             // Offset:   32 Size:    16
//   float4 g_lightColor;               // Offset:   48 Size:    16
//   float4 g_lightDirection;           // Offset:   64 Size:    16 [unused]
//   row_major float4x4 g_matWorldViewProj;// Offset:   80 Size:    64 [unused]
//   float4 g_commonParam;              // Offset:  144 Size:    16 [unused]
//   float4 g_lightingParam;            // Offset:  160 Size:    16
//   float4 g_msParam0;                 // Offset:  176 Size:    16 [unused]
//   float4 g_specularParam;            // Offset:  192 Size:    16 [unused]
//   float4 g_hatchingParam;            // Offset:  208 Size:    16 [unused]
//   float4 g_outline0Param;            // Offset:  224 Size:    16
//   float4 g_outemiParam;              // Offset:  240 Size:    16 [unused]
//   float4 g_waterParam0;              // Offset:  256 Size:    16 [unused]
//   float4 g_waterParam1;              // Offset:  272 Size:    16 [unused]
//   row_major float4x4 g_matWorldInvTrans;// Offset:  288 Size:    64 [unused]
//   float4 g_uvOffset0;                // Offset:  352 Size:    16 [unused]
//   float3 g_eyePos;                   // Offset:  368 Size:    12 [unused]
//   float4 g_ScreenToUV;               // Offset:  384 Size:    16
//   row_major float4x4 g_matWorld;     // Offset:  400 Size:    64 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_sampler0                        sampler      NA          NA    0        1
// g_texture0                        texture  float4          2d    0        1
// perMaterialBuffer                 cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xy
// TEXCOORD                 0   xyzw        1     NONE   float
// TEXCOORD                 1   xy          2     NONE   float   xy
// TEXCOORD                 2   xyz         3     NONE   float   xyz
// TEXCOORD                 3   xyz         4     NONE   float   xyz
// TEXCOORD                 7   xyz         5     NONE   float   xyz
// TEXCOORD                 8   xyzw        6     NONE   float
// COLOR                    0   xyzw        7     NONE   float   xyzw
//
//
// 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_4_0
dcl_constantbuffer cb0[25], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_input_ps linear v2.xy
dcl_input_ps linear v3.xyz
dcl_input_ps linear v4.xyz
dcl_input_ps linear v5.xyz
dcl_input_ps linear v7.xyzw
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_temps 3
mul r0.xy, v0.xyxx, cb0[24].xyxx
mad r0.xy, r0.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000), l(0.000000, 1.000000, 0.000000, 0.000000)
sample r1.xyzw, v2.xyxx, t0.xyzw, s0
add_sat r0.z, v7.y, l(-0.500000)
mad r0.z, r0.z, l(1.010000), l(0.500000)
round_ni r0.xy, r0.xyxx
mul r0.xy, r0.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
ge r2.xy, r0.xyxx, -r0.xyxx
frc r0.xy, |r0.xyxx|
movc r0.xy, r2.xyxx, r0.xyxx, -r0.xyxx
add r2.xy, r0.xyxx, r0.xyxx
mad r0.xy, -r0.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(1.000000, 1.000000, 0.000000, 0.000000)
mul r0.x, r0.y, r0.x
mad r0.x, r2.x, r2.y, r0.x
mad r0.x, r0.x, l(0.990000), r0.z
round_z_sat r0.x, r0.x
mul r0.x, r0.x, r1.w
ge r0.y, v7.x, r0.x
discard_nz r0.y
div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), cb0[10].x
dp3 r0.z, v5.xyzx, v3.xyzx
add r0.z, r0.z, cb0[10].y
mul r0.y, r0.y, r0.z
max r0.y, r0.y, l(-1.000000)
min r0.y, r0.y, l(1.000000)
mad r0.z, r0.y, l(0.500000), l(0.500000)
mad r0.y, -r0.y, l(0.500000), l(0.500000)
mul r2.xyz, r0.yyyy, cb0[2].xyzx
mad r0.yzw, r0.zzzz, cb0[3].xxyz, r2.xxyz
dp3 r2.x, v5.xyzx, v4.xyzx
add r2.x, r2.x, -cb0[14].x
div r2.y, l(1.000000, 1.000000, 1.000000, 1.000000), cb0[14].y
mul_sat r2.x, r2.y, r2.x
add r2.x, -r2.x, l(1.000000)
mad r2.x, -r2.x, cb0[14].w, l(1.000000)
mul r0.yzw, r1.xxyz, r0.yyzw
mul o0.xyz, r2.xxxx, r0.yzwy
mov o0.w, r0.x
mov o1.xy, v7.wzww
mov o1.z, l(1.000000)
mov o1.w, r1.w
ret
// Approximately 42 instruction slots used

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