forked from blender/blender
BLEN-326: Pass MaterialX to Hydra via hdMaterialNetwork #5
No reviewers
Labels
No Label
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: BogdanNagirniak/blender#5
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "George-Shakula/blender:mtlx-translation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
These changes require USD to be built with the usdMtlx module. Right now, pre-built USD stored on the blender's svn is built without it. @BogdanNagirniak do you see how to deal with that?
Here's how RPR delegate renders a sample scene with these changes:
Storm does not work correctly. I'm going to push fixes for Storm in a separate PR because they are unrelated to the mtlx integration.
e74c9496fc
to504e22c3f0
504e22c3f0
tocaf8d35795
Also, I forgot to mention that the latest USD expects the 1.38.4 MaterialX library. At the same time, Blender's prebuilt libraries hosted on an SVN repository contain the 1.38.6 MaterialX library. So we need not only to build USD with usdMtlx for this PR to work but also to downgrade the MaterialX library or update USD to use the latest MaterialX.
caf8d35795
to634cf7f9e3
Code style has been fixed
634cf7f9e3
to2f5f8e5e83
Hi.
I will try to build USD with usdMtlx module and test how it works.
@DagerD in order for it to work, USD must be built with usd.diff from this PR applied. It requires 1.38.6 MaterialX (the one Blender already targets).
@ -26,3 +26,3 @@
void mark_prim_dirty(DirtyBits dirty_bits) override;
pxr::VtValue material_resource();
pxr::VtValue material_resource(pxr::HdSceneDelegate *scene_delegate);
scene_delegate
is already available in MaterialData from IdData@ -0,0 +14,4 @@
struct HdMaterialNetworkMap;
void HdMtlxConvertToMaterialNetworkMap(std::string const &mtlxPath,
Can we move this function into MaterialData class as method?
Yes, we can. One of the reasons it is in a separate file is that Brian wanted to have this feature separated from anything else for convenient sharing with others. By keeping it in its own files we ensure this is easily relocatable and not obscured by anything else.
I see, ok
Material works for HdRPR. Please check warnings (both for HdRPR and HdStorm).
@ -86,4 +86,17 @@ set(LIB
blender_add_lib(bf_render_hydra "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
if(TARGET MaterialXCore AND TARGET MaterialXFormat)
We expect that MaterialX is enabled for hydra_render project. Can be removed.
@ -0,0 +64,4 @@
std::string stageId = TfStringPrintf(
"%s%s%s.usda", basePath.c_str(), ARCH_PATH_SEP, mtlxName.c_str());
auto stage = UsdStage::CreateInMemory(stageId, context);
if (_Read(stage, [&mtlxPath]() { return UsdMtlxReadDocument(mtlxPath); })) {
This part with
_Read()
and lambda function is hard to maintain in future + used in one place, can you move it content of_Read
here.@ -0,0 +69,4 @@
if (UsdPrimSiblingRange children = materials.GetChildren()) {
if (auto material = UsdShadeMaterial(
*children.begin())) { // TODO: specify which material to use from the mtlx
if (UsdShadeShader mtlxSurface = material.ComputeSurfaceSource(renderContexts)) {
Change construction
if (...) if (...) ....
toif (!...) return; if (!...) return
as more understandable and easier to maintain.As soon as I set
PXR_MTLX_STDLIB_SEARCH_PATHS
environment variable, these warnings wanish. This leads to a conclusion that either this env var was not set properly while testing the PR or there is some other problem. I would start from embedding this env var into blender.USD code expects this environment variable to be set if the MaterialX/libraries folder used at the time of compilation is moved to different folder. This is always the case for us because our build is obviously can be installed anywhere.