Code Monkey home page Code Monkey logo

xatlas's Introduction

xatlas

Appveyor CI Build Status Travis CI Build Status License: MIT

A cleaned up version of thekla_atlas.

Mesh charting, parameterization and atlas packing. Suitable for generating unique texture coordinates for baking lightmaps.

Screenshots

Example - Cesium Milk Truck

Viewer Random packing Brute force packing
Viewer Random packing Brute force packing

Example - Godot Third Person Shooter demo

Godot TPS

Graphite/Geogram

Graphite/Geogram

Changes from thekla_atlas

  • Smaller code size - from about 18 KLOC to 10 KLOC
  • Easier to integrate and build - a single source/header file pair instead of around 120 files and 10 directories.
  • Atlas resolution option for outputting multiple atlases.
  • Flexible data description API for input meshes.
  • Better tolerance of bad input geometry. Zero length edges and zero area faces are ignored.
  • Support for packing multiple atlases/parameterizations into a single atlas.

How to use

Generate an atlas (simple API)

  1. Create an empty atlas with xatlas::Create.
  2. Add one or more meshes with xatlas::AddMesh.
  3. Call xatlas::Generate. Meshes are segmented into charts, which are parameterized and packed into an atlas.

The xatlas::Atlas instance created in the first step now contains the result: each input mesh added by xatlas::AddMesh has a corresponding new mesh with a UV channel. New meshes have more vertices (the UV channel adds seams), but the same number of indices.

Cleanup with xatlas::Destroy.

Example code here.

Generate an atlas (tools/editor integration API)

Instead of calling xatlas::Generate, the following functions can be called in sequence:

  1. xatlas::ComputeCharts: meshes are segmented into charts.
  2. xatlas::ParameterizeCharts: charts are flattened into 2D parameterizations.
  3. xatlas::PackCharts: charts are packed into one or more atlases.

All of these functions take a progress callback. Return false to cancel.

You can call any of these functions multiple times, followed by the proceeding functions, to re-generate the atlas. E.g. calling xatlas::PackCharts multiple times to tweak options like unit to texel scale and resolution.

See the viewer for example code.

Pack multiple atlases into a single atlas

  1. Create an empty atlas with xatlas::Create.
  2. Add one or more meshes with xatlas::AddUvMesh.
  3. Call xatlas::PackCharts.

Example code here.

TODO

  • Segmentation: improve chart merging by using similar metrics to chart growing
  • Segmentation/Parameterization: detect geometry with zero Gaussian curvature (e.g. a cylinder) and unwrap as a single chart
  • Viewer: better lightmap baking
  • Viewer: chart picking in scene and texture views

Technical information / related publications

Ignacio Castaño's blog post on thekla_atlas

P. Sander, J. Snyder, S. Gortler, and H. Hoppe. Texture Mapping Progressive Meshes

K. Hormann, B. Lévy, and A. Sheffer. Mesh Parameterization: Theory and Practice

P. Sander, Z. Wood, S. Gortler, J. Snyder, and H. Hoppe. Multi-Chart Geometry Images

D. Julius, V. Kraevoy, and A. Sheffer. D-Charts: Quasi-Developable Mesh Segmentation

B. Lévy, S. Petitjean, N. Ray, and J. Maillot. Least Squares Conformal Maps for Automatic Texture Atlas Generation

O. Sorkine, D. Cohen-Or, R. Goldenthal, and D. Lischinski. Bounded-distortion Piecewise Mesh Parameterization

Y. O’Donnell. Precomputed Global Illumination in Frostbite

Used by

Bakery - GPU Lightmapper

Godot Engine

Graphite/Geogram

Filament

Lightmaps - An OpenGL sample demonstrating path traced lightmap baking on the CPU with Embree

toy / two

Wicked Engine

Related projects

Microsoft's UVAtlas - isochart texture atlasing.

simpleuv - Automatic UV Unwrapping Library for Dust3D.

Ministry of Flat - Commercial automated UV unwrapper.

Lightmapper - Hemicube based lightmap baking. The example model texture coordinates were generated by thekla_atlas.

aobaker - Ambient occlusion baking. Uses thekla_atlas.

seamoptimizer - A C/C++ single-file library that minimizes the hard transition errors of disjoint edges in lightmaps.

Models used

Gazebo model by Teh_Bucket

xatlas's People

Contributors

joshmeierenscape avatar jpcy avatar madrazo avatar prideout avatar stephanbergmannenscape avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.