Skip to content

Preserve imported geometry normals when using Vertex Color lighting#1197

Open
Copilot wants to merge 3 commits into
developfrom
copilot/fix-normals-on-imported-geometry
Open

Preserve imported geometry normals when using Vertex Color lighting#1197
Copilot wants to merge 3 commits into
developfrom
copilot/fix-normals-on-imported-geometry

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 19, 2026

Imported geometry could lose its intended shading when Lighting Mode = Vertex Color: shared-color meshes collapsed sharp edges into fully smooth normals, while face-corner-colored meshes preserved every split and broke smooth surfaces. The problem was not in import itself, but in the later vertex merge step that rebuilt room/compiler geometry.

  • Root cause

    • Imported geometry vertices were being merged too aggressively after import.
    • The merge key ignored imported normals, and in the classic path it also relied on an unused Color field instead of the actual packed lighting data.
  • What changed

    • Classic room rebuild path
      • Preserve transformed imported normals on tr_room_vertex.
      • Make imported-geometry deduplication compare:
        • position
        • packed lighting fields
        • attributes
        • transformed normal
    • Classic compiler path
      • Apply the same normal-preserving merge criteria during compiled room generation.
    • TombEngine compiler path
      • Include transformed normals in imported-geometry vertex merging, alongside position/color/double-sided state.
  • Effect on shading

    • Vertices only merge when both lighting data and normals match.
    • Split normals remain split across sharp edges.
    • Shared normals remain shared across curved surfaces.
    • Existing SharpEdges behavior stays unchanged.
  • Representative change

    existingIndex = roomVertices.IndexOf(v =>
        v.Position == trVertex.Position &&
        v.Lighting1 == trVertex.Lighting1 &&
        v.Attributes == trVertex.Attributes &&
        v.Lighting2 == trVertex.Lighting2 &&
        v.Normal == trVertex.Normal);
  • Scope

    • Limited to imported-geometry vertex merge logic in the editor/runtime compile paths.
    • No changes to importer formats, lighting mode UI, or shader behavior.

Copilot AI changed the title [WIP] Fix normals breaking on imported geometry with vertex color lighting mode Preserve imported geometry normals when using Vertex Color lighting Apr 19, 2026
Copilot AI requested a review from Nickelony April 19, 2026 21:01
@Nickelony Nickelony requested a review from Lwmte April 19, 2026 21:07
@Nickelony Nickelony added bug Something isn't working as intended. ready for review The Pull Request is finished and ready for review. labels Apr 19, 2026
@Nickelony Nickelony marked this pull request as ready for review April 19, 2026 21:31
@Nickelony Nickelony added this to the Version 2.1 milestone Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as intended. ready for review The Pull Request is finished and ready for review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TE: Normals on Imported Geometry break when the Lighting Mode is set to "Vertex Color"

2 participants