Top Related Projects
Quick Overview
OpenSubdiv is an open-source library developed by Pixar Animation Studios for high-performance subdivision surface evaluation on massively parallel CPU and GPU architectures. It provides a set of interoperable APIs and tools that implement subdivision surfaces for film and game industry application developers.
Pros
- High-performance subdivision surface evaluation on both CPU and GPU
- Interoperable APIs for easy integration into existing pipelines
- Supports various subdivision schemes (Catmull-Clark, Loop, Bilinear)
- Backed by Pixar Animation Studios, ensuring industry-standard quality
Cons
- Steep learning curve for beginners due to complex mathematical concepts
- Limited documentation for advanced use cases
- Requires understanding of parallel computing for optimal performance
- May be overkill for simple 3D projects or small-scale applications
Code Examples
- Creating a simple mesh:
#include <opensubdiv/far/topologyDescriptor.h>
#include <opensubdiv/far/primvarRefiner.h>
OpenSubdiv::Far::TopologyDescriptor desc;
desc.numVertices = 4;
desc.numFaces = 1;
int vertsPerFace[] = {4};
int faceIndices[] = {0, 1, 2, 3};
desc.numVertsPerFace = vertsPerFace;
desc.vertIndicesPerFace = faceIndices;
OpenSubdiv::Far::TopologyRefiner * refiner =
OpenSubdiv::Far::TopologyRefinerFactory<OpenSubdiv::Far::TopologyDescriptor>::Create(desc);
- Applying subdivision:
int maxLevel = 3;
refiner->RefineUniform(maxLevel);
std::vector<float> vertexBuffer;
OpenSubdiv::Far::PrimvarRefiner primvarRefiner(*refiner);
primvarRefiner.Interpolate(vertexBuffer, coarseVertices);
- Evaluating limit surface:
OpenSubdiv::Far::PatchTable const * patchTable =
OpenSubdiv::Far::PatchTableFactory::Create(*refiner);
OpenSubdiv::Far::PatchMap patchMap(*patchTable);
float u = 0.5f, v = 0.5f;
int face = 0;
OpenSubdiv::Far::PatchTable::PatchHandle const * handle = patchMap.FindPatch(face, u, v);
float limitPoint[3];
patchTable->EvaluateLimit(handle, u, v, vertexBuffer.data(), limitPoint);
Getting Started
-
Clone the repository:
git clone https://github.com/PixarAnimationStudios/OpenSubdiv.git
-
Build the library:
cd OpenSubdiv mkdir build cd build cmake .. make
-
Include the necessary headers in your project and link against the built libraries.
-
Start using OpenSubdiv in your code by creating topology descriptors, refining meshes, and evaluating subdivision surfaces as shown in the code examples above.
Competitor Comparisons
Mitsuba 2: A Retargetable Forward and Inverse Renderer
Pros of Mitsuba2
- More versatile rendering capabilities, including spectral rendering and advanced light transport algorithms
- Supports Python bindings, allowing for easier integration with data science and machine learning workflows
- Offers a wider range of material models and sensor types
Cons of Mitsuba2
- Steeper learning curve due to its more complex architecture and broader feature set
- Less specialized for subdivision surfaces compared to OpenSubdiv
- May have higher computational requirements for certain rendering tasks
Code Comparison
OpenSubdiv (C++):
Far::TopologyRefiner * refiner = Far::TopologyRefinerFactory<Shape>::Create(
shape,
Far::TopologyRefinerFactory<Shape>::Options(
Far::TopologyRefinerFactory<Shape>::CREASE_UNIFORM));
Mitsuba2 (Python):
scene = mi.load_file('scene.xml')
integrator = mi.load_dict({
'type': 'path',
'max_depth': 8
})
image = mi.render(scene, integrator=integrator)
The code snippets demonstrate the different focus areas of the two libraries. OpenSubdiv is specialized for subdivision surfaces, while Mitsuba2 provides a more general-purpose rendering framework with support for various integrators and scene descriptions.
OpenVDB - Sparse volume data structure and tools
Pros of OpenVDB
- Specialized for volumetric data and sparse volume representations
- Offers advanced level set operations and fluid simulations
- Provides efficient data structures for large-scale voxel grids
Cons of OpenVDB
- Steeper learning curve due to complex volumetric concepts
- Less suitable for general-purpose subdivision surfaces
- May require more computational resources for certain operations
Code Comparison
OpenVDB:
openvdb::initialize();
openvdb::FloatGrid::Ptr grid = openvdb::FloatGrid::create();
openvdb::FloatGrid::Accessor accessor = grid->getAccessor();
accessor.setValue(openvdb::Coord(0, 0, 0), 1.0f);
OpenSubdiv:
OpenSubdiv::Far::TopologyDescriptor desc;
desc.numVertices = numVerts;
desc.numFaces = numFaces;
OpenSubdiv::Far::TopologyRefiner* refiner = OpenSubdiv::Far::TopologyRefinerFactory<OpenSubdiv::Far::TopologyDescriptor>::Create(desc);
OpenVDB excels in volumetric data handling and fluid simulations, while OpenSubdiv focuses on efficient subdivision surface algorithms. OpenVDB's code demonstrates creating and manipulating voxel grids, whereas OpenSubdiv's code shows setting up topology for subdivision. Choose OpenVDB for volumetric work and OpenSubdiv for traditional subdivision surfaces.
Unity Graphics - Including Scriptable Render Pipeline
Pros of Graphics
- Broader scope, covering various aspects of graphics rendering in Unity
- More active development and frequent updates
- Larger community and ecosystem within Unity's framework
Cons of Graphics
- More complex and potentially overwhelming for beginners
- Less specialized in subdivision surfaces compared to OpenSubdiv
- May require more setup and integration within Unity projects
Code Comparison
OpenSubdiv (C++):
OpenSubdiv::Far::TopologyRefiner * refiner =
OpenSubdiv::Far::TopologyRefinerFactory<OpenSubdiv::Far::TopologyDescriptor>::Create(
desc, OpenSubdiv::Far::TopologyRefinerFactory<OpenSubdiv::Far::TopologyDescriptor>::Options(
OpenSubdiv::Sdc::SCHEME_CATMARK, OpenSubdiv::Sdc::OPTIONS_NONE));
Graphics (C#):
public class CustomRenderPipelineAsset : RenderPipelineAsset
{
protected override RenderPipeline CreatePipeline()
{
return new CustomRenderPipeline();
}
}
OpenSubdiv focuses on subdivision surfaces, providing a specialized library for high-quality surface modeling. Graphics, on the other hand, offers a comprehensive rendering pipeline for Unity, covering various aspects of graphics programming. While OpenSubdiv excels in its niche, Graphics provides a more versatile toolkit for game development within the Unity ecosystem.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
OpenSubdiv
OpenSubdiv is a set of open source libraries that implement high performance subdivision surface (subdiv) evaluation on massively parallel CPU and GPU architectures. This codepath is optimized for drawing deforming subdivs with static topology at interactive framerates. The resulting limit surface matches Pixar's Renderman to numerical precision.
OpenSubdiv is covered by the Apache license, and is free to use for commercial or non-commercial use. This is the same code that Pixar uses internally for animated film production. Our intent is to encourage high performance accurate subdiv drawing by giving away the "good stuff".
Feel free to use it and let us know what you think.
For more details about OpenSubdiv, see Pixar Graphics Technologies.
Linux | Windows | macOS | |
---|---|---|---|
dev | |||
release |
Documents
Forum
Prerequisite
For complete information, please refer OpenSubdiv documents: Building with CMake
- General requirements:
Lib | Min Version | Note |
---|---|---|
CMake | 3.12 | Required |
- Osd optional requirements:
Lib | Min Version | Note |
---|---|---|
CUDA | 4.0 | cuda backend |
TBB | 2018 | TBB backend |
OpenCL | 1.1 | CL backend |
DX11 SDK | DX backend | |
Metal | 1.2 | Metal backend |
- Requirements for building optional examples:
Lib | Min Version | Note |
---|---|---|
GLFW | 3.0.0 | GL examples |
Ptex | 2.0 | ptex viewers |
Zlib | (required for Ptex under windows) |
- Requirements for building documentation:
Lib |
---|
Docutils |
Doxygen |
Graphviz |
Build example to run glViewer and other example programs with minimal dependency
All platforms:
- Install cmake and GLFW
make sure GLFW install directories are configured as follows:
${GLFW_LOCATION}/include/GLFW/glfw3.h
${GLFW_LOCATION}/lib/libglfw3.a (linux)
${GLFW_LOCATION}/lib/glfw3.lib (windows)
- Clone OpenSubdiv repository, and create a build directory.
git clone https://github.com/PixarAnimationStudios/OpenSubdiv
mkdir build
cd build
Windows (Visual Studio)
cmake ^
-G "Visual Studio 15 2017 Win64" ^
-D NO_PTEX=1 -D NO_DOC=1 ^
-D NO_OMP=1 -D NO_TBB=1 -D NO_CUDA=1 -D NO_OPENCL=1 -D NO_CLEW=1 ^
-D "GLFW_LOCATION=*YOUR GLFW INSTALL LOCATION*" ^
..
cmake --build . --config Release --target install
Linux
cmake -D NO_PTEX=1 -D NO_DOC=1 \
-D NO_OMP=1 -D NO_TBB=1 -D NO_CUDA=1 -D NO_OPENCL=1 -D NO_CLEW=1 \
-D GLFW_LOCATION="*YOUR GLFW INSTALL LOCATION*" \
..
cmake --build . --config Release --target install
macOS
cmake -G Xcode -D NO_PTEX=1 -D NO_DOC=1 \
-D NO_OMP=1 -D NO_TBB=1 -D NO_CUDA=1 -D NO_OPENCL=1 -D NO_CLEW=1 \
-D GLFW_LOCATION="*YOUR GLFW INSTALL LOCATION*" \
..
cmake --build . --config Release --target install
iOS
SDKROOT=$(xcrun --sdk iphoneos --show-sdk-path) cmake -D NO_PTEX=1 -D NO_DOC=1 \
-D NO_OMP=1 -D NO_TBB=1 -D NO_CUDA=1 -D NO_OPENCL=1 -D NO_CLEW=1 \
-D CMAKE_TOOLCHAIN_FILE=../cmake/iOSToolchain.cmake -G Xcode \
..
- This will produce an "OpenSubdiv.xcodeproj" that can be open and the targets 'mtlViewer' and 'mtlPtexViewer' (if NO_PTEX is ommitted and libPtex.a is installed in the iOS SDK) that can be run
Useful cmake options and environment variables
-DCMAKE_BUILD_TYPE=[Debug|Release]
-DCMAKE_INSTALL_PREFIX=[base path to install OpenSubdiv]
-DCMAKE_LIBDIR_BASE=[library directory basename (default: lib)]
-DCMAKE_TOOLCHAIN_FILE=[toolchain file for crossplatform builds]
-DCUDA_TOOLKIT_ROOT_DIR=[path to CUDA Toolkit]
-DOSD_CUDA_NVCC_FLAGS=[CUDA options, e.g. --gpu-architecture]
-DPTEX_LOCATION=[path to Ptex]
-DGLFW_LOCATION=[path to GLFW]
-DSTRINGIFY_LOCATION=[path to stringify utility]
-DNO_LIB=1 // disable the opensubdiv libs build (caveat emptor)
-DNO_EXAMPLES=1 // disable examples build
-DNO_TUTORIALS=1 // disable tutorials build
-DNO_REGRESSION=1 // disable regression tests build
-DNO_PTEX=1 // disable PTex support
-DNO_DOC=1 // disable documentation build
-DNO_OMP=1 // disable OpenMP
-DNO_TBB=1 // disable TBB
-DNO_CUDA=1 // disable CUDA
-DNO_OPENCL=1 // disable OpenCL
-DNO_OPENGL=1 // disable OpenGL
-DNO_CLEW=1 // disable CLEW wrapper library
-DNO_METAL=1 // disable Metal
Top Related Projects
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot