Skip to content

Commit

Permalink
Adding an NDR plugin for arnold shaders. (#57)
Browse files Browse the repository at this point in the history
- Registering all the arnold shaders and setting up a filename metadata.
- Registering a filename metadata for prims.
- Updating Readme with the NDR plugin.
- Updating Readme regarding points support.
- Updating building docs with the NDR plugin.
- Fixing typos in the building docs.
- Generating the arnold_usd header for either the procedural, render delegate or ndr plugin and making all these three depend on it.

resolves #13
  • Loading branch information
sirpalee authored and sebastienblor committed Nov 25, 2019
1 parent 142afc2 commit 9722136
Show file tree
Hide file tree
Showing 14 changed files with 1,050 additions and 16 deletions.
19 changes: 17 additions & 2 deletions README.md
Expand Up @@ -15,7 +15,7 @@ Contributions are welcome! Please make sure to read the [contribution guidelines
Please follow the [building instructions](docs/building.md). To use the components, provided you installed in `<arnold-usd_dir>`, set the following environment variables:

- Add `<arnold-usd_dir>/lib/python` to `PYTHONPATH` for the Python schema bindings.
- Add `<arnold-usd_dir>/plugin` to `PXR_PLUGINPATH_NAME` for the Hydra render delegate.
- Add `<arnold-usd_dir>/plugin` to `PXR_PLUGINPATH_NAME` for the Hydra render delegate and the Node Registry plugin.
- Add `<arnold-usd_dir>/lib/usd` to `PXR_PLUGINPATH_NAME` for the USD schemas.
- Add `<arnold-usd_dir>/lib` to `LD_LIBRARY_PATH` on Linux, `PATH` on Windows and `DYLD_LIBRARY_PATH` on Mac.

Expand All @@ -30,6 +30,7 @@ The render delegate currently supports the following features:
- Support for the displayColor primvar
- Subdivision settings
- Volume
- Points
- SPrim Support
- Materials
- Arnold shaders are supported, the `info:id` attribute is used to determine the shader type
Expand Down Expand Up @@ -70,9 +71,23 @@ The render delegate currently supports the following features:
- Only converging renders are supported (ie. it’s not possible to block the viewport until the render finishes)
- No HdExtComputation and UsdSkel computation via the render delegate
- No of physical camera parameters
- No points
- No coordsys support

## Node Registry Plugin

The Node Registry plugin supports the current features:
- Registering Sdr nodes for every built-in shader and custom shader
- Setting up the asset URI either to `<built-in>` or to the path of the shader library providing the shader.
- Creating all parameters.

**Limitations**
- No nodes registered for
- Shapes
- Lights
- Filters
- Drivers
- No node is registered for the options node
- Metadata is not converted for any node

## Arnold USD Procedural

Expand Down
40 changes: 34 additions & 6 deletions SConstruct
Expand Up @@ -77,6 +77,7 @@ vars.AddVariables(
PathVariable('PREFIX', 'Directory to install under', '.', PathVariable.PathIsDirCreate),
PathVariable('PREFIX_PROCEDURAL', 'Directory to install the procedural under.', os.path.join('$PREFIX', 'procedural'), PathVariable.PathIsDirCreate),
PathVariable('PREFIX_RENDER_DELEGATE', 'Directory to install the procedural under.', os.path.join('$PREFIX', 'plugin'), PathVariable.PathIsDirCreate),
PathVariable('PREFIX_NDR_PLUGIN', 'Directory to install the ndr plugin under.', os.path.join('$PREFIX', 'plugin'), PathVariable.PathIsDirCreate),
PathVariable('PREFIX_HEADERS', 'Directory to install the headers under.', os.path.join('$PREFIX', 'include'), PathVariable.PathIsDirCreate),
PathVariable('PREFIX_LIB', 'Directory to install the libraries under.', os.path.join('$PREFIX', 'lib'), PathVariable.PathIsDirCreate),
PathVariable('PREFIX_BIN', 'Directory to install the binaries under.', os.path.join('$PREFIX', 'bin'), PathVariable.PathIsDirCreate),
Expand All @@ -85,6 +86,7 @@ vars.AddVariables(
BoolVariable('SHOW_PLOTS', 'Display timing plots for the testsuite. gnuplot has to be found in the environment path.', False),
BoolVariable('BUILD_SCHEMAS', 'Wether or not to build the schemas and their wrapper.', True),
BoolVariable('BUILD_RENDER_DELEGATE', 'Wether or not to build the hydra render delegate.', True),
BoolVariable('BUILD_NDR_PLUGIN', 'Wether or not to build the node registry plugin.', True),
BoolVariable('BUILD_USD_WRITER', 'Wether or not to build the arnold to usd writer tool.', True),
BoolVariable('BUILD_PROCEDURAL', 'Wether or not to build the arnold procedural', True),
BoolVariable('BUILD_TESTSUITE', 'Wether or not to build the testsuite', True),
Expand All @@ -108,6 +110,7 @@ def get_optional_env_var(env_name):

BUILD_SCHEMAS = env['BUILD_SCHEMAS']
BUILD_RENDER_DELEGATE = env['BUILD_RENDER_DELEGATE']
BUILD_NDR_PLUGIN = env['BUILD_NDR_PLUGIN']
BUILD_USD_WRITER = env['BUILD_USD_WRITER']
BUILD_PROCEDURAL = env['BUILD_PROCEDURAL']
BUILD_TESTSUITE = env['BUILD_TESTSUITE']
Expand Down Expand Up @@ -144,6 +147,7 @@ ARNOLD_BINARIES = env.subst(env['ARNOLD_BINARIES'])
PREFIX = env.subst(env['PREFIX'])
PREFIX_PROCEDURAL = env.subst(env['PREFIX_PROCEDURAL'])
PREFIX_RENDER_DELEGATE = env.subst(env['PREFIX_RENDER_DELEGATE'])
PREFIX_NDR_PLUGIN = env.subst(env['PREFIX_NDR_PLUGIN'])
PREFIX_HEADERS = env.subst(env['PREFIX_HEADERS'])
PREFIX_LIB = env.subst(env['PREFIX_LIB'])
PREFIX_BIN = env.subst(env['PREFIX_BIN'])
Expand Down Expand Up @@ -314,6 +318,10 @@ renderdelegate_script = os.path.join('render_delegate', 'SConscript')
renderdelegate_build = os.path.join(BUILD_BASE_DIR, 'render_delegate')
renderdelegate_plug_info = os.path.join('render_delegate', 'plugInfo.json')

ndrplugin_script = os.path.join('ndr', 'SConscript')
ndrplugin_build = os.path.join(BUILD_BASE_DIR, 'ndr')
ndrplugin_plug_info = os.path.join('ndr', 'plugInfo.json')

testsuite_build = os.path.join(BUILD_BASE_DIR, 'testsuite')

# Define targets
Expand All @@ -328,19 +336,23 @@ if BUILD_PROCEDURAL or BUILD_USD_WRITER:
else:
TRANSLATOR = None

if BUILD_PROCEDURAL or BUILD_RENDER_DELEGATE or BUILD_NDR_PLUGIN:
ARNOLDUSD_HEADER = env.Command(os.path.join(BUILD_BASE_DIR, 'arnold_usd.h'), 'arnold_usd.h.in', configure.configure_header_file)
else:
ARNOLDUSD_HEADER = None

# Define targets
# Target for the USD procedural
if BUILD_PROCEDURAL:
PROCEDURAL = env.SConscript(procedural_script,
variant_dir = procedural_build,
duplicate = 0, exports = 'env')
SConscriptChdir(0)

Depends(PROCEDURAL, TRANSLATOR[0])
Depends(PROCEDURAL, ARNOLDUSD_HEADER)
else:
PROCEDURAL = None


if BUILD_SCHEMAS:
SCHEMAS = env.SConscript(schemas_script,
variant_dir = schemas_build,
Expand All @@ -357,14 +369,19 @@ else:
ARNOLD_TO_USD = None

if BUILD_RENDER_DELEGATE:
ARNOLDUSD_HEADER = env.Command(os.path.join(BUILD_BASE_DIR, 'arnold_usd.h'), 'arnold_usd.h.in', configure.configure_header_file)
RENDERDELEGATE = env.SConscript(renderdelegate_script, variant_dir = renderdelegate_build, duplicate = 0, exports = 'env')
SConscriptChdir(0)
Depends(RENDERDELEGATE, ARNOLDUSD_HEADER)
else:
ARNOLDUSD_HEADER = None
RENDERDELEGATE = None

if BUILD_NDR_PLUGIN:
NDRPLUGIN = env.SConscript(ndrplugin_script, variant_dir = ndrplugin_build, duplicate = 0, exports = 'env')
SConscriptChdir(0)
Depends(NDRPLUGIN, ARNOLDUSD_HEADER)
else:
NDRPLUGIN = None

#Depends(PROCEDURAL, SCHEMAS)

if BUILD_DOCS:
Expand All @@ -380,7 +397,8 @@ else:
# extension.

plugInfos = [
renderdelegate_plug_info
renderdelegate_plug_info,
ndrplugin_plug_info,
]

for plugInfo in plugInfos:
Expand Down Expand Up @@ -431,9 +449,19 @@ if RENDERDELEGATE:
INSTALL_RENDERDELEGATE += env.Install(os.path.join(PREFIX_RENDER_DELEGATE, 'hdArnold', 'resources'), [os.path.join('render_delegate', 'plugInfo.json')])
INSTALL_RENDERDELEGATE += env.Install(PREFIX_RENDER_DELEGATE, ['plugInfo.json'])
INSTALL_RENDERDELEGATE += env.Install(os.path.join(PREFIX_HEADERS, 'render_delegate'), env.Glob(os.path.join('render_delegate', '*.h')))
INSTALL_RENDERDELEGATE += env.Install(PREFIX_HEADERS, ARNOLDUSD_HEADER)
env.Alias('delegate-install', INSTALL_RENDERDELEGATE)

if NDRPLUGIN:
INSTALL_NDRPLUGIN = env.Install(PREFIX_NDR_PLUGIN, NDRPLUGIN)
INSTALL_NDRPLUGIN += env.Install(os.path.join(PREFIX_NDR_PLUGIN, 'ndrArnold', 'resources'), [os.path.join('ndr', 'plugInfo.json')])
INSTALL_NDRPLUGIN += env.Install(PREFIX_NDR_PLUGIN, ['plugInfo.json'])
INSTALL_NDRPLUGIN += env.Install(os.path.join(PREFIX_HEADERS, 'ndr'), env.Glob(os.path.join('ndr', '*.h')))
env.Alias('ndrplugin-install', INSTALL_NDRPLUGIN)

if ARNOLDUSD_HEADER:
INSTALL_ARNOLDUSDHEADER = env.Install(PREFIX_HEADERS, ARNOLDUSD_HEADER)
env.Alias('arnoldusdheader-install', INSTALL_ARNOLDUSDHEADER)

'''
# below are the other dlls we need
env.Install(USD_INSTALL, [os.path.join(env['USD_PATH'], 'bin', 'tbb.dll')])
Expand Down
2 changes: 1 addition & 1 deletion docs/Doxyfile
Expand Up @@ -113,7 +113,7 @@ WARN_LOGFILE =
# Configuration options related to the input files
#---------------------------------------------------------------------------
# List input directories as strings and separate them by space.
INPUT = "README.md" "LICENSE.md" "CONTRIBUTING.md" "render_delegate" "docs"
INPUT = "README.md" "LICENSE.md" "CONTRIBUTING.md" "render_delegate" "ndr" "docs"
USE_MDFILE_AS_MAINPAGE = "README.md"
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.cpp \
Expand Down
17 changes: 10 additions & 7 deletions docs/building.md
Expand Up @@ -33,6 +33,7 @@ are the following.
- COMPILER: Compiler to use. `gcc` or `clang` (default is `gcc`) on Linux and Mac, and `msvc` on Windows.
- BUILD_SCHEMAS: Wether or not to build the schemas and their wrapper.
- BUILD_RENDER_DELEGATE: Wether or not to build the hydra render delegate.
- BUILD_NDR_PLUGIN: Wether or not to build the node registry plugin.
- BUILD_USD_WRITER: Wether or not to build the arnold to usd writer tool.
- BUILD_PROCEDURAL: Wether or not to build the arnold procedural.
- BUILD_TESTSUITE: Wether or not to build the testsuite.
Expand Down Expand Up @@ -64,13 +65,15 @@ are the following.
- TBB_LIB: Where to find TBB libraries.

## Configuring Installation
- PREFIX: Directory to install under. True by default.
- PREFIX_PROCEDURAL: Directory to install the procedural under. True by default.
- PREFIX_RENDER_DELEGATE: Directory to install the procedural under. True by default.
- PREFIX_HEADERS: Directory to install the headers under. True by default.
- PREFIX_LIB: Directory to install the libraries under. True by default.
- PREFIX_BIN: Directory to install the binaries under. True by default.
- PREFIX_DOCS: Directory to install the documentation under. True by default.
- PREFIX: Directory to install under.
- PREFIX_PROCEDURAL: Directory to install the procedural under. Defaults to `prefix/procedural`.
- PREFIX_RENDER_DELEGATE: Directory to install the render delegate under. Defaults to `prefix/plugin`.
- PREFIX_NDR_PLUGIN: Directory to install the ndr plugin under. Defaults to `prefix/plugin`.
- PREFIX_HEADERS: Directory to install the headers under. Defaults to `prefix/include`.
- PREFIX_LIB: Directory to install the libraries under. Defaults to `prefix/lib`.
- PREFIX_BIN: Directory to install the binaries under. Defaults to `prefix/bin`.
- PREFIX_DOCS: Directory to install the documentation under. Defaults to `prefix/docs`.
- PREFIX_THIRD_PARTY: Directory to install the third party modules under. Defaults to `prefix/third_party`.

## Example configuration

Expand Down
63 changes: 63 additions & 0 deletions ndr/SConscript
@@ -0,0 +1,63 @@
# Copyright 2019 Autodesk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from utils import system, build_tools

Import('env')
local_env = env.Clone()

from utils import configure

src_dir = os.path.join(env['ROOT_DIR'], 'ndr')
source_files = [
'discovery.cpp',
'parser.cpp',
'utils.cpp',
]

if system.os != 'windows':
local_env.Append(CXXFLAGS = Split('-fPIC'))

local_env.Append(CPPDEFINES=['NDRARNOLD_EXPORTS'])
local_env.Append(CPPPATH = [os.path.join(env['ROOT_DIR'], env['BUILD_BASE_DIR'], 'ndr')])
local_env.Append(LIBS = ['ai'])

if local_env['USD_BUILD_MODE'] == 'monolithic':
usd_deps = [
local_env['USD_MONOLITHIC_LIBRARY'],
'tbb',
]
else:
usd_libs = [
'arch',
'tf',
'gf',
'vt',
'ndr',
'sdr',
'sdf',
'usd',
]

usd_deps = ['tbb']
usd_libs, usd_sources = build_tools.link_usd_libraries(local_env, usd_libs)
usd_deps = usd_deps + usd_libs
source_files = source_files + usd_sources

local_env.Append(LIBS = usd_deps)
if local_env['USD_HAS_PYTHON_SUPPORT']:
local_env.Append(LIBS = [local_env['PYTHON_LIB_NAME'], local_env['BOOST_LIB_NAME'] % 'python'])

NDRPLUGIN = local_env.SharedLibrary('ndrArnold', source_files, SHLIBPREFIX='')
Return('NDRPLUGIN')
48 changes: 48 additions & 0 deletions ndr/api.h
@@ -0,0 +1,48 @@
// Copyright 2019 Luma Pictures
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Modifications Copyright 2019 Autodesk, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once

#include "pxr/base/arch/export.h"

#if defined(PXR_STATIC)
#define NDRARNOLD_API
#define NDRARNOLD_API_TEMPLATE_CLASS(...)
#define NDRARNOLD_API_TEMPLATE_STRUCT(...)
#define NDRARNOLD_LOCAL
#else
#if defined(NDRARNOLD_EXPORTS)
#define NDRARNOLD_API ARCH_EXPORT
#define NDRARNOLD_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
#define NDRARNOLD_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
#else
#define NDRARNOLD_API ARCH_IMPORT
#define NDRARNOLD_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
#define NDRARNOLD_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
#endif
#define NDRARNOLD_LOCAL ARCH_HIDDEN
#endif

0 comments on commit 9722136

Please sign in to comment.