forked from blender/blender
BLEN-326: Pass MaterialX to Hydra via hdMaterialNetwork #5
@ -794,7 +794,7 @@ set(POSTCONFIGURE_SCRIPT "" CACHE FILEPATH "Run given CMake script as the last s
|
|||||||
mark_as_advanced(POSTCONFIGURE_SCRIPT)
|
mark_as_advanced(POSTCONFIGURE_SCRIPT)
|
||||||
|
|
||||||
# USD Hydra plugin.
|
# USD Hydra plugin.
|
||||||
if(WIN32 AND WITH_USD)
|
if(WIN32 AND WITH_USD AND WITH_MATERIALX)
|
||||||
option(WITH_HYDRA "Enable USD Hydra plugin" ON)
|
option(WITH_HYDRA "Enable USD Hydra plugin" ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# Copyright 2011-2022 Blender Foundation
|
# Copyright 2011-2022 Blender Foundation
|
||||||
|
|
||||||
|
if(NOT TARGET MaterialXCore OR NOT TARGET MaterialXFormat)
|
||||||
|
message(FATAL_ERROR "Hydra Scene Delegate requires MaterialX")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -DBOOST_DEBUG_PYTHON)
|
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -DBOOST_DEBUG_PYTHON)
|
||||||
endif()
|
endif()
|
||||||
@ -70,6 +74,8 @@ set(SRC
|
|||||||
sceneDelegate/material.cc
|
sceneDelegate/material.cc
|
||||||
sceneDelegate/mesh.h
|
sceneDelegate/mesh.h
|
||||||
sceneDelegate/mesh.cc
|
sceneDelegate/mesh.cc
|
||||||
|
sceneDelegate/mtlxHydraAdapter.h
|
||||||
|
sceneDelegate/mtlxHydraAdapter.cc
|
||||||
sceneDelegate/light.h
|
sceneDelegate/light.h
|
||||||
sceneDelegate/light.cc
|
sceneDelegate/light.cc
|
||||||
sceneDelegate/world.h
|
sceneDelegate/world.h
|
||||||
@ -86,17 +92,8 @@ set(LIB
|
|||||||
|
|
||||||
blender_add_lib(bf_render_hydra "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
blender_add_lib(bf_render_hydra "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||||
|
|
||||||
if(TARGET MaterialXCore AND TARGET MaterialXFormat)
|
target_link_libraries(bf_render_hydra PRIVATE
|
||||||
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
|
|
||||||
MaterialXCore
|
MaterialXCore
|
||||||
MaterialXFormat)
|
MaterialXFormat)
|
||||||
else()
|
|
||||||
message(WARN "Compiling Hydra Scene Delegate without MaterialX-to-Hydra translation")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_dependencies(bf_render_hydra bf_rna)
|
add_dependencies(bf_render_hydra bf_rna)
|
||||||
|
@ -51,7 +51,6 @@ VtValue MaterialData::get_data(TfToken const &key)
|
|||||||
|
|
||||||
pxr::VtValue MaterialData::material_resource()
|
pxr::VtValue MaterialData::material_resource()
|
||||||
{
|
{
|
||||||
#if defined(_MTLX_TRANSLATION_ENABLED)
|
|
||||||
std::string const &path = mtlx_path.GetResolvedPath();
|
std::string const &path = mtlx_path.GetResolvedPath();
|
||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
HdRenderDelegate *render_delegate = scene_delegate->GetRenderIndex().GetRenderDelegate();
|
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);
|
path, shader_source_types, render_contexts, &material_network_map);
|
||||||
return VtValue(material_network_map);
|
return VtValue(material_network_map);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# pragma message("Compiling without MaterialX translation")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return pxr::VtValue();
|
return pxr::VtValue();
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(_MTLX_TRANSLATION_ENABLED)
|
#include <pxr/base/tf/token.h>
|
||||||
|
#include <pxr/pxr.h>
|
||||||
|
|
||||||
# include <pxr/base/tf/token.h>
|
#include <string>
|
||||||
# include <pxr/pxr.h>
|
|
||||||
|
|
||||||
# include <string>
|
|
||||||
|
|
||||||
PXR_NAMESPACE_OPEN_SCOPE
|
PXR_NAMESPACE_OPEN_SCOPE
|
||||||
|
|
||||||
@ -20,5 +18,3 @@ void HdMtlxConvertToMaterialNetworkMap(std::string const &mtlxPath,
|
|||||||
HdMaterialNetworkMap *out);
|
HdMaterialNetworkMap *out);
|
||||||
|
|
||||||
PXR_NAMESPACE_CLOSE_SCOPE
|
PXR_NAMESPACE_CLOSE_SCOPE
|
||||||
|
|
||||||
#endif // _MTLX_TRANSLATION_ENABLED
|
|
||||||
|
Loading…
Reference in New Issue
Block a user