Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#require LightingV1 Support #246

Open
Almamu opened this issue Sep 2, 2024 · 0 comments
Open

#require LightingV1 Support #246

Almamu opened this issue Sep 2, 2024 · 0 comments
Assignees

Comments

@Almamu
Copy link
Owner

Almamu commented Sep 2, 2024

Looks like they've added some lighting system that adds code to shaders based on a #require directive. This seems to contain most of the logic on what code to add to vertex and fragment shaders.

void FUN_00501f00(void)

{
  undefined8 uVar1;
  undefined auVar2 [16];
  undefined auVar3 [16];
  undefined auVar4 [16];
  undefined auVar5 [16];
  undefined auVar6 [16];
  undefined auVar7 [16];
  undefined auVar8 [16];
  undefined auVar9 [16];
  undefined auVar10 [16];
  undefined auVar11 [16];
  undefined auVar12 [16];
  undefined auVar13 [16];
  uint uVar14;
  uint uVar15;
  char cVar16;
  undefined4 *puVar17;
  int iVar18;
  undefined (*pauVar19) [16];
  uint uVar20;
  undefined4 *puVar21;
  undefined *puVar22;
  undefined4 uVar23;
  int iVar24;
  undefined4 extraout_ECX;
  undefined4 extraout_ECX_00;
  undefined4 extraout_ECX_01;
  undefined4 extraout_ECX_02;
  undefined4 extraout_ECX_03;
  undefined4 extraout_ECX_04;
  undefined4 extraout_ECX_05;
  undefined4 extraout_ECX_06;
  undefined4 extraout_ECX_07;
  undefined4 extraout_ECX_08;
  undefined *puVar25;
  bool bVar26;
  uint uVar27;
  undefined local_1cf [24];
  undefined local_1b7 [24];
  undefined local_19f [24];
  undefined local_187 [24];
  undefined local_16f [24];
  undefined local_157 [24];
  undefined local_13f [3];
  undefined local_13c [16];
  undefined4 local_12c;
  uint local_128;
  undefined local_124 [16];
  undefined4 local_114;
  uint local_110;
  undefined local_10c [16];
  undefined4 local_fc;
  uint local_f8;
  undefined local_f4 [16];
  undefined8 local_e4;
  undefined local_dc [16];
  undefined8 local_cc;
  undefined local_c4 [16];
  undefined8 local_b4;
  int local_ac;
  uint local_a8;
  uint local_a4;
  uint local_a0;
  uint local_9c;
  uint local_98;
  uint local_94;
  undefined local_90 [16];
  undefined8 local_80;
  uint local_78;
  undefined local_74 [8];
  undefined8 uStack_6c;
  undefined8 local_64;
  undefined local_5c [16];
  undefined4 local_4c;
  uint local_48;
  char local_41;
  undefined local_40 [4];
  undefined auStack_3c [8];
  undefined4 uStack_34;
  undefined4 local_30;
  uint local_2c;
  uint local_28;
  undefined local_24 [16];
  undefined8 local_14;
  
  bVar26 = false;
  local_9c = 0;
  cVar16 = FUN_004108e0("LightingV1",10);
  if (cVar16 != '\0') {
    local_64 = 0xf00000008;
    _local_74 = (unkuint9)0x474e49544847494c;
    uStack_6c._1_7_ = 0;
    puVar17 = (undefined4 *)FUN_005063a0(local_74);
    if (0xf < (uint)puVar17[5]) {
      puVar17 = (undefined4 *)*puVar17;
    }
    bVar26 = true;
    iVar18 = FUN_005cef57(puVar17);
    local_41 = '\x01';
    if (iVar18 != 0) goto LAB_00501f89;
  }
  local_41 = '\0';
LAB_00501f89:
  if ((bVar26) && (0xf < local_64._4_4_)) {
    FUN_00414390(local_74,local_74._0_4_,local_64._4_4_);
  }
  if (local_41 != '\0') {
    local_30 = 0xc;
    local_2c = 0xf;
    stack0xffffffc8 = 0x544e494f;
    _local_40 = 0x505f53544847494c;
    uStack_34 = 0;
    puVar17 = (undefined4 *)FUN_005063a0(local_40);
    if (0xf < (uint)puVar17[5]) {
      puVar17 = (undefined4 *)*puVar17;
    }
    local_a4 = FUN_005cef57(puVar17);
    FUN_004143d0();
    auVar2 = _local_74;
    uStack_6c._2_1_ = 0x54;
    local_74 = auVar2._0_8_;
    uStack_6c._0_2_ = 0x4f50;
    local_64 = 0xf0000000b;
    uStack_6c._4_4_ = 0;
    local_74 = (undefined  [8])0x535f53544847494c;
    uStack_6c._3_5_ = 0;
    puVar17 = (undefined4 *)FUN_005063a0(local_74);
    if (0xf < (uint)puVar17[5]) {
      puVar17 = (undefined4 *)*puVar17;
    }
    local_94 = FUN_005cef57(puVar17);
    FUN_004143d0();
    auVar2 = _local_74;
    uStack_6c._2_1_ = 0x45;
    local_74 = auVar2._0_8_;
    uStack_6c._0_2_ = 0x4255;
    local_64 = 0xf0000000b;
    uStack_6c._4_4_ = 0;
    local_74 = (undefined  [8])0x545f53544847494c;
    uStack_6c._3_5_ = 0;
    puVar17 = (undefined4 *)FUN_005063a0(local_74);
    if (0xf < (uint)puVar17[5]) {
      puVar17 = (undefined4 *)*puVar17;
    }
    local_98 = FUN_005cef57(puVar17);
    FUN_004143d0();
    local_24 = ZEXT816(0);
    local_14 = 0;
    FUN_00414570("LIGHTS_DIRECTIONAL",0x12);
    puVar17 = (undefined4 *)FUN_005063a0(local_24);
    if (0xf < (uint)puVar17[5]) {
      puVar17 = (undefined4 *)*puVar17;
    }
    local_9c = FUN_005cef57(puVar17);
    FUN_004143d0();
    local_28 = 0x1f;
    local_24 = ZEXT816(0);
    puVar17 = (undefined4 *)FUN_00414510(local_24,&local_28);
    local_24._0_4_ = puVar17;
    local_14 = CONCAT44(local_28,0x19);
    *puVar17 = 0x4847494c;
    puVar17[1] = 0x535f5354;
    puVar17[2] = 0x5f544f50;
    puVar17[3] = 0x44414853;
    *(undefined8 *)(puVar17 + 4) = 0x494b4f4f435f574f;
    *(undefined *)(puVar17 + 6) = 0x45;
    *(undefined *)((int)puVar17 + 0x19) = 0;
    puVar17 = (undefined4 *)FUN_005063a0(local_24);
    if (0xf < (uint)puVar17[5]) {
      puVar17 = (undefined4 *)*puVar17;
    }
    local_a8 = FUN_005cef57(puVar17);
    FUN_004143d0();
    local_28 = 0x1f;
    _local_40 = ZEXT816(0);
    puVar17 = (undefined4 *)FUN_00414510(local_40,&local_28);
    local_2c = local_28;
    *puVar17 = 0x4847494c;
    puVar17[1] = 0x535f5354;
    puVar17[2] = 0x5f544f50;
    puVar17[3] = 0x44414853;
    *(undefined2 *)(puVar17 + 4) = 0x574f;
    local_40 = (undefined  [4])puVar17;
    *(undefined *)((int)puVar17 + 0x12) = 0;
    local_30 = 0x12;
    puVar17 = (undefined4 *)FUN_005063a0(local_40);
    if (0xf < (uint)puVar17[5]) {
      puVar17 = (undefined4 *)*puVar17;
    }
    local_78 = FUN_005cef57(puVar17);
    FUN_004143d0();
    local_28 = 0x1f;
    _local_40 = ZEXT816(0);
    puVar17 = (undefined4 *)FUN_00414510(local_40,&local_28);
    local_2c = local_28;
    *puVar17 = 0x4847494c;
    puVar17[1] = 0x535f5354;
    puVar17[2] = 0x5f544f50;
    puVar17[3] = 0x4b4f4f43;
    *(undefined2 *)(puVar17 + 4) = 0x4549;
    local_40 = (undefined  [4])puVar17;
    *(undefined *)((int)puVar17 + 0x12) = 0;
    local_30 = 0x12;
    puVar17 = (undefined4 *)FUN_005063a0(local_40);
    if (0xf < (uint)puVar17[5]) {
      puVar17 = (undefined4 *)*puVar17;
    }
    local_ac = FUN_005cef57(puVar17);
    FUN_004143d0();
    local_28 = 0x1f;
    local_24 = ZEXT816(0);
    puVar17 = (undefined4 *)FUN_00414510(local_24,&local_28);
    local_24._0_4_ = puVar17;
    local_14 = CONCAT44(local_28,0x19);
    *puVar17 = 0x4847494c;
    puVar17[1] = 0x445f5354;
    puVar17[2] = 0x43455249;
    puVar17[3] = 0x4e4f4954;
    *(undefined8 *)(puVar17 + 4) = 0x4f444148535f4c41;
    *(undefined *)(puVar17 + 6) = 0x57;
    *(undefined *)((int)puVar17 + 0x19) = 0;
    puVar17 = (undefined4 *)FUN_005063a0(local_24);
    if (0xf < (uint)puVar17[5]) {
      puVar17 = (undefined4 *)*puVar17;
    }
    local_28 = FUN_005cef57(puVar17);
    FUN_004143d0();
    local_a0 = 0x1f;
    _local_40 = ZEXT816(0);
    pauVar19 = (undefined (*) [16])FUN_00414510(local_40,&local_a0);
    local_2c = local_a0;
    local_40 = (undefined  [4])pauVar19;
    local_30 = 0x13;
    *pauVar19 = s_LIGHTS_POINT_SHADOW_00732088._0_16_;
    *(undefined2 *)pauVar19[1] = 0x4f44;
    pauVar19[1][2] = 0x57;
    pauVar19[1][3] = 0;
    puVar17 = (undefined4 *)FUN_005063a0(local_40);
    if (0xf < (uint)puVar17[5]) {
      puVar17 = (undefined4 *)*puVar17;
    }
    uVar20 = FUN_005cef57(puVar17);
    FUN_004143d0();
    if (local_a4 != 0) {
      FUN_004f6b10();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_004143d0();
    }
    if (local_94 != 0) {
      FUN_004f6b10();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_004143d0();
    }
    if (local_98 != 0) {
      FUN_004f6b10();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_004143d0();
    }
    if (local_9c != 0) {
      FUN_004f6b10();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_004143d0();
    }
    if (local_ac + local_28 * 3 + local_78 + local_a8 != 0) {
      FUN_004f6b10();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_004143d0();
    }
    if (uVar20 == 0) {
      FUN_00413010("vec3 PerformLighting_V1(vec3 worldPos, vec3 color, vec3 normal, vec3 viewVector,  vec3 specularTint, vec3 ambient, float roughness, float metallic)\n{\n\tvec3 light = CAST3(0. 0);\n"
                   ,0xaf);
      uVar27 = 0;
      uVar14 = local_a8;
      uVar15 = local_a4;
    }
    else {
      FUN_004f6b10();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_0046ec10(local_24,&DAT_00731e38);
      puVar21 = (undefined4 *)FUN_004607d0();
      puVar17 = puVar21 + 4;
      if (0xf < (uint)puVar21[5]) {
        puVar21 = (undefined4 *)*puVar21;
      }
      FUN_00413010(puVar21,*puVar17);
      FUN_004143d0();
      FUN_004143d0();
      FUN_004143d0();
      FUN_00413010("vec3 PerformLighting_V1(vec3 worldPos, vec3 color, vec3 normal, vec3 viewVector,  vec3 specularTint, vec3 ambient, float roughness, float metallic)\n{\n\tvec3 light = CAST3(0. 0);\n"
                   ,0xaf);
      uVar27 = 0;
      do {
        FUN_00413010(&DAT_007351e8,2);
        if ((int)uVar27 < 0) {
          iVar18 = FUN_00440eb0();
          puVar22 = (undefined *)(iVar18 + -1);
          *puVar22 = 0x2d;
          uVar23 = extraout_ECX;
        }
        else {
          puVar22 = (undefined *)FUN_00440eb0();
          uVar23 = extraout_ECX_00;
        }
        FUN_00440ee0(puVar22,(int)&local_80 + 5,uVar23);
        uVar23 = FUN_0042bd10(0,"\tconst uint i = ",0x10);
        FUN_00413f80(uVar23);
        uVar23 = FUN_00413010(&DAT_007352b4,3);
        FUN_00413f80(uVar23);
        puVar22 = local_24;
        if (0xf < local_14._4_4_) {
          puVar22 = (undefined *)local_24._0_4_;
        }
        FUN_00413010(puVar22,(undefined4)local_14);
        FUN_004143d0();
        FUN_004143d0();
        FUN_004143d0();
        FUN_00413010("\tvec3 lightDelta = g_LPoint_Origin[i].xyz - worldPos;\n",0x36);
        FUN_00413010("\tvec4 projectedCoords = CalculateProjectedCoordsPoint(worldPos, g_LPoint_Orig in[i].xyz, g_LFeature_ShadowPointProjection[i], g_LFeature_ShadowPointProjectionTransform[i] );\n"
                     ,0xac);
        FUN_00413010("\tfloat shadowFactor = PerformPointShadowMapping(projectedCoords);\n",0x42);
        FUN_00413010("\tlight += ComputePBRLightShadow(normal, lightDelta, viewVector, color, g_LPoi nt_Color[i].rgb, g_LPoint_Color[i].w, g_LPoint_Origin[i].w, specularTint, ambient, roughness , metallic, shadowFactor);\n"
                     ,0xc4);
        FUN_00413010(&DAT_00732104,2);
        uVar27 = uVar27 + 1;
        uVar14 = local_a8;
        uVar15 = local_a4;
      } while (uVar27 < uVar20);
    }
    for (; uVar20 = local_a4, local_a8 = uVar14, uVar27 < local_a4; uVar27 = uVar27 + 1) {
      local_a4 = uVar15;
                    /* WARNING: Read-only address (ram,0x00732088) is written */
      FUN_00413010(&DAT_007351e8,2);
      if ((int)uVar27 < 0) {
        iVar18 = FUN_00440eb0();
        puVar22 = (undefined *)(iVar18 + -1);
        *puVar22 = 0x2d;
        uVar23 = extraout_ECX_01;
      }
      else {
        puVar22 = (undefined *)FUN_00440eb0();
        uVar23 = extraout_ECX_02;
      }
      FUN_00440ee0(puVar22,(int)&local_80 + 5,uVar23);
      uVar23 = FUN_0042bd10(0,"\tconst uint i = ",0x10);
      FUN_00413f80(uVar23);
      uVar23 = FUN_00413010(&DAT_007352b4,3);
      FUN_00413f80(uVar23);
      puVar22 = local_24;
      if (0xf < local_14._4_4_) {
        puVar22 = (undefined *)local_24._0_4_;
      }
      FUN_00413010(puVar22,(undefined4)local_14);
      FUN_004143d0();
      FUN_004143d0();
      FUN_004143d0();
      FUN_00413010("\tvec3 lightDelta = g_LPoint_Origin[i].xyz - worldPos;\n",0x36);
      FUN_00413010("\tlight += ComputePBRLightShadow(normal, lightDelta, viewVector, color, g_LPoint _Color[i].rgb, g_LPoint_Color[i].w, g_LPoint_Origin[i].w, specularTint, ambient, roughness, me tallic, 1.0);\n"
                   ,0xbb);
      FUN_00413010(&DAT_00732104,2);
      uVar14 = local_a8;
      uVar15 = local_a4;
      local_a4 = uVar20;
    }
                    /* WARNING: Read-only address (ram,0x00732088) is written */
    uVar20 = 0;
    local_a4 = uVar15;
    iVar18 = local_ac;
    if (uVar14 != 0) {
      do {
        FUN_00413010(&DAT_007351e8,2);
        if ((int)uVar20 < 0) {
          iVar18 = FUN_00440eb0();
          puVar22 = (undefined *)(iVar18 + -1);
          *puVar22 = 0x2d;
          uVar23 = extraout_ECX_03;
        }
        else {
          puVar22 = (undefined *)FUN_00440eb0();
          uVar23 = extraout_ECX_04;
        }
        FUN_00440ee0(puVar22,(int)&local_80 + 5,uVar23);
        uVar23 = FUN_0042bd10(0,"\tconst uint i = ",0x10);
        FUN_00413f80(uVar23);
        uVar23 = FUN_00413010(&DAT_007352b4,3);
        FUN_00413f80(uVar23);
        puVar22 = local_24;
        if (0xf < local_14._4_4_) {
          puVar22 = (undefined *)local_24._0_4_;
        }
        FUN_00413010(puVar22,(undefined4)local_14);
        FUN_004143d0();
        FUN_004143d0();
        FUN_004143d0();
        FUN_00413010("\tvec3 lightDelta = g_LSpot_Origin[i].xyz - worldPos;\n",0x35);
        FUN_00413010("\tvec3 projectedCoords = CalculateProjectedCoords(worldPos, g_LFeature_ShadowP rojection[i]);\n"
                     ,0x5c);
        FUN_00413010("\tfloat shadowFactor = PerformShadowMapping(projectedCoords, g_LFeature_Shadow ProjectionTransform[i]);\n"
                     ,0x66);
        FUN_00413010("\tvec3 colorCookie = texSample2D(COOKIE_SAMPLER, projectedCoords.xy).rgb;\n",
                     0x49);
        FUN_00413010("\tlight += ComputePBRLightShadow(normal, lightDelta, viewVector, color, g_LSpo t_Color[i].rgb * colorCookie, g_LSpot_Color[i].w, g_LSpot_Exponent[i].x, specularTint, ambie nt, roughness, metallic, shadowFactor);\n"
                     ,0xd1);
        FUN_00413010(&DAT_00732104,2);
        uVar20 = uVar20 + 1;
        iVar18 = local_ac;
      } while (uVar20 < uVar14);
    }
    for (; uVar27 = local_94, iVar24 = local_78, iVar18 != 0; iVar18 = iVar18 + -1) {
                    /* WARNING: Read-only address (ram,0x00732088) is written */
      FUN_00413010(&DAT_007351e8,2);
      if ((int)uVar20 < 0) {
        iVar24 = FUN_00440eb0();
        puVar22 = (undefined *)(iVar24 + -1);
        *puVar22 = 0x2d;
        uVar23 = extraout_ECX_05;
      }
      else {
        puVar22 = (undefined *)FUN_00440eb0();
        uVar23 = extraout_ECX_06;
      }
      FUN_00440ee0(puVar22,(int)&local_80 + 5,uVar23);
      uVar23 = FUN_0042bd10(0,"\tconst uint i = ",0x10);
      FUN_00413f80(uVar23);
      uVar23 = FUN_00413010(&DAT_007352b4,3);
      FUN_00413f80(uVar23);
      puVar22 = local_24;
      if (0xf < local_14._4_4_) {
        puVar22 = (undefined *)local_24._0_4_;
      }
      FUN_00413010(puVar22,(undefined4)local_14);
      FUN_004143d0();
      FUN_004143d0();
      FUN_004143d0();
      FUN_00413010("\tvec3 lightDelta = g_LSpot_Origin[i].xyz - worldPos;\n",0x35);
      FUN_00413010("\tvec3 projectedCoords = CalculateProjectedCoords(worldPos, g_LFeature_ShadowPro jection[i]);\n"
                   ,0x5c);
      FUN_00413010("\tvec3 colorCookie = texSample2D(COOKIE_SAMPLER, projectedCoords.xy).rgb;\n",
                   0x49);
      FUN_00413010("\tlight += ComputePBRLightShadow(normal, lightDelta, viewVector, color, g_LSpot_ Color[i].rgb * colorCookie, g_LSpot_Color[i].w, g_LSpot_Exponent[i].x, specularTint, ambient, roughness, metallic, 1.0);\n"
                   ,200);
      FUN_00413010(&DAT_00732104,2);
      uVar20 = uVar20 + 1;
    }
    for (; uVar15 = uVar20, uVar14 = local_98, local_94 = uVar27, iVar24 != 0; iVar24 = iVar24 + -1)
    {
      FUN_00413010(&DAT_007351e8,2);
      if ((int)uVar20 < 0) {
        iVar18 = FUN_00440eb0();
        puVar22 = (undefined *)(iVar18 + -1);
        *puVar22 = 0x2d;
        uVar23 = extraout_ECX_07;
      }
      else {
        puVar22 = (undefined *)FUN_00440eb0();
        uVar23 = extraout_ECX_08;
      }
      FUN_00440ee0(puVar22,(int)&local_80 + 5,uVar23);
      uVar23 = FUN_0042bd10(0,"\tconst uint i = ",0x10);
      FUN_00413f80(uVar23);
      uVar23 = FUN_00413010(&DAT_007352b4,3);
      FUN_00413f80(uVar23);
      puVar22 = local_24;
      if (0xf < local_14._4_4_) {
        puVar22 = (undefined *)local_24._0_4_;
      }
      FUN_00413010(puVar22,(undefined4)local_14);
      FUN_004143d0();
      FUN_004143d0();
      FUN_004143d0();
      FUN_00413010("\tvec3 lightDelta = g_LSpot_Origin[i].xyz - worldPos;\n",0x35);
      FUN_00413010("\tfloat spotCookie = -dot(normalize(lightDelta), g_LSpot_Direction[i].xyz);\n",
                   0x4b);
      FUN_00413010("\tspotCookie = smoothstep(g_LSpot_Direction[i].w, g_LSpot_Origin[i].w, spotCooki e);\n"
                   ,0x53);
      FUN_00413010("\tvec3 projectedCoords = CalculateProjectedCoords(worldPos, g_LFeature_ShadowPro jection[i]);\n"
                   ,0x5c);
      FUN_00413010("\tfloat shadowFactor = PerformShadowMapping(projectedCoords, g_LFeature_ShadowPr ojectionTransform[i]);\n"
                   ,0x66);
      FUN_00413010("\tlight += ComputePBRLightShadow(normal, lightDelta, viewVector, color, g_LSpot_ Color[i].rgb * spotCookie, g_LSpot_Color[i].w, g_LSpot_Exponent[i].x, specularTint, ambient, r oughness, metallic, shadowFactor);\n"
                   ,0xd0);
      FUN_00413010(&DAT_00732104,2);
      uVar20 = uVar20 + 1;
      uVar27 = local_94;
    }
    for (; local_78 = uVar15, local_98 = uVar14, uVar20 < uVar27; uVar20 = uVar20 + 1) {
      FUN_00413010(&DAT_007351e8,2);
      if ((int)uVar20 < 0) {
        iVar18 = FUN_00440eb0();
        *(undefined *)(iVar18 + -1) = 0x2d;
        puVar22 = (undefined *)(iVar18 + -1);
      }
      else {
        puVar22 = (undefined *)FUN_00440eb0();
      }
      local_30 = 0;
      local_2c = 0;
      _local_40 = ZEXT816(0);
      if (puVar22 == local_13f) {
        local_2c = 0xf;
        auVar2[15] = 0;
        auVar2._0_15_ = stack0xffffffc1;
        _local_40 = auVar2 << 8;
      }
      else {
        FUN_00414570(puVar22,local_13f + -(int)puVar22);
      }
      uVar23 = FUN_0042bd10(0,"\tconst uint i = ",0x10);
      FUN_00413f80(uVar23);
      uVar23 = FUN_00413010(&DAT_007352b4,3);
      FUN_00413f80(uVar23);
      puVar22 = local_24;
      if (0xf < local_14._4_4_) {
        puVar22 = (undefined *)local_24._0_4_;
      }
      FUN_00413010(puVar22,(undefined4)local_14);
      FUN_004143d0();
      FUN_004143d0();
      FUN_004143d0();
      FUN_00413010("\tvec3 lightDelta = g_LSpot_Origin[i].xyz - worldPos;\n",0x35);
      FUN_00413010("\tfloat spotCookie = -dot(normalize(lightDelta), g_LSpot_Direction[i].xyz);\n",
                   0x4b);
      FUN_00413010("\tspotCookie = smoothstep(g_LSpot_Direction[i].w, g_LSpot_Origin[i].w, spotCooki e);\n"
                   ,0x53);
      FUN_00413010("\tlight += ComputePBRLightShadow(normal, lightDelta, viewVector, color, g_LSpot_ Color[i].rgb * spotCookie, g_LSpot_Color[i].w, g_LSpot_Exponent[i].x, specularTint, ambient, r oughness, metallic, 1.0);\n"
                   ,199);
      FUN_00413010(&DAT_00732104,2);
      uVar15 = local_78;
      uVar14 = local_98;
    }
    uVar20 = 0;
    if (uVar14 != 0) {
      do {
        FUN_00413010(&DAT_007351e8,2);
        if ((int)uVar20 < 0) {
          iVar18 = FUN_00440eb0();
          *(undefined *)(iVar18 + -1) = 0x2d;
          puVar22 = (undefined *)(iVar18 + -1);
        }
        else {
          puVar22 = (undefined *)FUN_00440eb0();
        }
        local_64 = 0;
        _local_74 = ZEXT816(0);
        if (puVar22 == local_157) {
          local_64 = 0xf00000000;
          auVar3[15] = 0;
          auVar3._0_15_ = stack0xffffff8d;
          _local_74 = auVar3 << 8;
        }
        else {
          FUN_00414570(puVar22,local_157 + -(int)puVar22);
        }
        uVar23 = FUN_0042bd10(0,"\tconst uint i = ",0x10);
        FUN_00413f80(uVar23);
        uVar23 = FUN_00413010(&DAT_007352b4,3);
        FUN_00413f80(uVar23);
        puVar22 = local_24;
        if (0xf < local_14._4_4_) {
          puVar22 = (undefined *)local_24._0_4_;
        }
        FUN_00413010(puVar22,(undefined4)local_14);
        FUN_004143d0();
        FUN_004143d0();
        if (0xf < local_64._4_4_) {
          FUN_00414390(local_74,local_74._0_4_,local_64._4_4_);
        }
        FUN_00413010("\tvec3 lightDelta = PointSegmentDelta(worldPos, g_LTube_OriginA[i].xyz, g_LTub e_OriginB[i].xyz);\n"
                     ,0x60);
        FUN_00413010("\tlight += ComputePBRLightShadow(normal, lightDelta, viewVector, color, g_LTub e_Color[i].rgb, g_LTube_Color[i].w, g_LTube_OriginA[i].w, specularTint, ambient, roughness, metallic, 1.0);\n"
                     ,0xb9);
        FUN_00413010(&DAT_00732104,2);
        uVar20 = uVar20 + 1;
      } while (uVar20 < uVar14);
    }
    uVar20 = 0;
    uVar27 = local_9c;
    if (local_28 != 0) {
      iVar18 = local_78 + 2;
      do {
        FUN_00413010(&DAT_007351e8,2);
        if ((int)uVar20 < 0) {
          iVar24 = FUN_00440eb0();
          *(undefined *)(iVar24 + -1) = 0x2d;
          puVar22 = (undefined *)(iVar24 + -1);
        }
        else {
          puVar22 = (undefined *)FUN_00440eb0();
        }
        local_fc = 0;
        local_f8 = 0;
        local_10c = ZEXT816(0);
        if (puVar22 == local_16f) {
          local_f8 = 0xf;
          auVar4[15] = 0;
          auVar4._0_15_ = local_10c._1_15_;
          local_10c = auVar4 << 8;
        }
        else {
          FUN_00414570(puVar22,local_16f + -(int)puVar22);
        }
        pauVar19 = (undefined (*) [16])FUN_0042bd10(0,"\tconst uint i = ",0x10);
        local_90 = *pauVar19;
        local_80 = *(undefined8 *)pauVar19[1];
        *(undefined4 *)(pauVar19[1] + 4) = 0xf;
        *(undefined4 *)pauVar19[1] = 0;
        (*pauVar19)[0] = 0;
        pauVar19 = (undefined (*) [16])FUN_00413010(&DAT_007352b4,3);
        puVar22 = *(undefined **)*pauVar19;
        local_24 = *pauVar19;
        uVar1 = *(undefined8 *)pauVar19[1];
        *(undefined4 *)pauVar19[1] = 0;
        *(undefined4 *)(pauVar19[1] + 4) = 0xf;
        (*pauVar19)[0] = 0;
        local_14._4_4_ = (uint)((ulonglong)uVar1 >> 0x20);
        local_14._0_4_ = (undefined4)uVar1;
        puVar25 = local_24;
        if (0xf < local_14._4_4_) {
          puVar25 = puVar22;
        }
        uVar23 = (undefined4)local_14;
        local_14 = uVar1;
        FUN_00413010(puVar25,uVar23);
        if (0xf < local_14._4_4_) {
          uVar27 = local_14._4_4_ + 1;
          iVar24 = local_24._0_4_;
          if (0xfff < uVar27) {
            iVar24 = *(int *)(local_24._0_4_ + -4);
            uVar27 = local_14._4_4_ + 0x24;
            if (0x1f < (local_24._0_4_ - iVar24) - 4U) goto LAB_00503a08;
          }
          FUN_005ab85c(iVar24,uVar27);
        }
        if (0xf < local_80._4_4_) {
          uVar27 = local_80._4_4_ + 1;
          iVar24 = local_90._0_4_;
          if (0xfff < uVar27) {
            iVar24 = *(int *)(local_90._0_4_ + -4);
            uVar27 = local_80._4_4_ + 0x24;
            if (0x1f < (local_90._0_4_ - iVar24) - 4U) goto LAB_00503a08;
          }
          FUN_005ab85c(iVar24,uVar27);
        }
        local_80 = 0xf00000000;
        auVar5[15] = 0;
        auVar5._0_15_ = local_90._1_15_;
        local_90 = auVar5 << 8;
        if (0xf < local_f8) {
          uVar27 = local_f8 + 1;
          iVar24 = local_10c._0_4_;
          if (0xfff < uVar27) {
            iVar24 = *(int *)(local_10c._0_4_ + -4);
            uVar27 = local_f8 + 0x24;
            if (0x1f < (local_10c._0_4_ - iVar24) - 4U) goto LAB_00503a08;
          }
          FUN_005ab85c(iVar24,uVar27);
        }
        if (iVar18 + -2 < 0) {
          iVar24 = FUN_00440eb0();
          *(undefined *)(iVar24 + -1) = 0x2d;
          puVar22 = (undefined *)(iVar24 + -1);
        }
        else {
          puVar22 = (undefined *)FUN_00440eb0();
        }
        local_114 = 0;
        local_110 = 0;
        local_124 = ZEXT816(0);
        if (puVar22 == local_187) {
          local_110 = 0xf;
          auVar6[15] = 0;
          auVar6._0_15_ = local_124._1_15_;
          local_124 = auVar6 << 8;
        }
        else {
          FUN_00414570(puVar22,local_187 + -(int)puVar22);
        }
        pauVar19 = (undefined (*) [16])FUN_0042bd10(0,"\tconst uint p1 = ",0x11);
        local_c4 = *pauVar19;
        local_b4 = *(undefined8 *)pauVar19[1];
        *(undefined4 *)(pauVar19[1] + 4) = 0xf;
        *(undefined4 *)pauVar19[1] = 0;
        (*pauVar19)[0] = 0;
        pauVar19 = (undefined (*) [16])FUN_00413010(&DAT_007352b4,3);
        puVar22 = *(undefined **)*pauVar19;
        local_24 = *pauVar19;
        uVar1 = *(undefined8 *)pauVar19[1];
        *(undefined4 *)pauVar19[1] = 0;
        *(undefined4 *)(pauVar19[1] + 4) = 0xf;
        (*pauVar19)[0] = 0;
        local_14._4_4_ = (uint)((ulonglong)uVar1 >> 0x20);
        local_14._0_4_ = (undefined4)uVar1;
        puVar25 = local_24;
        if (0xf < local_14._4_4_) {
          puVar25 = puVar22;
        }
        uVar23 = (undefined4)local_14;
        local_14 = uVar1;
        FUN_00413010(puVar25,uVar23);
        if (0xf < local_14._4_4_) {
          uVar27 = local_14._4_4_ + 1;
          iVar24 = local_24._0_4_;
          if (0xfff < uVar27) {
            iVar24 = *(int *)(local_24._0_4_ + -4);
            uVar27 = local_14._4_4_ + 0x24;
            if (0x1f < (local_24._0_4_ - iVar24) - 4U) goto LAB_00503a08;
          }
          FUN_005ab85c(iVar24,uVar27);
        }
        if (0xf < local_b4._4_4_) {
          uVar27 = local_b4._4_4_ + 1;
          iVar24 = local_c4._0_4_;
          if (0xfff < uVar27) {
            iVar24 = *(int *)(local_c4._0_4_ + -4);
            uVar27 = local_b4._4_4_ + 0x24;
            if (0x1f < (local_c4._0_4_ - iVar24) - 4U) goto LAB_00503a08;
          }
          FUN_005ab85c(iVar24,uVar27);
        }
        local_b4 = 0xf00000000;
        auVar7[15] = 0;
        auVar7._0_15_ = local_c4._1_15_;
        local_c4 = auVar7 << 8;
        if (0xf < local_110) {
          uVar27 = local_110 + 1;
          iVar24 = local_124._0_4_;
          if (0xfff < uVar27) {
            iVar24 = *(int *)(local_124._0_4_ + -4);
            uVar27 = local_110 + 0x24;
            if (0x1f < (local_124._0_4_ - iVar24) - 4U) goto LAB_00503a08;
          }
          FUN_005ab85c(iVar24,uVar27);
        }
        if (iVar18 + -1 < 0) {
          iVar24 = FUN_00440eb0();
          *(undefined *)(iVar24 + -1) = 0x2d;
          puVar22 = (undefined *)(iVar24 + -1);
        }
        else {
          puVar22 = (undefined *)FUN_00440eb0();
        }
        local_12c = 0;
        local_128 = 0;
        local_13c = ZEXT816(0);
        if (puVar22 == local_19f) {
          local_128 = 0xf;
          auVar8[15] = 0;
          auVar8._0_15_ = local_13c._1_15_;
          local_13c = auVar8 << 8;
        }
        else {
          FUN_00414570(puVar22,local_19f + -(int)puVar22);
        }
        pauVar19 = (undefined (*) [16])FUN_0042bd10(0,"\tconst uint p2 = ",0x11);
        local_dc = *pauVar19;
        local_cc = *(undefined8 *)pauVar19[1];
        *(undefined4 *)(pauVar19[1] + 4) = 0xf;
        *(undefined4 *)pauVar19[1] = 0;
        (*pauVar19)[0] = 0;
        pauVar19 = (undefined (*) [16])FUN_00413010(&DAT_007352b4,3);
        puVar22 = *(undefined **)*pauVar19;
        local_24 = *pauVar19;
        uVar1 = *(undefined8 *)pauVar19[1];
        *(undefined4 *)pauVar19[1] = 0;
        *(undefined4 *)(pauVar19[1] + 4) = 0xf;
        (*pauVar19)[0] = 0;
        local_14._4_4_ = (uint)((ulonglong)uVar1 >> 0x20);
        local_14._0_4_ = (undefined4)uVar1;
        puVar25 = local_24;
        if (0xf < local_14._4_4_) {
          puVar25 = puVar22;
        }
        uVar23 = (undefined4)local_14;
        local_14 = uVar1;
        FUN_00413010(puVar25,uVar23);
        if (0xf < local_14._4_4_) {
          uVar27 = local_14._4_4_ + 1;
          iVar24 = local_24._0_4_;
          if (0xfff < uVar27) {
            iVar24 = *(int *)(local_24._0_4_ + -4);
            uVar27 = local_14._4_4_ + 0x24;
            if (0x1f < (local_24._0_4_ - iVar24) - 4U) goto LAB_00503a08;
          }
          FUN_005ab85c(iVar24,uVar27);
        }
        if (0xf < local_cc._4_4_) {
          uVar27 = local_cc._4_4_ + 1;
          iVar24 = local_dc._0_4_;
          if (0xfff < uVar27) {
            iVar24 = *(int *)(local_dc._0_4_ + -4);
            uVar27 = local_cc._4_4_ + 0x24;
            if (0x1f < (local_dc._0_4_ - iVar24) - 4U) goto LAB_00503a08;
          }
          FUN_005ab85c(iVar24,uVar27);
        }
        local_cc = 0xf00000000;
        auVar9[15] = 0;
        auVar9._0_15_ = local_dc._1_15_;
        local_dc = auVar9 << 8;
        if (0xf < local_128) {
          uVar27 = local_128 + 1;
          iVar24 = local_13c._0_4_;
          if (0xfff < uVar27) {
            iVar24 = *(int *)(local_13c._0_4_ + -4);
            uVar27 = local_128 + 0x24;
            if (0x1f < (local_13c._0_4_ - iVar24) - 4U) goto LAB_00503a08;
          }
          FUN_005ab85c(iVar24,uVar27);
        }
        if (iVar18 < 0) {
          iVar24 = FUN_00440eb0();
          *(undefined *)(iVar24 + -1) = 0x2d;
          puVar22 = (undefined *)(iVar24 + -1);
        }
        else {
          puVar22 = (undefined *)FUN_00440eb0();
        }
        local_4c = 0;
        local_48 = 0;
        local_5c = ZEXT816(0);
        if (puVar22 == local_1b7) {
          local_48 = 0xf;
          auVar10[15] = 0;
          auVar10._0_15_ = local_5c._1_15_;
          local_5c = auVar10 << 8;
        }
        else {
          FUN_00414570(puVar22,local_1b7 + -(int)puVar22);
        }
        pauVar19 = (undefined (*) [16])FUN_0042bd10(0,"\tconst uint p3 = ",0x11);
        local_f4 = *pauVar19;
        local_e4 = *(undefined8 *)pauVar19[1];
        *(undefined4 *)(pauVar19[1] + 4) = 0xf;
        *(undefined4 *)pauVar19[1] = 0;
        (*pauVar19)[0] = 0;
        pauVar19 = (undefined (*) [16])FUN_00413010(&DAT_007352b4,3);
        puVar22 = *(undefined **)*pauVar19;
        local_24 = *pauVar19;
        uVar1 = *(undefined8 *)pauVar19[1];
        *(undefined4 *)pauVar19[1] = 0;
        *(undefined4 *)(pauVar19[1] + 4) = 0xf;
        (*pauVar19)[0] = 0;
        local_14._4_4_ = (uint)((ulonglong)uVar1 >> 0x20);
        local_14._0_4_ = (undefined4)uVar1;
        puVar25 = local_24;
        if (0xf < local_14._4_4_) {
          puVar25 = puVar22;
        }
        uVar23 = (undefined4)local_14;
        local_14 = uVar1;
        FUN_00413010(puVar25,uVar23);
        if (0xf < local_14._4_4_) {
          uVar27 = local_14._4_4_ + 1;
          iVar24 = local_24._0_4_;
          if (0xfff < uVar27) {
            iVar24 = *(int *)(local_24._0_4_ + -4);
            uVar27 = local_14._4_4_ + 0x24;
            if (0x1f < (local_24._0_4_ - iVar24) - 4U) goto LAB_00503a08;
          }
          FUN_005ab85c(iVar24,uVar27);
        }
        if (0xf < local_e4._4_4_) {
          uVar27 = local_e4._4_4_ + 1;
          iVar24 = local_f4._0_4_;
          if (0xfff < uVar27) {
            iVar24 = *(int *)(local_f4._0_4_ + -4);
            uVar27 = local_e4._4_4_ + 0x24;
            if (0x1f < (local_f4._0_4_ - iVar24) - 4U) goto LAB_00503a08;
          }
          FUN_005ab85c(iVar24,uVar27);
        }
        local_e4 = 0xf00000000;
        auVar11[15] = 0;
        auVar11._0_15_ = local_f4._1_15_;
        local_f4 = auVar11 << 8;
        if (0xf < local_48) {
          uVar27 = local_48 + 1;
          iVar24 = local_5c._0_4_;
          if (0xfff < uVar27) {
            iVar24 = *(int *)(local_5c._0_4_ + -4);
            uVar27 = local_48 + 0x24;
            if (0x1f < (local_5c._0_4_ - iVar24) - 4U) goto LAB_00503a08;
          }
          FUN_005ab85c(iVar24,uVar27);
        }
        FUN_00413010("\tvec4 projectedCoords1 = CalculateProjectedCoordsCascades(worldPos, g_LFeatur e_ShadowProjection[p1]);\n"
                     ,0x66);
        FUN_00413010("\tvec4 projectedCoords2 = CalculateProjectedCoordsCascades(worldPos, g_LFeatur e_ShadowProjection[p2]);\n"
                     ,0x66);
        FUN_00413010("\tvec4 projectedCoords3 = CalculateProjectedCoordsCascades(worldPos, g_LFeatur e_ShadowProjection[p3]);\n"
                     ,0x66);
        FUN_00413010("\tprojectedCoords1.xyz = mix(projectedCoords1.xyz, projectedCoords2.xyz, proje ctedCoords1.w);\n"
                     ,0x5d);
        FUN_00413010("\tprojectedCoords1.xyz = mix(projectedCoords1.xyz, projectedCoords3.xyz, proje ctedCoords2.w);\n"
                     ,0x5d);
        FUN_00413010("\tvec4 uvTransforms = mix(g_LFeature_ShadowProjectionTransform[p1], g_LFeature _ShadowProjectionTransform[p2], projectedCoords1.w);\n"
                     ,0x82);
        FUN_00413010("\tuvTransforms = mix(uvTransforms, g_LFeature_ShadowProjectionTransform[p3], p rojectedCoords2.w);\n"
                     ,0x61);
        FUN_00413010("\tfloat shadowFactor = max(projectedCoords3.w, PerformShadowMapping(projectedC oords1.xyz, uvTransforms));\n"
                     ,0x69);
        FUN_00413010("\tlight += ComputePBRLightShadowInfinite(normal, g_LDirectional_Direction[i].x yz, viewVector, color, g_LDirectional_Color[i].rgb, specularTint, ambient, roughness, metall ic, shadowFactor);\n"
                     ,0xbc);
        FUN_00413010(&DAT_00732104,2);
        uVar20 = uVar20 + 1;
        iVar18 = iVar18 + 1;
        uVar27 = local_9c;
      } while (uVar20 < local_28);
    }
    for (; uVar14 = local_9c, uVar20 < local_9c; uVar20 = uVar20 + 1) {
      local_9c = uVar27;
                    /* WARNING: Read-only address (ram,0x00732088) is written */
      FUN_00413010(&DAT_007351e8,2);
      if ((int)uVar20 < 0) {
        iVar18 = FUN_00440eb0();
        *(undefined *)(iVar18 + -1) = 0x2d;
        puVar22 = (undefined *)(iVar18 + -1);
      }
      else {
        puVar22 = (undefined *)FUN_00440eb0();
      }
      local_30 = 0;
      local_2c = 0;
      _local_40 = ZEXT816(0);
      if (puVar22 == local_1cf) {
        local_2c = 0xf;
        auVar12[15] = 0;
        auVar12._0_15_ = stack0xffffffc1;
        _local_40 = auVar12 << 8;
      }
      else {
        FUN_00414570(puVar22,local_1cf + -(int)puVar22);
      }
      pauVar19 = (undefined (*) [16])FUN_0042bd10(0,"\tconst uint i = ",0x10);
      _local_74 = *pauVar19;
      local_64 = *(undefined8 *)pauVar19[1];
      *(undefined4 *)(pauVar19[1] + 4) = 0xf;
      *(undefined4 *)pauVar19[1] = 0;
      (*pauVar19)[0] = 0;
      pauVar19 = (undefined (*) [16])FUN_00413010(&DAT_007352b4,3);
      puVar22 = *(undefined **)*pauVar19;
      local_24 = *pauVar19;
      uVar1 = *(undefined8 *)pauVar19[1];
      *(undefined4 *)pauVar19[1] = 0;
      *(undefined4 *)(pauVar19[1] + 4) = 0xf;
      (*pauVar19)[0] = 0;
      local_14._4_4_ = (uint)((ulonglong)uVar1 >> 0x20);
      local_14._0_4_ = (undefined4)uVar1;
      puVar25 = local_24;
      if (0xf < local_14._4_4_) {
        puVar25 = puVar22;
      }
      uVar23 = (undefined4)local_14;
      local_14 = uVar1;
      FUN_00413010(puVar25,uVar23);
      if (0xf < local_14._4_4_) {
        uVar27 = local_14._4_4_ + 1;
        iVar18 = local_24._0_4_;
        if (0xfff < uVar27) {
          iVar18 = *(int *)(local_24._0_4_ + -4);
          uVar27 = local_14._4_4_ + 0x24;
          if (0x1f < (local_24._0_4_ - iVar18) - 4U) {
LAB_00503a08:
                    /* WARNING: Subroutine does not return */
            FUN_005c695f();
          }
        }
        FUN_005ab85c(iVar18,uVar27);
      }
      if (0xf < local_64._4_4_) {
        uVar27 = local_64._4_4_ + 1;
        iVar18 = local_74._0_4_;
        if (0xfff < uVar27) {
          iVar18 = *(int *)(local_74._0_4_ + -4);
          uVar27 = local_64._4_4_ + 0x24;
          if (0x1f < (local_74._0_4_ - iVar18) - 4U) goto LAB_00503a08;
        }
        FUN_005ab85c(iVar18,uVar27);
      }
      local_64 = 0xf00000000;
      auVar13[15] = 0;
      auVar13._0_15_ = stack0xffffff8d;
      _local_74 = auVar13 << 8;
      if (0xf < local_2c) {
        uVar27 = local_2c + 1;
        iVar18 = (int)local_40;
        if (0xfff < uVar27) {
          iVar18 = *(int *)((int)local_40 + -4);
          uVar27 = local_2c + 0x24;
          if (0x1f < ((int)local_40 - iVar18) - 4U) goto LAB_00503a08;
        }
        FUN_005ab85c(iVar18,uVar27);
      }
      FUN_00413010("\tlight += ComputePBRLightShadowInfinite(normal, g_LDirectional_Direction[i].xyz , viewVector, color, g_LDirectional_Color[i].rgb, specularTint, ambient, roughness, metallic, 1.0);\n"
                   ,0xb3);
      FUN_00413010(&DAT_00732104,2);
      uVar27 = local_9c;
      local_9c = uVar14;
    }
    local_9c = uVar27;
                    /* WARNING: Read-only address (ram,0x00732088) is written */
    FUN_00413010("\treturn light;\n}\n",0x11);
  }
  return;
}

This lighting system also looks to be using something similar to sample2DShadow or samplerCubeArrayShadow, which might require some changes to FBO and other things...

#define DECLARE_SAMPLER2D_PARAMETER(t) Texture2D t, SamplerState t ## SamplerState
#define MAKE_SAMPLER2D_ARGUMENT(t) t, t ## SamplerState
#define DECLARE_SAMPLER2D_COMPARE_PARAMETER(t) Texture2D t, SamplerComparisonState t ## SamplerComparisonState
#define MAKE_SAMPLER2D_COMPARE_ARGUMENT(t) t, t ## SamplerComparisonState
#define texSample2D(s, u) s.Sample(s ## SamplerState, u)
#define texSample2DLod(s, u, m) s.SampleLevel(s  ## SamplerState, u, m)
#define texSample2DCompare(s, u, d) s.SampleCmpLevelZero(s ## SamplerComparisonState, u, d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant