Skip to content

Commit

Permalink
Release v24.03
Browse files Browse the repository at this point in the history
* Fix URL in build docs (#151)

* OGSMOD-3964: Upgrade to MtlX 1.38.7 and fix errors (#153)

* OGSMOD-3972:  Add some tests for UV transforms (#154)

* Optionally support 23.08.01 USD (#157)

* Build on PR and Abort Previous Build for PR (#156)

* OGSMOD-3766: Move raytracer to non-recursive architecture (#152)

* OGSMOD-3967: Implement transparent shadows in non-recusive mode (#158)

* OGSMOD-3966: Ground plane works with non-recursive rendering (#160)

* OGSMOD-4003: Upgrade to MaterialX 1.38.8 (#161)

* Specify thread group dimensions for the accumulation and post-processing compute shaders (#30) (#162)

* OGSMOD-3965: Support layers in non-recursive ray tracing (Part 1) (#164)

* OGSMOD-3965: Support layers in non-recursive ray tracing (Part 2) (#165)

* Update CONTRIBUTING.MD (#166)

* OGSMOD-4183: Fix layer crash in inventor (#167)

* Move shadow ray emission to end of loop (#168)

* OGSMOD-4309: Remove erase from for light iterator loop (#169)

* Don't assert if zero verts (#172)

* Use default image when getData function fails (#173)
  • Loading branch information
gareth-morgan-autodesk committed Mar 15, 2024
1 parent dbb7199 commit 3082b23
Show file tree
Hide file tree
Showing 129 changed files with 5,902 additions and 3,674 deletions.
9 changes: 8 additions & 1 deletion Applications/Plasma/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ static constexpr vec3 kForward = vec3(0.0f, 0.0f, -1.0f);
static constexpr vec3 kRight = vec3(1.0f, 0.0f, 0.0f);
static constexpr vec3 kUp = vec3(0.0f, 1.0f, 0.0f);

#define DUMP_CAMERA_POSITION 0

const mat4& Camera::viewMatrix()
{
// Create a view matrix if it needs to be updated.
if (_isViewDirty)
{
_viewMatrix = lookAt(_eye, _target, _up);
_viewMatrix = lookAt(_eye, _target, _up);
// If dev flag is set dump camera position.
#if DUMP_CAMERA_POSITION
AU_INFO("--eye=%0.2f,%0.2f,%0.2f --target=%0.2f,%0.2f,%0.2f", _eye.x, _eye.y, _eye.z,
_target.x, _target.y, _target.z);
#endif
_isViewDirty = false;
}

Expand Down
3 changes: 3 additions & 0 deletions Applications/Plasma/Loaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class ImageCache
using LoadSceneFunc = function<bool(Aurora::IRenderer* pRenderer, Aurora::IScene* pScene,
const string& filePath, SceneContents& sceneContents)>;

// If true OBJ loader will try and load a materialX file for each OBJ material.
void loadMaterialXForOBJMaterials(bool enabled);

// Loads a Wavefront OBJ (.obj) file into the specified renderer and scene, from the specified file
// path.
bool loadOBJFile(Aurora::IRenderer* pRenderer, Aurora::IScene* pScene, const string& filePath,
Expand Down
41 changes: 40 additions & 1 deletion Applications/Plasma/OBJLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "Loaders.h"
#include "SceneContents.h"

bool gEnableMaterialXMaterials = false;

uint32_t ImageCache::whitePixels[1] = { 0xFFFFFFFF };

#define PLASMA_HAS_TANGENTS 0
Expand Down Expand Up @@ -62,6 +64,11 @@ struct hashOBJIndex
// An unordered (hash) map from an OBJIndex (with vertex channel indices) to a single index.
using OBJIndexMap = unordered_map<OBJIndex, uint32_t, hashOBJIndex>;

void loadMaterialXForOBJMaterials(bool enabled)
{
gEnableMaterialXMaterials = enabled;
}

// Loads a Wavefront OBJ file into the specified renderer and scene, from the specified file path.
bool loadOBJFile(Aurora::IRenderer* /*pRenderer*/, Aurora::IScene* pScene, const string& filePath,
SceneContents& sceneContents)
Expand Down Expand Up @@ -103,9 +110,40 @@ bool loadOBJFile(Aurora::IRenderer* /*pRenderer*/, Aurora::IScene* pScene, const
int mtlCount = 0;
for (auto& objMaterial : objMaterials)
{
// Flag is set try and load a materialX file with the OBJ material name.
if (gEnableMaterialXMaterials && !objMaterial.name.empty())
{
// Build MaterialX file path from OBJ material name and OBJ path.
std::string directory = std::filesystem::path(filePath).parent_path().u8string();
string mtlxFilename = directory + "/" + objMaterial.name + ".mtlx";
ifstream is(mtlxFilename, ifstream::binary);
if (is.good())
{
// If the file exists load it into a string.
string mtlString;
is.seekg(0, is.end);
size_t length = is.tellg();
is.seekg(0, is.beg);
mtlString.resize(length + 1);
is.read((char*)&mtlString[0], length);

// Create a material from the MaterialX string, and use it in place of the OBJ
// material.
Aurora::Path materialPath =
filePath + "-" + objMaterial.name + ":MaterialX-" + to_string(mtlCount++);
pScene->setMaterialType(materialPath, Names::MaterialTypes::kMaterialX, mtlString);
lstMaterials.push_back(materialPath);
AU_INFO("Found materialX document %s for OBJ material %s", mtlxFilename.c_str(),
objMaterial.name.c_str());
continue;
}
}

// Collect material properties.
// NOTE: This includes support for some of the properties in the PBR extension here:
// http://exocortex.com/blog/extending_wavefront_mtl_to_support_pbr
// See TinyOBJ parsing code for mapping from OBJ mtl values to ObjMaterial properties:
// https://github.com/tinyobjloader/tinyobjloader/blob/ee45fb41db95bf9563f2a41bc63adfa18475c2ee/tiny_obj_loader.h#L2127
// > We use the Standard Surface IOR default of 1.5 when no IOR is specified in the file,
// which is parsed as 1.0.
// > Transmission is derived from the "dissolve" property. This is normally intended for
Expand Down Expand Up @@ -178,7 +216,8 @@ bool loadOBJFile(Aurora::IRenderer* /*pRenderer*/, Aurora::IScene* pScene, const
{ "normal_image", normalImage }
};
// clang-format on
Aurora::Path materialPath = filePath + ":OBJFileMaterial-" + to_string(mtlCount++);
Aurora::Path materialPath =
filePath + "-" + objMaterial.name + ":OBJFileMaterial-" + to_string(mtlCount++);
pScene->setMaterialProperties(materialPath, properties);
lstMaterials.push_back(materialPath);
};
Expand Down
85 changes: 55 additions & 30 deletions Applications/Plasma/Plasma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,11 @@ bool Plasma::run(int argc, char* argv[])
#endif

// Creates a sample scene.
Aurora::IScenePtr Plasma::createSampleScene(Aurora::IRenderer* pRenderer, SceneContents& contents)
void Plasma::createSampleScene(Aurora::IScene* pScene, SceneContents& contents)
{
// Clear the result.
contents.reset();

// Create an Aurora scene.
Aurora::IScenePtr pScene = pRenderer->createScene();
if (!pScene)
{
return nullptr;
}

// Create sample geometry, a single triangle.
const Aurora::Path kGeomPath = "PlasmaDefaultSceneGeometry";

Expand Down Expand Up @@ -269,7 +262,7 @@ Aurora::IScenePtr Plasma::createSampleScene(Aurora::IRenderer* pRenderer, SceneC
vec3 max(1.0f, 1.0f, 0.01f);
contents.bounds = Foundation::BoundingBox(min, max);

return pScene;
return;
}

bool Plasma::getFloat3Option(const string& name, glm::vec3& value) const
Expand Down Expand Up @@ -360,6 +353,7 @@ void Plasma::parseOptions(int argc, char* argv[])
("fov", "Camera field of view in degrees.", cxxopts::value<float>())
("env", "Environment map path to load (lat-long format .HDR file)", cxxopts::value<string>())
("mtlx", "MaterialX document path to apply.",cxxopts::value<string>())
("loadMtlXForObj", "Try and load MaterialX documents for each OBJ material.", cxxopts::value<bool>())
("h,help", "Print help");
// clang-format on

Expand Down Expand Up @@ -437,12 +431,11 @@ bool Plasma::initialize()
return false;
}

// Setup asset search paths. Including the path to the ProteinX test folder (if running within
// the Github repo).
// TODO: A more reliable solution would be to set based on the loaded materialX file path.
_assetPaths = { "",
Foundation::getModulePath() +
"../../../Renderers/Tests/Data/Materials/mtlx_ProteinSubset/" };
// Setup asset search paths. Including the path to the unit test assets folder (if running
// within the Github repo).
// TODO: A more reliable solution would be to set based on the loaded MaterialX file path.
_assetPaths = { "", Foundation::getModulePath() + "../../../Tests/Assets/Materials/",
Foundation::getModulePath() + "../../../Tests/Assets/Textures/" };

// Setup the resource loading function to use asset search paths.
auto loadResourceFunc = [this](const string& uri, vector<unsigned char>* pBufferOut,
Expand Down Expand Up @@ -479,6 +472,12 @@ bool Plasma::initialize()
};
_pRenderer->setLoadResourceFunction(loadResourceFunc);

// The load materialX flag for OBJ loader if argument set.
if (_pArguments->count("loadMtlXForObj") > 0)
{
loadMaterialXForOBJMaterials(true);
}

// Set reference flag.
if (_pArguments->count("reference") > 0)
{
Expand Down Expand Up @@ -536,8 +535,14 @@ bool Plasma::initialize()
// If a file was not loaded, create a sample scene.
if (!bFileLoaded)
{
// Create new empty scene
_pScene = _pRenderer->createScene();

// Set the scene on the renderer.
_pRenderer->setScene(_pScene);

// Create the sample scene, and return if it not successful.
_pScene = createSampleScene(_pRenderer.get(), _sceneContents);
createSampleScene(_pScene.get(), _sceneContents);
if (!_pScene)
{
return false;
Expand Down Expand Up @@ -605,7 +610,7 @@ bool Plasma::initialize()

bool Plasma::addDecal(const string& decalMtlXPath)
{
// Load the materialX file for decal.
// Load the MaterialX file for decal.
auto materialPath = loadMaterialXFile(decalMtlXPath);
if (materialPath.empty())
return false;
Expand Down Expand Up @@ -705,10 +710,6 @@ void Plasma::updateNewScene()
_animationTimer.reset(!_isAnimating);
_frameNumber = 0;

// Set the scene on the renderer, and assign the environment and ground plane. Set the ground
// plane position to the bottom corner, of the scene bounds.
_pRenderer->setScene(_pScene);

// Setup environment for new scene.
_pScene->setEnvironmentProperties(
_environmentPath, { { Aurora::Names::EnvironmentProperties::kBackgroundUseScreen, true } });
Expand Down Expand Up @@ -1003,12 +1004,30 @@ void Plasma::selectFile(
// works as desired here because the load blocks the application.
::SetCursor(::LoadCursor(nullptr, IDC_WAIT));

// Load the file.
addAssetPathContainingFile(Foundation::w2s(filePath.data()));
loadFunc(Foundation::w2s(filePath.data()));
}

#endif

void Plasma::addAssetPathContainingFile(const string& filePath)
{
string directory = filesystem::path(filePath).parent_path().u8string();
if (directory.empty())
return;
addAssetPath(directory + "/");
}

void Plasma::addAssetPath(const string& filePath)
{
for (int i = 0; i < _assetPaths.size(); i++)
{
if (_assetPaths[i].compare(filePath) == 0)
return;
}
_assetPaths.push_back(filePath);
}

// Loads an environment image file with the specified path.
bool Plasma::loadEnvironmentImageFile(const string& filePath)
{
Expand Down Expand Up @@ -1052,10 +1071,16 @@ bool Plasma::loadSceneFile(const string& filePath)
auto directory = filesystem::path(filePath).parent_path();
filesystem::current_path(directory);

// Create new empty scene
_pScene = _pRenderer->createScene();

// Set the scene on the renderer.
_pRenderer->setScene(_pScene);

// Create a new scene and load the scene file into it. If that fails, return immediately.
_sceneContents.reset();
Aurora::IScenePtr pScene = _pRenderer->createScene();
if (!loadSceneFunc(_pRenderer.get(), pScene.get(), filePath, _sceneContents))
addAssetPathContainingFile(filePath);
if (!loadSceneFunc(_pRenderer.get(), _pScene.get(), filePath, _sceneContents))
{
::errorMessage("Unable to load the specified scene file: \"" + filePath + "\"");

Expand All @@ -1064,7 +1089,6 @@ bool Plasma::loadSceneFile(const string& filePath)
_instanceLayers = vector<Layers>(_sceneContents.instances.size());

// Record the new scene and update application state for the new scene.
_pScene = pScene;
updateNewScene();

// Report the load time.
Expand Down Expand Up @@ -1139,15 +1163,15 @@ Aurora::Path Plasma::loadMaterialXFile(const string& filePath)
processedMtlXString =
regex_replace(processedMtlXString, regex(R"(\.\.\/\.\.\/\.\.)"), mtlxResourcesPath);

// Create a new material from the materialX document.
// Create a new material from the MaterialX document.
_pScene->setMaterialType(
materialPath, Aurora::Names::MaterialTypes::kMaterialX, processedMtlXString);

return materialPath;
}
bool Plasma::applyMaterialXFile(const string& filePath)
{
// Create a new material from the materialX document.
// Create a new material from the MaterialX document.
Aurora::Path materialPath = loadMaterialXFile(filePath);
if (materialPath.empty())
{
Expand Down Expand Up @@ -1327,6 +1351,7 @@ void Plasma::onFilesDropped(HDROP hDrop)
}
else
{
addAssetPathContainingFile(filePath);
(*funcIt).second(filePath);
}
}
Expand Down Expand Up @@ -1482,8 +1507,8 @@ void Plasma::onKeyPressed(WPARAM keyCode)
}
else
{
_isOpaqueShadowsEnabled = !_isOpaqueShadowsEnabled;
options.setBoolean("isOpaqueShadowsEnabled", _isOpaqueShadowsEnabled);
_isForceOpaqueShadowsEnabled = !_isForceOpaqueShadowsEnabled;
options.setBoolean("isForceOpaqueShadowsEnabled", _isForceOpaqueShadowsEnabled);
requestUpdate();
}
break;
Expand Down Expand Up @@ -1515,7 +1540,7 @@ void Plasma::onKeyPressed(WPARAM keyCode)
adjustUnit(+1);
break;

// W: Add decal from materialX file.
// W: Add decal from MaterialX file.
case 0x57:
if (::GetAsyncKeyState(VK_CONTROL) != 0)
{
Expand Down
11 changes: 6 additions & 5 deletions Applications/Plasma/Plasma.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class Plasma
#if defined(INTERACTIVE_PLASMA)
static LRESULT __stdcall wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
#endif
static Aurora::IScenePtr createSampleScene(
Aurora::IRenderer* pRenderer, SceneContents& contentsOut);
static void createSampleScene(Aurora::IScene* pRenderer, SceneContents& contentsOut);

/*** Private Functions ***/

Expand Down Expand Up @@ -96,6 +95,8 @@ class Plasma
void saveImage(const wstring& filePath, const uvec2& dimensions);
bool applyMaterialXFile(const string& mtlxPath);
Aurora::Path loadMaterialXFile(const string& filePath);
void addAssetPath(const string& path);
void addAssetPathContainingFile(const string& filePath);

void resetMaterials();
bool addDecal(const string& decalMtlXPath);
Expand Down Expand Up @@ -139,9 +140,9 @@ class Plasma
vec3 _lightDirection = normalize(vec3(1.0f, -0.5f, 0.0f));
bool _isDenoisingEnabled = false;
#if defined(INTERACTIVE_PLASMA)
bool _isDiffuseOnlyEnabled = false;
bool _isOpaqueShadowsEnabled = false;
bool _isToneMappingEnabled = false;
bool _isDiffuseOnlyEnabled = false;
bool _isForceOpaqueShadowsEnabled = false;
bool _isToneMappingEnabled = false;
#endif
bool _isGroundPlaneShadowEnabled = false;
bool _isGroundPlaneReflectionEnabled = false;
Expand Down
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source build is not allowed!")
endif()

# See if USD was built with python.
find_library(USD_usdviewq_LIBRARY_RELEASE usd_usdviewq)
find_library(USD_usdviewq_LIBRARY_DEBUG usd_usdviewqd)
if(USD_usdviewq_LIBRARY_RELEASE OR USD_usdviewq_LIBRARY_DEBUG)
# iF USDView is found, then we know USD was built with python.
set(USD_BUILT_WITH_PYTHON "True")
message(STATUS "USD built with Python, system Python libraries required.")
endif()

# Set the project name and project variables
project(Aurora VERSION 23.07.0.0)
project(Aurora VERSION 24.03.0.0)

# Create a folder for the version header files
set(VERSION_FOLDER "${PROJECT_BINARY_DIR}/VersionFiles")
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
## Contributor License Agreement #
Before contributing code to this project, we ask that you sign the appropriate Contributor License Agreement (CLA):

+ [ADSKFormCorpContribAgmtForOpenSource.docx](Doc/CLA/ADSKFormCorpContribAgmtforOpenSource.docx?raw=1): please sign this one for corporate use.
+ [ADSKFormIndContribAgmtForOpenSource.docx](Doc/CLA/ADSKFormIndContribAgmtforOpenSource.docx?raw=1): please sign this one if you're an individual contributor
+ [ADSKFormCorpContribAgmtForOpenSource.docx](Doc/CLA/ADSKFormCorpContribAgmtforOpenSource.docx): please sign this one for corporate use.
+ [ADSKFormIndContribAgmtForOpenSource.docx](Doc/CLA/ADSKFormIndContribAgmtforOpenSource.docx): please sign this one if you're an individual contributor

The documents include instructions on where to send the completed forms. Once a signed form has been received you will be able to submit pull requests.
Return the completed form to [email protected]. Once a signed form has been received you will be able to submit pull requests.

Contributors are expected to follow the [Contributor Covenant](CODE_OF_CONDUCT.md), which describes the code of conduct for Autodesk open source projects like this one.

Expand Down Expand Up @@ -34,6 +34,6 @@ The Aurora project accepts and greatly appreciates contributions. The project fo

When contributing code, please also include appropriate tests as part of the pull request, and follow the published [coding standards](Doc/CodingStandards.md). In particular, use the same style as the code you are modifying.

All development should happen against the "main" (default) branch of the repository. Please make sure the base branch of your pull request is set to the "main" branch when filing your pull request.
Contributor pull requests should target the latest `contrib` branch of the repository, this will have a suffix of the latest released version, so contributions based on version v23.07 should target the `contrib/v23.07`. Please make sure the base branch of your pull request is set to the correct contrib branch when filing your pull request. Contributor pull requests that are accepted will be merged into the contrib branch and then included in the next Aurora release from there. They will be merged into the main branch along with any other changes for the next release.

It is highly recommended that an issue be logged on GitHub before any work is started. This will allow for early feedback from other developers and will help avoid duplicate effort.
Loading

0 comments on commit 3082b23

Please sign in to comment.