Skip to content

Commit

Permalink
Merge branch 'pr/usd-lux-update-ref-implementation' into pr/usd-lux-u…
Browse files Browse the repository at this point in the history
…pdate
  • Loading branch information
pmolodo committed Aug 15, 2024
2 parents 2bd74e3 + 78ca954 commit 1422fb3
Show file tree
Hide file tree
Showing 28 changed files with 2,702 additions and 109 deletions.
17 changes: 17 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,23 @@ Redistributions in binary form must reproduce the above copyright notice, this l

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

============================================================
pbrt (sampling functions in hdEmbree/pxrPbrt/pbrUtils.h)
============================================================

Copyright(c) 1998-2020 Matt Pharr, Wenzel Jakob, and Greg Humphreys.

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.

============================================================
Draco
Expand Down
2 changes: 2 additions & 0 deletions build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2578,6 +2578,7 @@ def _JoinVersion(v):
OpenVDB support: {enableOpenVDB}
OpenImageIO support: {buildOIIO}
OpenColorIO support: {buildOCIO}
Embree support: {buildEmbree}
PRMan support: {buildPrman}
UsdImaging {buildUsdImaging}
usdview: {buildUsdview}
Expand Down Expand Up @@ -2641,6 +2642,7 @@ def FormatBuildArguments(buildArgs):
enableOpenVDB=("On" if context.enableOpenVDB else "Off"),
buildOIIO=("On" if context.buildOIIO else "Off"),
buildOCIO=("On" if context.buildOCIO else "Off"),
buildEmbree=("On" if context.buildEmbree else "Off"),
buildPrman=("On" if context.buildPrman else "Off"),
buildUsdImaging=("On" if context.buildUsdImaging else "Off"),
buildUsdview=("On" if context.buildUsdview else "Off"),
Expand Down
8 changes: 4 additions & 4 deletions pxr/base/work/threadLimits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ Work_NormalizeThreadCount(const int n)

// Returns the normalized thread limit value from the environment setting. Note
// that 0 means "no change", i.e. the environment setting does not apply.
static unsigned
Work_GetConcurrencyLimitSetting()
unsigned
WorkGetConcurrencyLimitEnvSetting()
{
return Work_NormalizeThreadCount(TfGetEnvSetting(PXR_WORK_THREAD_LIMIT));
}
Expand All @@ -106,7 +106,7 @@ Work_InitializeThreading()
{
// Get the thread limit from the environment setting. Note that this value
// can be 0, i.e. the environment setting does not apply.
const unsigned settingVal = Work_GetConcurrencyLimitSetting();
const unsigned settingVal = WorkGetConcurrencyLimitEnvSetting();

// Threading is initialized with maximum physical concurrency.
const unsigned physicalLimit = WorkGetPhysicalConcurrencyLimit();
Expand Down Expand Up @@ -147,7 +147,7 @@ WorkSetConcurrencyLimit(unsigned n)
if (n) {
// Get the thread limit from the environment setting. Note this value
// may be 0 (default).
const unsigned settingVal = Work_GetConcurrencyLimitSetting();
const unsigned settingVal = WorkGetConcurrencyLimitEnvSetting();

// Override n with the environment setting. This will make sure that the
// setting always wins over the specified value n, but only if the
Expand Down
7 changes: 7 additions & 0 deletions pxr/base/work/threadLimits.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ PXR_NAMESPACE_OPEN_SCOPE
///
WORK_API unsigned WorkGetConcurrencyLimit();

/// Return the value set via the PXR_WORK_THREAD_LIMIT env setting.
///
/// The returned value is always >= 0, and it is normalized according to the
/// rules in WorkSetConcurrencyLimitArgument.
///
WORK_API unsigned WorkGetConcurrencyLimitEnvSetting();

/// Return true if WorkGetPhysicalConcurrencyLimit() returns a number greater
/// than 1 and PXR_WORK_THREAD_LIMIT was not set in an attempt to limit the
/// process to a single thread, false otherwise.
Expand Down
11 changes: 11 additions & 0 deletions pxr/imaging/plugin/hdEmbree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pxr_plugin(hdEmbree
PUBLIC_CLASSES
config
instancer
light
mesh
meshSamplers
renderBuffer
Expand All @@ -45,8 +46,18 @@ pxr_plugin(hdEmbree
renderParam.h

PRIVATE_CLASSES
debugCodes
implicitSurfaceSceneIndexPlugin

PRIVATE_HEADERS
pxrIES/ies.h
pxrIES/pxrIES.h
pxrPbrt/pbrtUtils.h

CPPFILES
pxrIES/ies.cpp
pxrIES/pxrIES.cpp

RESOURCE_FILES
plugInfo.json

Expand Down
60 changes: 43 additions & 17 deletions pxr/imaging/plugin/hdEmbree/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,49 @@ TF_INSTANTIATE_SINGLETON(HdEmbreeConfig);
// Each configuration variable has an associated environment variable.
// The environment variable macro takes the variable name, a default value,
// and a description...
TF_DEFINE_ENV_SETTING(HDEMBREE_SAMPLES_TO_CONVERGENCE, 100,
"Samples per pixel before we stop rendering (must be >= 1)");
TF_DEFINE_ENV_SETTING(
HDEMBREE_SAMPLES_TO_CONVERGENCE,
HdEmbreeDefaultSamplesToConvergence,
"Samples per pixel before we stop rendering (must be >= 1)");

TF_DEFINE_ENV_SETTING(HDEMBREE_TILE_SIZE, 8,
"Size (per axis) of threading work units (must be >= 1)");
TF_DEFINE_ENV_SETTING(
HDEMBREE_TILE_SIZE,
HdEmbreeDefaultTileSize,
"Size (per axis) of threading work units (must be >= 1)");

TF_DEFINE_ENV_SETTING(HDEMBREE_AMBIENT_OCCLUSION_SAMPLES, 16,
"Ambient occlusion samples per camera ray (must be >= 0; a value of 0 disables ambient occlusion)");
TF_DEFINE_ENV_SETTING(
HDEMBREE_AMBIENT_OCCLUSION_SAMPLES,
HdEmbreeDefaultAmbientOcclusionSamples,
"Ambient occlusion samples per camera ray (must be >= 0;"
" a value of 0 disables ambient occlusion)");

TF_DEFINE_ENV_SETTING(HDEMBREE_JITTER_CAMERA, 1,
"Should HdEmbree jitter camera rays while rendering? (values >0 are true)");
TF_DEFINE_ENV_SETTING(
HDEMBREE_JITTER_CAMERA,
HdEmbreeDefaultJitterCamera,
"Should HdEmbree jitter camera rays while rendering?");

TF_DEFINE_ENV_SETTING(HDEMBREE_USE_FACE_COLORS, 1,
"Should HdEmbree use face colors while rendering? (values > 0 are true)");
TF_DEFINE_ENV_SETTING(
HDEMBREE_USE_FACE_COLORS,
HdEmbreeDefaultUseFaceColors,
"Should HdEmbree use face colors while rendering?");

TF_DEFINE_ENV_SETTING(HDEMBREE_CAMERA_LIGHT_INTENSITY, 300,
"Intensity of the camera light, specified as a percentage of <1,1,1>.");
TF_DEFINE_ENV_SETTING(
HDEMBREE_CAMERA_LIGHT_INTENSITY,
HdEmbreeDefaultCameraLightIntensity,
"Intensity of the camera light, specified as a percentage of <1,1,1>.");

TF_DEFINE_ENV_SETTING(HDEMBREE_PRINT_CONFIGURATION, 0,
"Should HdEmbree print configuration on startup? (values > 0 are true)");
TF_DEFINE_ENV_SETTING(
HDEMBREE_RANDOM_NUMBER_SEED,
HdEmbreeDefaultRandomNumberSeed,
"Seed to give to the random number generator. A value of anything other"
" than -1, combined with setting PXR_WORK_THREAD_LIMIT=1, should"
" give deterministic / repeatable results. A value of -1 (the"
" default) will allow the implementation to set a value that varies"
" from invocation to invocation and thread to thread.");

TF_DEFINE_ENV_SETTING(HDEMBREE_PRINT_CONFIGURATION,
false,
"Should HdEmbree print configuration on startup?");

HdEmbreeConfig::HdEmbreeConfig()
{
Expand All @@ -50,12 +73,13 @@ HdEmbreeConfig::HdEmbreeConfig()
TfGetEnvSetting(HDEMBREE_TILE_SIZE));
ambientOcclusionSamples = std::max(0,
TfGetEnvSetting(HDEMBREE_AMBIENT_OCCLUSION_SAMPLES));
jitterCamera = (TfGetEnvSetting(HDEMBREE_JITTER_CAMERA) > 0);
useFaceColors = (TfGetEnvSetting(HDEMBREE_USE_FACE_COLORS) > 0);
jitterCamera = (TfGetEnvSetting(HDEMBREE_JITTER_CAMERA));
useFaceColors = (TfGetEnvSetting(HDEMBREE_USE_FACE_COLORS));
cameraLightIntensity = (std::max(100,
TfGetEnvSetting(HDEMBREE_CAMERA_LIGHT_INTENSITY)) / 100.0f);
randomNumberSeed = TfGetEnvSetting(HDEMBREE_RANDOM_NUMBER_SEED);

if (TfGetEnvSetting(HDEMBREE_PRINT_CONFIGURATION) > 0) {
if (TfGetEnvSetting(HDEMBREE_PRINT_CONFIGURATION)) {
std::cout
<< "HdEmbree Configuration: \n"
<< " samplesToConvergence = "
Expand All @@ -70,6 +94,8 @@ HdEmbreeConfig::HdEmbreeConfig()
<< useFaceColors << "\n"
<< " cameraLightIntensity = "
<< cameraLightIntensity << "\n"
<< " randomNumberSeed = "
<< randomNumberSeed << "\n"
;
}
}
Expand Down
42 changes: 32 additions & 10 deletions pxr/imaging/plugin/hdEmbree/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@

PXR_NAMESPACE_OPEN_SCOPE

// NOTE: types here restricted to bool/int/string, as also used for
// TF_DEFINE_ENV_SETTING
constexpr int HdEmbreeDefaultSamplesToConvergence = 100;
constexpr int HdEmbreeDefaultTileSize = 8;
constexpr int HdEmbreeDefaultAmbientOcclusionSamples = 16;
constexpr bool HdEmbreeDefaultJitterCamera = true;
constexpr bool HdEmbreeDefaultUseFaceColors = true;
constexpr int HdEmbreeDefaultCameraLightIntensity = 300;
constexpr int HdEmbreeDefaultRandomNumberSeed = -1;

/// \class HdEmbreeConfig
///
/// This class is a singleton, holding configuration parameters for HdEmbree.
Expand All @@ -27,45 +37,57 @@ PXR_NAMESPACE_OPEN_SCOPE
///
class HdEmbreeConfig {
public:

/// \brief Return the configuration singleton.
static const HdEmbreeConfig &GetInstance();

/// How many samples do we need before a pixel is considered
/// converged?
///
/// Override with *HDEMBREE_SAMPLES_TO_CONVERGENCE*.
unsigned int samplesToConvergence;
unsigned int samplesToConvergence = HdEmbreeDefaultSamplesToConvergence;

/// How many pixels are in an atomic unit of parallel work?
/// A work item is a square of size [tileSize x tileSize] pixels.
///
/// Override with *HDEMBREE_TILE_SIZE*.
unsigned int tileSize;
unsigned int tileSize = HdEmbreeDefaultTileSize;

/// How many ambient occlusion rays should we generate per
/// camera ray?
///
/// Override with *HDEMBREE_AMBIENT_OCCLUSION_SAMPLES*.
unsigned int ambientOcclusionSamples;
unsigned int ambientOcclusionSamples = HdEmbreeDefaultAmbientOcclusionSamples;

/// Should the renderpass jitter camera rays for antialiasing?
///
/// Override with *HDEMBREE_JITTER_CAMERA*. Integer values greater than
/// zero are considered "true".
bool jitterCamera;
/// Override with *HDEMBREE_JITTER_CAMERA*. The case-insensitive strings
/// "true", "yes", "on", and "1" are considered true; an empty value uses
/// the default, and all other values are false.
bool jitterCamera = HdEmbreeDefaultJitterCamera;

/// Should the renderpass use the color primvar, or flat white colors?
/// (Flat white shows off ambient occlusion better).
///
/// Override with *HDEMBREE_USE_FACE_COLORS*. Integer values greater than
/// zero are considered "true".
bool useFaceColors;
/// Override with *HDEMBREE_USE_FACE_COLORS*. The case-insensitive strings
/// "true", "yes", "on", and "1" are considered true; an empty value uses
/// the default, and all other values are false.
bool useFaceColors = HdEmbreeDefaultUseFaceColors;

/// What should the intensity of the camera light be, specified as a
/// percent of <1, 1, 1>. For example, 300 would be <3, 3, 3>.
///
/// Override with *HDEMBREE_CAMERA_LIGHT_INTENSITY*.
float cameraLightIntensity;
float cameraLightIntensity = HdEmbreeDefaultCameraLightIntensity;

/// Seed to give to the random number generator. A value of anything other
/// than -1, combined with setting PXR_WORK_THREAD_LIMIT=1, should give
/// deterministic / repeatable results. A value of -1 (the default) will
/// allow the implementation to set a value that varies from invocation to
/// invocation and thread to thread.
///
/// Override with *HDEMBREE_RANDOM_NUMBER_SEED*.
int randomNumberSeed = HdEmbreeDefaultRandomNumberSeed;

private:
// The constructor initializes the config variables with their
Expand Down
4 changes: 4 additions & 0 deletions pxr/imaging/plugin/hdEmbree/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@

#include "pxr/base/gf/matrix4f.h"
#include "pxr/base/vt/array.h"
#include "pxr/base/vt/types.h"

#include <embree3/rtcore.h>

PXR_NAMESPACE_OPEN_SCOPE

class HdRprim;
class HdEmbree_Light;

/// \class HdEmbreePrototypeContext
///
Expand Down Expand Up @@ -51,6 +53,8 @@ struct HdEmbreeInstanceContext
RTCScene rootScene;
/// The instance id of this instance.
int32_t instanceId;
/// The light (if this is a light)
HdEmbree_Light *light = nullptr;
};


Expand Down
20 changes: 20 additions & 0 deletions pxr/imaging/plugin/hdEmbree/debugCodes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Copyright 2024 Pixar
//
// Licensed under the terms set forth in the LICENSE.txt file available at
// https://openusd.org/license.
//
#include "pxr/pxr.h"
#include "pxr/imaging/plugin/hdEmbree/debugCodes.h"

#include "pxr/base/tf/debug.h"
#include "pxr/base/tf/registryManager.h"

PXR_NAMESPACE_OPEN_SCOPE

TF_REGISTRY_FUNCTION(TfDebug)
{
TF_DEBUG_ENVIRONMENT_SYMBOL(HDEMBREE_LIGHT_CREATE, "Creation of HdEmbree lights");
}

PXR_NAMESPACE_CLOSE_SCOPE
21 changes: 21 additions & 0 deletions pxr/imaging/plugin/hdEmbree/debugCodes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Copyright 2024 Pixar
//
// Licensed under the terms set forth in the LICENSE.txt file available at
// https://openusd.org/license.
//
#ifndef PXR_IMAGING_PLUGIN_HD_EMBREE_DEBUG_CODES_H
#define PXR_IMAGING_PLUGIN_HD_EMBREE_DEBUG_CODES_H

#include "pxr/pxr.h"
#include "pxr/base/tf/debug.h"

PXR_NAMESPACE_OPEN_SCOPE

TF_DEBUG_CODES(
HDEMBREE_LIGHT_CREATE
);

PXR_NAMESPACE_CLOSE_SCOPE

#endif // PXR_IMAGING_PLUGIN_HD_EMBREE_DEBUG_CODES_H
Loading

0 comments on commit 1422fb3

Please sign in to comment.