Texture2D<float4> t2 : register(t2);

Texture2D<float4> t1 : register(t1);

Texture2D<float4> t0 : register(t0);

SamplerState s2_s : register(s2);

SamplerState s1_s : register(s1);

SamplerState s0_s : register(s0);

cbuffer cb3 : register(b3)
{
  float4 cb3[21];
}

cbuffer cb2 : register(b2)
{
  float4 cb2[112];
}

cbuffer cb1 : register(b1)
{
  float4 cb1[5];
}

cbuffer cb0 : register(b0)
{
  float4 cb0[44];
}




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


void main(
  float4 v0 : SV_POSITION0,
  float4 v1 : COLOR0,
  float4 v2 : TEXCOORD0,
  float4 v3 : TEXCOORD1,
  float4 v4 : TEXCOORD3,
  float2 v5 : texcoord4,
  float2 w5 : TEXCOORD8,
  float4 v6 : TEXCOORD5,
  float3 v7 : TEXCOORD7,
  out float4 o0 : SV_TARGET0)
{
  const float4 icb[] = { { 1.000000, 0, 0, 0},
                              { 0, 1.000000, 0, 0},
                              { 0, 0, 1.000000, 0},
                              { 0, 0, 0, 1.000000} };
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = cmp(0 != cb3[20].x);
  if (r0.x != 0) {
    r0.x = cmp(cb3[20].y < 0.949999988);
    if (r0.x != 0) {
      r0.xy = v6.yx / v6.ww;
      r0.xy = cb1[4].yx * r0.xy;
      r0.xy = (uint2)r0.xy;
      r0.xy = (int2)r0.xy & int2(3,3);
      r1.x = dot(float4(1,13,4,16), icb[r0.y+0].xyzw);
      r1.y = dot(float4(9,5,12,8), icb[r0.y+0].xyzw);
      r1.z = dot(float4(3,15,2,14), icb[r0.y+0].xyzw);
      r1.w = dot(float4(11,7,10,6), icb[r0.y+0].xyzw);
      r0.x = dot(r1.xyzw, icb[r0.x+0].xyzw);
      r0.y = 17 + -r0.x;
      r0.x = cb0[38].x ? r0.y : r0.x;
      r0.x = cb3[20].y * 17 + -r0.x;
      r0.x = -0.00999999978 + r0.x;
    } else {
      r0.x = 1;
    }
    r0.x = min(1, r0.x);
  } else {
    r0.x = 1;
  }
  r0.x = cmp(r0.x < 0);
  if (r0.x != 0) discard;
  r0.xyzw = t1.Sample(s1_s, v3.xy).xyzw;
  r1.xyzw = t1.Sample(s1_s, v3.zw).xyzw;
  r1.xy = r0.xy;
  r0.xyz = float3(-0.5,-0.5,-0.5) + r1.xyz;
  r0.xyz = v4.xxw * r0.xyz;
  r0.xyzw = r0.xyxy + r0.zzzz;
  r1.x = 1;
  r1.z = cb3[5].w;
  r0.xyzw = -r0.xyzw * r1.xxzz + v2.xyzw;
  r1.xyzw = t0.Sample(s0_s, r0.xy).xyzw;
  r0.x = cmp(cb3[20].z == 0.000000);
  if (r0.x != 0) {
    r2.xyzw = t2.Sample(s2_s, r0.zw).xyzw;
    r0.x = dot(r2.xyz, cb3[5].xyz);
    r0.x = cb3[11].z + r0.x;
    r0.x = r0.x * v5.x + v4.y;
    r0.y = 1 + -cb3[10].w;
    r0.y = -v4.z + r0.y;
    r0.x = r0.x + -r0.y;
    r0.y = cb3[10].w + -r0.y;
    r0.y = 1 / r0.y;
    r0.x = saturate(r0.x * r0.y);
  } else {
    r0.y = v4.y + r0.z;
    r0.z = 1 + -cb3[10].w;
    r0.z = -v4.z + r0.z;
    r0.y = r0.y + -r0.z;
    r0.z = cb3[10].w + -r0.z;
    r0.z = 1 / r0.z;
    r0.y = saturate(r0.y * r0.z);
    r0.zw = cmp(cb3[20].zz == float2(1,2));
    r0.w = r0.w ? 1.000000 : 0;
    r0.x = r0.z ? r0.y : r0.w;
  }
  r2.xyzw = v1.xyzw * r1.xyzw;
  r2.w = saturate(r2.w);
  r0.yzw = saturate(cb3[3].www + r1.xyz);
  r3.x = dot(r1.xyz, cb3[3].xyz);
  r3.w = saturate(v1.w * r3.x);
  r3.xyz = v1.xyz * r0.yzw;
  r0.yz = cmp(asint(cb3[15].xx) == int2(1,2));
  r0.w = saturate(dot(cb3[4].xyzw, r1.xyzw));
  r1.x = dot(cb3[3].xyzw, r1.xyzw);
  r1.w = saturate(v1.w * r1.x);
  r1.xyz = v1.xyz * r0.www;
  r1.xyzw = r0.zzzz ? r1.xyzw : v1.xyzw;
  r1.xyzw = r0.yyyy ? r3.xyzw : r1.xyzw;
  r1.xyzw = cb3[15].xxxx ? r1.xyzw : r2.xyzw;
  r0.x = r1.w * r0.x;
  r0.y = cmp(0.5 < cb3[14].y);
  r0.z = 1 + -cb3[14].z;
  r0.w = cmp(0 >= cb3[14].w);
  r0.w = r0.w ? 1 : cb3[14].w;
  r1.w = 1 + -r0.z;
  r0.z = v0.z * r0.w + -r0.z;
  r0.w = 1 / r1.w;
  r0.z = saturate(r0.z * r0.w);
  r0.w = r0.z * -2 + 3;
  r0.z = r0.z * r0.z;
  r0.z = -r0.w * r0.z + 1;
  r0.z = r0.x * r0.z;
  r0.x = r0.y ? r0.z : r0.x;
  r0.y = 1 + -cb3[13].x;
  r0.x = r0.x * r0.y;
  r0.yz = -cb0[43].yz * cb2[1].xy + float2(1,1);
  r1.xyz = r1.xyz * r0.yyy;
  r0.yzw = r1.xyz * r0.zzz;
  r0.yzw = cb2[111].www * r0.yzw;
  r1.x = max(r0.y, r0.z);
  r1.x = max(r1.x, r0.w);
  r1.x = r1.x * r0.x;
  r1.x = max(0.00999999978, r1.x);
  r0.yzw = r0.yzw / r1.xxx;
  r1.y = cmp(cb2[79].x < r1.x);
  r1.z = -cb2[79].x + cb2[78].w;
  r1.w = -cb2[79].x + r1.x;
  r2.x = 1 / r1.z;
  r1.w = saturate(r2.x * r1.w);
  r2.x = r1.w * -2 + 3;
  r1.w = r1.w * r1.w;
  r1.w = r2.x * r1.w;
  r1.z = r1.w * r1.z + cb2[79].x;
  r1.z = r1.z + -r1.x;
  r1.z = cb2[79].y * r1.z + r1.x;
  r1.x = r1.y ? r1.z : r1.x;
  // 1. 先获取原本要输出的基础颜色
  float3 finalColor = r0.yzw * r1.x;

  // 2. 提取亮度 (Luma)
  // 使用你提供的灰度权重公式
  float luma = dot(finalColor.xyz, float3(0.299, 0.587, 0.114));

  // 3. 映射为樱花粉色
  // 这里的系数 1.8, 0.8, 1.1 会显著增强红紫色调
  float3 sakuraColor = luma * float3(1.8, 0.8, 1.1);

  // 4. 将结果赋予输出寄存器
  o0.xyz = sakuraColor;
  o0.w = r0.x;
  return;
}