Skip to content

Added support for vertex colors#88

Merged
HeDo88TH merged 2 commits intomasterfrom
add-vertex-colors-and-srgb
Feb 12, 2026
Merged

Added support for vertex colors#88
HeDo88TH merged 2 commits intomasterfrom
add-vertex-colors-and-srgb

Conversation

@HeDo88TH
Copy link
Copy Markdown
Collaborator

Add support for OBJ files with per-vertex colors (extended vertex format: v x y z r g b).

Vertex colors are:

  • Parsed from OBJ files by all three internal parsers (splitting, decimation, and glTF conversion stages)
  • Preserved through mesh splitting (with correct interpolation at edge intersections) and LOD decimation
  • Exported to glTF/GLB as COLOR_0 attribute with automatic sRGB → linear RGB conversion per the glTF specification

Closes #43

@HeDo88TH HeDo88TH self-assigned this Feb 11, 2026
Copilot AI review requested due to automatic review settings February 11, 2026 17:26
@HeDo88TH HeDo88TH added the enhancement New feature or request label Feb 11, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds end-to-end support for per-vertex colors in extended OBJ vertex lines (v x y z r g b) across the Obj2Tiles pipeline (splitting, decimation, and OBJ→glTF conversion), preserving/interpolating colors during splitting and exporting them as COLOR_0 in glTF (with sRGB→linear conversion).

Changes:

  • Parse and carry optional vertex colors through Obj2Tiles.Library meshes (Mesh/MeshT) including split-time interpolation and OBJ write-back.
  • Extend decimation-stage OBJ parsing/writing (ObjMesh) and pass colors through MeshDecimatorCore.
  • Extend Obj2Gltf OBJ parser + glTF writer to emit COLOR_0 and write a dedicated colors buffer; add NUnit coverage for library-layer behavior.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
README.md Documents vertex color support and cleans up formatting.
Obj2Tiles/Stages/Model/ObjMesh.cs Adds vertex color parsing/storage + OBJ writing for the decimation-stage parser.
Obj2Tiles/Stages/DecimationStage.cs Passes colors into/out of MeshDecimatorCore during LOD decimation.
Obj2Tiles.Library/Materials/RGB.cs Adds RGB interpolation + sRGB→linear helper + equality members.
Obj2Tiles.Library/Geometry/MeshUtils.cs Parses per-vertex RGB from OBJ and plumbs into Mesh/MeshT.
Obj2Tiles.Library/Geometry/Mesh.cs Stores optional vertex colors; preserves + interpolates through splitting; writes colors in OBJ output.
Obj2Tiles.Library/Geometry/MeshT.cs Same as Mesh but for textured meshes; updates split + OBJ writing + unused-vertex removal.
Obj2Tiles.Library.Test/VertexColorTests.cs Adds tests for parsing/splitting/interpolation/round-trip OBJ writing with colors.
Obj2Tiles.Library.Test/TestData/triangle-colors.obj New colored OBJ fixture.
Obj2Tiles.Library.Test/TestData/cube-colors.obj New colored OBJ fixture.
Obj2Tiles.Library.Test/TestData/cube-colors-textured/* New textured + colored OBJ/MTL (and texture) fixtures.
Obj2Tiles.Library.Test/Obj2Tiles.Library.Test.csproj Copies new test data to output.
Obj2Gltf/WaveFront/ObjParser.cs Parses extended vertex color tokens into ObjModel.Colors.
Obj2Gltf/WaveFront/ObjModel.cs Adds storage for per-vertex colors.
Obj2Gltf/Converter.cs Emits COLOR_0 and converts sRGB→linear when writing vertex data.
Obj2Gltf/BufferState.cs Adds color buffer/accessor plumbing for glTF output.
.github/copilot-instructions.md Updates project guidance to mention vertex color support and flow.

Comment thread Obj2Tiles/Stages/Model/ObjMesh.cs
Comment thread Obj2Tiles/Stages/Model/ObjMesh.cs Outdated
Comment thread Obj2Tiles/Stages/Model/ObjMesh.cs
@HeDo88TH HeDo88TH merged commit de6ac53 into master Feb 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep colors on obj objects with vertex colors ?

2 participants