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
Prerequisites and Building
The OpenSubdiv core libraries are implemented in C++ with no dependencies other than the C++ standard library.
The OpenSubdiv::Osd library contains additional conditionally compiled components which use specific external CPU and GPU APIs for evaluation and display and there are also optional interactive examples. Some of these optional aspects are enabled by default but can be disabled while configuring the OpenSubdiv build.
For complete information, please see: Building with CMake
Versions
These are the versions of external dependencies used to test the current release of OpenSubdiv. Generally, OpenSubdiv will also work with earlier and later versions of these external dependencies, but this represents versions known to work.
Core Dependencies | Version | Note |
---|---|---|
CMake | 3.14 | Required |
Optional OpenSubdiv::Osd Dependencies | Version | Note |
---|---|---|
OpenGL | 4.1+ | OpenGL |
Metal | 3+ | Metal |
CUDA | 12.6 | CUDA |
TBB | 2021.12.0 | oneTBB |
OpenCL | 1.1 | OpenCL |
DirectX11 | 11+ | DirectX11 |
Optional Interactive Example Dependencies | Version | Note |
---|---|---|
GLFW | 3.3.3 | OpenGL example viewers |
Ptex | 2.4.2 | Ptex example viewers |
Zlib | 1.2.13 | Ptex example viewers |
Optional Documentation Dependencies | Version | Note |
---|---|---|
Doxygen | 1.14.0 | C++ API Documentation |
Docutils | 0.21.2 | general documentation |
Pygments | 2.19 | general documentation |
Building with minimal dependencies to run glViewer and other example programs
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
git clone https://github.com/PixarAnimationStudios/OpenSubdiv
cd OpenSubdiv
Windows (Visual Studio)
cmake -B buildDir ^
-D CMAKE_INSTALL_PREFIX=instDir ^
-G "Visual Studio 16 2019" -A x64 ^
-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=C:\path\to\glfw" ^
-S .
cmake --build buildDir --config Release --target install
Linux
cmake -B buildDir \
-D CMAKE_INSTALL_PREFIX=instDir \
-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=/path/to/glfw" \
-S .
cmake --build buildDir --config Release --target install
macOS
cmake -B buildDir \
-D CMAKE_INSTALL_PREFIX=instDir \
-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=/path/to/glfw" \
-S .
cmake --build buildDir --config Release --target install
iOS
Use CMAKE_SYSTEM_NAME to have CMake use the appropriate cross-compilation toolchain when building for iOS.
SDKROOT=$(xcrun --sdk iphoneos --show-sdk-path) \
cmake -B buildDir \
-D CMAKE_INSTALL_PREFIX=instDir \
-G Xcode \
-D CMAKE_SYSTEM_NAME=iOS \
-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 NO_TUTORIALS=1 -D NO_EXAMPLES=1 -D NO_REGRESSION=1 -D NO_OPENGL=1 \
-S .
- This will produce an "OpenSubdiv.xcodeproj" that can be opened with Xcode.
- Use
SDKROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
instead for an iOS-Sim target
Useful cmake options and environment variables
-DCMAKE_BUILD_TYPE=[Debug|Release]
-DCMAKE_INSTALL_PREFIX=[base path to install OpenSubdiv (default: Current directory)]
-DCMAKE_LIBDIR_BASE=[library directory basename (default: lib)]
-DCMAKE_SYSTEM_NAME=[target system name for cross-compilation builds, e.g. iOS]
-DCMAKE_PREFIX_PATH=[semicolon-separated list of directories specifying installation prefixes to be searched by the find_package() command (default: empty list)]
-DCUDA_SDK_ROOT_DIR=[path to CUDA]
-DCUDA_TOOLKIT_ROOT_DIR=[path to CUDA]
-DOSD_CUDA_NVCC_FLAGS=[CUDA options, e.g. --gpu-architecture]
-DGLFW_LOCATION=[path to GLFW for OpenGL example viewers]
-DPTEX_LOCATION=[path to Ptex for Ptex example viewers]
-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 examples
-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_CLEW=1 // disable OpenCL loader library
-DNO_OPENGL=1 // disable OpenGL
-DNO_METAL=1 // disable Metal
-DOSD_PATCH_SHADER_SOURCE_GLSL=1 // GLSL Patch Shader Source
-DOSD_PATCH_SHADER_SOURCE_HLSL=1 // HLSL Patch Shader Source
-DOSD_PATCH_SHADER_SOURCE_MSL=1 // MSL Patch Shader Source
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