Skip to content

This is the official implementation of CT2Hair High-fidelity 3D Hair Modeling Using Computed Tomography.

License

Notifications You must be signed in to change notification settings

facebookresearch/CT2Hair

Repository files navigation

CT2Hair: High-Fidelity 3D Hair Modeling using Computed Tomography

Yuefan Shen · Shunsuke Saito · Ziyan Wang · Olivier Maury
Chenglei Wu · Jessica Hodgins · Youyi Zheng · Giljoo Nam

ACM SIGGRAPH 2023 (ACM Transactions on Graphics)


Paper PDF YouTube Video Project Page


This repository contains the code and data that are associated with the paper "CT2Hair: High-Fidelity 3D Hair Modeling using Computed Tomography". CT2Hair is a fully automatic framework for creating high-fidelity 3D hair models that are suitable for use in downstream graphics applications. Our approach utilizes real-world hair wigs as input and is able to reconstruct hair strands for a wide range of hairstyles. Our method leverages computed tomography (CT) to create density volumes of the hair regions, allowing us to see through the hair, unlike image-based approaches which are limited to reconstructing the visible surface.

Data

CT scan data (7.2GB) | 3D hair models (248MB)

Here is an overview image of our dataset. We have 10 samples with different hairstyles.

The CT scan data contains the following files: template head models, scalp points and vbd volumes for 10 samples. The data folder has the following structure.

data
├── HeadModels
│   ├── MannequinHeadA/
│   └── MannequinHeadB/
└── ScalpPoints
│   ├── scalp_xxx_pts.ply
│   └── ...
└── VDBs
    └── Clipped
        ├── xxx_clipped.vdb
        └── ...

The 3D hair models have 10 .bin files. The data structure of .bin files can be seen here. You can also open the .bin files with our visualizer.

Requirements

  • Hardware: NVIDIA GPU (24G memory or larger), 64G RAM or larger.
  • Environments: Ubuntu 22.04 (> 20.04) or Windows 10/11, CUDA 11.5 (> 11.0), Python 3.10, PyTorch 1.11 (>1.10).

Compilation (C++ & CUDA)

Linux

Install dependencies. Take Ubuntu as an example.

# Dependencies
apt install libeigen3-dev
apt install libpcl-dev
apt install libflann-dev

For the OpenVDB library, we recommend building it from the source code to avoid some known issues. Please refer to their GitHub repo.

cd CT2Hair/GuideHairStrands

# Please add your OpenVDB and CUDA path in CMakeLists.txt.
------------------------------------
7 set(CUDAPATH $CUDA_path)
8 set(OPENVDBPATH $OpenVDB_lib_path)
------------------------------------

mkdir build && cd build
cmake ..
make -j

Windows

We strongly recommend using vcpkg to manage most of your third-party libraries on Windows. Please install vcpkg first, and go to the vcpkg folder to install the following dependencies.

# Dependencies
vcpkg.exe install eigen3:x64-windows
vcpkg.exe install pcl:x64-windows
vcpkg.exe install flann:x64-windows

For the OpenVDB library, we recommend building it from the source code to avoid some known issues. Please refer to their GitHub repo.

cd CT2Hair/GuideHairStrands

# Please add your OpenVDB and CUDA path in CMakeLists.txt.
-------------------------------------
20 set(CUDAPATH $CUDA_path)
21 set(VCPKGPATH $VCPKG_path)
22 set(OPENVDBPATH $OpenVDB_lib_path)
-------------------------------------

mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=$VCPKG_path\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_POLICY_DEFAULT_CMP0091=NEW
cmake --build . --config release
cmake --install .

Note that you have to make sure you already install CUDA and its corresponding Visual Studio extension correctly. If you have multiple versions of Visual Studio, please choose the one that has the corresponding extension with your installed CUDA. For example, if you are using CUDA 11.5 and Visual Studio 2019 (VS 2022 requires CUDA 11.6 at least), please add -G "Visual Studio 16 2019" to your first cmake command.

Running

Our code contains the entire pipeline of reconstructing strands from the input density volume. We have four scripts for four corresponding steps in our pipeline. We have set config files for each sample in conf/data/.

Setup

# Create and activate a virtual environment
conda env create --file CT2Hair/environment.yml
conda activate ct2hair

Commands

# Estimate 3D orientations
python scripts/est_orientations.py --conf $configure_file --datapath $path_to_data
# This will generate a point cloud with color encoding the estimated orientations, named as "*_oriens_*.ply".

# Generate guide hair strands
python scripts/gen_guide_strands.py --conf $configure_file --datapath $path_to_data
# This will generate guide hair strands file named as "*_guide.bin*.

# Interpolate empty regions
python scripts/interpolation.py --conf $configure_file --datapath $path_to_data
# This will generate hair strands file after interpolation named as "*_merged.bin".

# Optimize hair strands to fit the CT volume
python scripts/optimization.py --conf $configure_file --datapath $path_to_data
# This will generate hair strands file after optimization named as "*_opted.bin". This step usually takes hours for each case.

Visualization

We can use a simple visualization tool for hair strands. Users can directly use the interface to load our generated hair strands files (*.bin or .data files). Please refer to HairStrandsRendering for more details.

For volume visualization (.vdb), we suggest using Houdini or Blender. Here is a tutorial example for importing and shading .vdb files in Blender.

License

Creative Commons Attribution-NonCommercial (CC BY-NC) 4.0.

BibTeX

@article{shen2023CT2Hair,
  title={CT2Hair: High-Fidelity 3D Hair Modeling using Computed Tomography},
  author={Shen, Yuefan and Saito, Shunsuke and Wang, Ziyan and Maury, Olivier and Wu, Chenglei and Hodgins, Jessica and Zheng, Youyi and Nam, Giljoo},
  journal={ACM Transactions on Graphics},
  volume={42},
  number={4},
  articleno={75},
  pages={1--13},
  year={2023},
  publisher={ACM New York, NY, USA}
}

About

This is the official implementation of CT2Hair High-fidelity 3D Hair Modeling Using Computed Tomography.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published