BLEN-326: Pass MaterialX to Hydra via hdMaterialNetwork #5

Merged
Bogdan Nagirniak merged 4 commits from George-Shakula/blender:mtlx-translation into hydra-render 2023-03-02 12:35:51 +01:00
4 changed files with 11 additions and 22 deletions
Showing only changes of commit 54f1e1d930 - Show all commits

View File

@ -794,7 +794,7 @@ set(POSTCONFIGURE_SCRIPT "" CACHE FILEPATH "Run given CMake script as the last s
mark_as_advanced(POSTCONFIGURE_SCRIPT)
# USD Hydra plugin.
if(WIN32 AND WITH_USD)
if(WIN32 AND WITH_USD AND WITH_MATERIALX)
option(WITH_HYDRA "Enable USD Hydra plugin" ON)
endif()

View File

@ -1,6 +1,10 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2011-2022 Blender Foundation
if(NOT TARGET MaterialXCore OR NOT TARGET MaterialXFormat)
message(FATAL_ERROR "Hydra Scene Delegate requires MaterialX")
endif()
if(WIN32)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -DBOOST_DEBUG_PYTHON)
endif()
@ -70,6 +74,8 @@ set(SRC
sceneDelegate/material.cc
sceneDelegate/mesh.h
sceneDelegate/mesh.cc
sceneDelegate/mtlxHydraAdapter.h
sceneDelegate/mtlxHydraAdapter.cc
sceneDelegate/light.h
sceneDelegate/light.cc
sceneDelegate/world.h
@ -86,17 +92,8 @@ set(LIB
blender_add_lib(bf_render_hydra "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
if(TARGET MaterialXCore AND TARGET MaterialXFormat)
target_sources(bf_render_hydra PRIVATE
sceneDelegate/mtlxHydraAdapter.h
sceneDelegate/mtlxHydraAdapter.cc)
target_compile_definitions(bf_render_hydra PRIVATE
_MTLX_TRANSLATION_ENABLED)
target_link_libraries(bf_render_hydra PRIVATE
target_link_libraries(bf_render_hydra PRIVATE
MaterialXCore
MaterialXFormat)
else()
message(WARN "Compiling Hydra Scene Delegate without MaterialX-to-Hydra translation")
endif()
add_dependencies(bf_render_hydra bf_rna)

View File

@ -51,7 +51,6 @@ VtValue MaterialData::get_data(TfToken const &key)
pxr::VtValue MaterialData::material_resource()
{
#if defined(_MTLX_TRANSLATION_ENABLED)
std::string const &path = mtlx_path.GetResolvedPath();
if (!path.empty()) {
HdRenderDelegate *render_delegate = scene_delegate->GetRenderIndex().GetRenderDelegate();
@ -63,9 +62,6 @@ pxr::VtValue MaterialData::material_resource()
path, shader_source_types, render_contexts, &material_network_map);
return VtValue(material_network_map);
}
#else
# pragma message("Compiling without MaterialX translation")
#endif
return pxr::VtValue();
}

View File

@ -3,12 +3,10 @@
#pragma once
#if defined(_MTLX_TRANSLATION_ENABLED)
#include <pxr/base/tf/token.h>
#include <pxr/pxr.h>
# include <pxr/base/tf/token.h>
# include <pxr/pxr.h>
# include <string>
#include <string>
PXR_NAMESPACE_OPEN_SCOPE
@ -20,5 +18,3 @@ void HdMtlxConvertToMaterialNetworkMap(std::string const &mtlxPath,
HdMaterialNetworkMap *out);
PXR_NAMESPACE_CLOSE_SCOPE
#endif // _MTLX_TRANSLATION_ENABLED