2012-08-10 05:14:44 +00:00
# OpenSubdiv
2012-06-08 17:05:35 +00:00
2012-12-11 01:15:13 +00:00
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.
2012-06-08 17:05:35 +00:00
2013-08-01 23:14:23 +00:00
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".
2012-06-08 17:05:35 +00:00
2013-08-15 17:22:26 +00:00
Feel free to use it and let us know what you think.
2012-06-08 17:05:35 +00:00
2012-08-10 05:14:44 +00:00
For more details about OpenSubdiv, see [Pixar Graphics Technologies ](http://graphics.pixar.com ).
2012-06-08 17:05:35 +00:00
2013-04-03 20:48:34 +00:00
## Git Flow
We have adopted the git flow branching model. It is not necessary to use the git-flow extensions, though you may find them useful! But it will be helpful to read about the git flow branching model in order to understand the organization of branches and tags that you will find in the repository.
* [git-flow extensions ](https://github.com/nvie/gitflow )
2012-08-10 05:14:44 +00:00
## Quickstart
2012-06-08 17:05:35 +00:00
2012-06-08 18:30:50 +00:00
Basic instructions to get started with the code.
2012-08-10 05:14:44 +00:00
### Dependencies
2012-06-08 18:30:50 +00:00
2012-12-11 01:15:13 +00:00
Cmake will adapt the build based on which dependencies have been successfully discovered and will disable certain features and code examples accordingly.
2012-08-14 17:46:21 +00:00
2012-08-15 19:45:10 +00:00
Please refer to the documentation of each of the dependency packages for specific build and installation instructions.
2012-08-10 05:14:44 +00:00
Required:
2012-08-15 19:45:10 +00:00
* [cmake ](http://www.cmake.org/cmake/resources/software.html )
2012-06-08 18:30:50 +00:00
2012-08-10 05:14:44 +00:00
Optional:
2013-08-01 23:14:23 +00:00
* [GLEW ](http://sourceforge.net/projects/glew/ ) (Windows/Linux only)
2012-08-15 19:45:10 +00:00
* [CUDA ](http://developer.nvidia.com/category/zone/cuda-zone )
2014-09-05 22:07:46 +00:00
* [TBB] (https://www.threadingbuildingblocks.org/)
2012-08-15 19:45:10 +00:00
* [OpenCL ](http://www.khronos.org/opencl/ )
2013-02-01 11:22:12 +00:00
* [GLFW ](http://www.glfw.org/ )
2012-08-15 19:45:10 +00:00
* [Ptex ](https://github.com/wdas/ptex )
* [Zlib ](http://www.zlib.net ) (required for Ptex under Windows)
* [Maya SDK ](http://www.autodesk.com/maya/ ) (sample code for Maya viewport 2.0 primitive)
2012-12-11 01:15:13 +00:00
* [DX11 SDK ](http://www.microsoft.com/en-us/download/details.aspx?id=6812 )
2013-08-01 23:14:23 +00:00
* [Docutils ](http://docutils.sourceforge.net/ )
* [Doxygen ](file://www.doxygen.org/ )
2012-08-15 19:45:10 +00:00
### Useful cmake options and environment variables
````
-DCMAKE_BUILD_TYPE=[Debug|Release]
2013-08-01 23:14:23 +00:00
2013-04-23 02:35:41 +00:00
-DCMAKE_INSTALL_PREFIX=[base path to install OpenSubdiv (default: Current directory)]
-DCMAKE_LIBDIR_BASE=[library directory basename (default: lib)]
2013-08-01 23:14:23 +00:00
2012-08-15 19:45:10 +00:00
-DCUDA_TOOLKIT_ROOT_DIR=[path to CUDA]
-DPTEX_LOCATION=[path to Ptex]
-DGLEW_LOCATION=[path to GLEW]
2013-02-01 11:22:12 +00:00
-DGLFW_LOCATION=[path to GLFW]
2012-08-15 19:45:10 +00:00
-DMAYA_LOCATION=[path to Maya]
2013-08-01 23:14:23 +00:00
-DNO_LIB=1 // disable the opensubdiv libs build (caveat emptor)
-DNO_EXAMPLES=1 // disable examples build
2014-09-05 22:07:46 +00:00
-DNO_TUTORIALS=1 // disable tutorials build
2013-08-01 23:14:23 +00:00
-DNO_REGRESSION=1 // disable regression tests build
2014-05-16 12:21:41 +00:00
-DNO_MAYA=1 // disable Maya plugin build
2014-05-16 12:27:49 +00:00
-DNO_PTEX=1 // disable PTex support
2013-08-01 23:14:23 +00:00
-DNO_DOC=1 // disable documentation build
-DNO_OMP=1 // disable OpenMP
2014-09-05 22:07:46 +00:00
-DNO_TBB=1 // disable TBB
2013-08-01 23:14:23 +00:00
-DNO_CUDA=1 // disable CUDA
2014-05-16 12:08:11 +00:00
-DNO_OPENCL=1 // disable OpenCL
2014-09-05 22:07:46 +00:00
-DNO_OPENGL=1 // disable OpenGL
2014-05-21 08:10:45 +00:00
-DNO_CLEW=1 // disable CLEW wrapper library
2012-08-15 19:45:10 +00:00
````
2013-02-01 11:22:12 +00:00
The paths to Maya, Ptex, GLFW, and GLEW can also be specified through the
following environment variables: `MAYA_LOCATION` , `PTEX_LOCATION` , `GLFW_LOCATION` ,
2012-08-15 19:45:10 +00:00
and `GLEW_LOCATION` .
2012-06-08 18:30:50 +00:00
2012-12-11 01:15:13 +00:00
### Build instructions (Linux/OSX/Windows):
2012-06-05 21:07:27 +00:00
2012-08-10 05:14:44 +00:00
__Clone the repository:__
2012-06-05 21:07:27 +00:00
2012-12-11 01:15:13 +00:00
From the GitShell, Cygwin or the CLI :
2012-08-10 05:14:44 +00:00
````
git clone git://github.com/PixarAnimationStudios/OpenSubdiv.git
````
2012-06-08 17:05:35 +00:00
2012-12-11 01:15:13 +00:00
Alternatively, on Windows, GIT also provides a GUI to perform this operation.
2012-08-10 05:14:44 +00:00
__Generate Makefiles:__
2012-06-08 18:30:50 +00:00
2012-12-11 01:15:13 +00:00
Assuming that we want the binaries installed into a "build" directory at the root of the OpenSubdiv tree :
2012-08-10 05:14:44 +00:00
````
cd OpenSubdiv
mkdir build
cd build
````
2012-06-08 18:30:50 +00:00
2012-12-11 01:15:13 +00:00
Here is an example cmake configuration script for a full typical windows-based build that can be run in GitShell :
2012-06-08 18:30:50 +00:00
2012-08-10 05:14:44 +00:00
````
2012-12-11 01:15:13 +00:00
#/bin/tcsh
# Replace the ".." with a full path to the root of the OpenSubdiv source tree if necessary
"c:/Program Files (x86)/CMake 2.8/bin/cmake.exe" \
-G "Visual Studio 10 Win64" \
-D "GLEW_LOCATION:string=c:/Program Files/glew-1.9.0" \
2013-02-01 11:22:12 +00:00
-D "GLFW_LOCATION:string=c:/Program Files/glfw-2.7.7.bin.WIN64" \
2012-12-11 01:15:13 +00:00
-D "OPENCL_INCLUDE_DIRS:string=c:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.2/OpenCL/common/inc" \
-D "_OPENCL_CPP_INCLUDE_DIRS:string=c:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.2/OpenCL/common/inc" \
-D "OPENCL_LIBRARIES:string=c:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.2/OpenCL/common/lib/x64/OpenCL.lib" \
-D "MAYA_LOCATION:string=c:/Program Files/Autodesk/Maya2013.5" \
-D "PTEX_LOCATION:string=c:/Users/opensubdiv/demo/src/ptex/x64" \
..
# copy Ptex dependencies (Windows only)
mkdir -p bin/{Debug,Release}
\cp -f c:/Users/opensubdiv/demo/src/zlib-1.2.7/contrib/vstudio/vc10/x64/ZlibDllRelease/zlibwapi.dll bin/Debug/
\cp -f c:/Users/opensubdiv/demo/src/zlib-1.2.7/contrib/vstudio/vc10/x64/ZlibDllRelease/zlibwapi.dll bin/Release/
\cp -f c:/Users/opensubdiv/demo/src/ptex/x64/lib/Ptex.dll bin/Debug/
\cp -f c:/Users/opensubdiv/demo/src/ptex/x64/lib/Ptex.dll bin/Release/
2012-08-10 05:14:44 +00:00
````
2012-06-08 18:30:50 +00:00
2012-12-11 01:15:13 +00:00
Alternatively, you can use the cmake GUI or run the commands from the CLI.
2012-08-15 19:45:10 +00:00
2014-02-20 19:05:09 +00:00
Note : the OSX generator in cmake for Xcode is -G "Xcode". However we recommend against using it, as we have noticed problems with dependency tracking.
2013-02-04 19:49:30 +00:00
2012-12-11 01:15:13 +00:00
__Build the project:__
2012-08-15 19:45:10 +00:00
2014-02-20 19:05:09 +00:00
CMake provides a cross-platform command-line build:
````
cmake --build . --target install --config Release
````
2012-12-11 01:15:13 +00:00
Windows : launch VC++ with the solution generated by cmake in your build directory.
2012-08-04 02:51:27 +00:00
2014-02-20 19:05:09 +00:00
OSX : with the Xcode generator, run xcodebuild in your build directory, otherwise make.
2013-02-01 18:21:10 +00:00
2012-12-11 01:15:13 +00:00
*Nix : run make in your build directory
2012-06-08 18:30:50 +00:00
2012-08-10 05:14:44 +00:00
2012-12-11 01:15:13 +00:00
## Standalone viewers
2012-08-04 02:51:27 +00:00
2012-12-11 01:15:13 +00:00
OpenSubdiv builds a number of standalone viewers that demonstrate various aspects of the software.
2012-06-08 23:15:08 +00:00
2012-12-11 01:15:13 +00:00
__Common Keyboard Shortcuts:__
2012-06-08 23:15:08 +00:00
2012-08-10 05:14:44 +00:00
````
Left mouse button drag : orbit camera
2012-12-11 01:15:13 +00:00
Middle mouse button drag : pan camera
Right mouse button : dolly camera
2012-08-10 05:14:44 +00:00
n, p : next/prev model
2012-12-11 01:15:13 +00:00
1, 2, 3, 4, 5, 6, 7 : specify adaptive isolation or uniform refinment level
+, - : increase / decrease tessellation
2012-08-10 05:14:44 +00:00
w : switch display mode
q : quit
````
2012-12-21 19:51:23 +00:00
## Build instructions (iOS/Android)
2012-12-21 19:47:50 +00:00
OpenSubdiv may also be used for mobile app development.
Support for the CPU and GPU APIs used by OpenSubdiv is more limited on today's mobile operating systems. For example, the most widely support graphics API is OpenGL ES 2.0 which doesn't yet provide the support for tessellation shaders needed to fully implement GPU accellerated Feature Adaptive Subdivision.
OpenSubdiv can still be used to compute uniform refinement of subdivision surfaces for display on these platforms, realizing all of the benefits of a consistent interpretation of subdivision schemes and tags.
The easiest way to get started using OpenSubdiv for mobile is to use CMake's support for cross-compiling:
* [CMake Cross Compiling ](http://www.cmake.org/Wiki/CMake_Cross_Compiling )
2012-12-21 19:51:23 +00:00
### iOS
2012-12-21 19:47:50 +00:00
You will need a current version of Apple's Xcode and iOS SDK (tested with iOS 6.0.1 and Xcode 4.5.2):
* [Xcode ](https://developer.apple.com/xcode/ )
and a CMake toolchain for iOS:
* [iOS CMake ](https://code.google.com/p/ios-cmake/ )
You can then use CMake to configure and generate an Xcode project:
2012-12-21 19:53:08 +00:00
````
2012-12-21 19:47:50 +00:00
mkdir build-ios
cd build-ios
2014-12-08 09:12:19 +00:00
cmake -DNO_CUDA=1 -DCMAKE_TOOLCHAIN_FILE=[path to iOS.cmake] -GXcode ..
2012-12-21 19:47:50 +00:00
xcodebuild -target install -configuration Debug
2012-12-21 19:53:08 +00:00
````
2012-12-21 19:47:50 +00:00
You can open the resulting Xcode project directly, or include as a sub-project in the Xcode project for your app.
2012-12-21 19:51:23 +00:00
### Android NDK
2012-12-21 19:47:50 +00:00
You will need a current version of the Android NDK (tested with Android 4.2.1 and android-ndk-r8b):
* [Android NDK ](http://developer.android.com/tools/sdk/ndk/index.html )
and a CMake toolchain for Android:
* [Android CMake ](https://code.google.com/p/android-cmake/ )
You can then use CMake to configure and build OpenSubdiv:
2012-12-21 19:53:08 +00:00
````
2012-12-21 19:47:50 +00:00
mkdir build-ndk
cd build-ndk
cmake -DCMAKE_TOOLCHAIN_FILE=[path to android.cmake] -DLIBRARY_OUTPUT_PATH_ROOT=`pwd`/modules/OpenSubdiv ..
make install
2012-12-21 19:53:08 +00:00
````
2012-12-21 19:47:50 +00:00
The resulting NDK module can be imported by other NDK modules by including it in your module search path:
2012-12-21 19:53:08 +00:00
````
2012-12-21 19:47:50 +00:00
export NDK_MODULE_PATH=[path to build-ndk/modules]
2012-12-21 19:53:08 +00:00
````
2012-12-21 19:47:50 +00:00
2013-02-03 16:45:10 +00:00
## Regression tests
OpenSubdiv builds a number of regression test executables for testing:
* hbr_regression: Regression testing matching HBR (low-level hierarchical boundary rep) to a pre-generated data set.
* far_regression: Matching FAR (feature-adaptive rep using tables) against HBR results.
* osd_regression: Matching full OSD subdivision against HBR results. Currently checks single threaded CPU kernel only.