Skip to content

Add mesh texture mapping#4202

Open
ahojnnes wants to merge 15 commits intomainfrom
user/jsch/mesh-texture-mapping
Open

Add mesh texture mapping#4202
ahojnnes wants to merge 15 commits intomainfrom
user/jsch/mesh-texture-mapping

Conversation

@ahojnnes
Copy link
Contributor

@ahojnnes ahojnnes commented Mar 5, 2026

Based on Waechter, Michael and Moehrle, Nils and Goesele, Michael. "Let there be color! Large-scale texturing of 3D reconstructions." European Conference on Computer Vision, 2014.

Current vertex-based coloring with 16M faces:
mesh-textured

New texture-based coloring with 0.4M faces:
Screenshot 2026-03-11 at 16 09 04

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request adds a new feature to COLMAP for mapping textures onto 3D mesh models using multiple images. It includes a new command-line tool, options for customization, and integrates with existing COLMAP components. The changes enhance the visual quality of reconstructed 3D models by applying realistic textures derived from the input images.

Highlights

  • Mesh Texture Mapping: This PR introduces mesh texture mapping functionality to COLMAP, allowing users to apply textures to 3D mesh models using calibrated multi-view images.
  • New Executable Command: A new mesh_texture_mapper command is added to the COLMAP executable, providing a command-line interface for performing mesh texture mapping.
  • Option Manager Integration: The PR integrates mesh texture mapping options into the OptionManager, allowing users to configure various parameters such as minimum normal angle, visible vertices, and smoothing iterations.
  • CGAL Dependency: The implementation uses CGAL for occlusion testing, which improves the quality of texture mapping by avoiding occluded regions. A warning message is displayed when CGAL is disabled.
Changelog
  • src/colmap/controllers/option_manager.cc
    • Added include for texture_mapping.h
    • Added mesh texture mapping options
    • Added a method to add mesh texture mapping options
    • Reset mesh texture mapping options
    • Reset mesh texture mapping options struct
    • Added a check for mesh texture mapping options
  • src/colmap/controllers/option_manager.h
    • Added MeshTextureMappingOptions struct
    • Added a method to add mesh texture mapping options
    • Added mesh texture mapping options as a shared pointer
    • Added a boolean to check if mesh texture mapping options were added
  • src/colmap/exe/colmap.cc
    • Added mesh_texture_mapper command
  • src/colmap/exe/mvs.cc
    • Added include for model.h and texture_mapping.h
    • Added RunMeshTextureMapper function
  • src/colmap/exe/mvs.h
    • Added RunMeshTextureMapper declaration
  • src/colmap/mvs/CMakeLists.txt
    • Added texture_mapping.h and texture_mapping.cc
    • Added texture_mapping_test.cc
  • src/colmap/mvs/texture_mapping.cc
    • Added new file for mesh texture mapping implementation
  • src/colmap/mvs/texture_mapping.h
    • Added new file for mesh texture mapping header
  • src/colmap/mvs/texture_mapping_test.cc
    • Added new file for mesh texture mapping tests
  • src/colmap/util/ply.cc
    • Added include for string.h
    • Added ReadTexturedPlyMesh function
    • Added WriteTextTexturedPlyMesh function
    • Added WriteBinaryTexturedPlyMesh function
  • src/colmap/util/ply.h
    • Added include for string
    • Added PlyTexturedMesh struct
    • Added ReadTexturedPlyMesh declaration
    • Added WriteTextTexturedPlyMesh declaration
    • Added WriteBinaryTexturedPlyMesh declaration
  • src/colmap/util/ply_test.cc
    • Added CreateTestTexturedMesh function
    • Added VerifyTexturedMesh function
    • Added RoundTripTextTexturedPlyMesh test
    • Added RoundTripBinaryTexturedPlyMesh test
    • Added ReadTexturedPlyMeshWithoutTexcoords test
Activity
  • The pull request introduces a new feature for mesh texture mapping.
  • The implementation includes view selection, atlas packing, texture baking, and color correction.
  • The code leverages CGAL for occlusion testing to improve texture quality.
  • The changes include modifications to option management, command-line execution, and PLY file I/O.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive mesh texture mapping pipeline, including view selection for each mesh face, texture atlas packing, texture baking from source images, and an optional global color correction step to reduce seams. A critical security concern has been identified: a potential Denial of Service (DoS) vulnerability in the atlas packing logic due to integer overflows in atlas dimensions calculation, which could lead to an infinite loop. This requires immediate attention, ideally by using larger integer types and implementing dimension limits. Furthermore, the review highlights areas for improvement such as potential rendering artifacts from a loose threshold in texture baking, an unimplemented Poisson blending option, and a performance suggestion for the linear solver in color correction.

@ahojnnes ahojnnes marked this pull request as ready for review March 11, 2026 15:29
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

Successfully merging this pull request may close these issues.

1 participant