USD Materials

477 views
Skip to first unread message

aurora

unread,
Dec 10, 2022, 4:25:55 PM12/10/22
to gaffer-dev
Hello!
Any way to access USD Materials the in the Graph in the same way Nuke an Houdini does? Using Cycles Material from Blender. I can access the individual shader assigment from the Object Attributes, via Python, but cant see a way to access the actual material containing the shaders.
Thank you!
Nuke | Gaffer | Houdini
Screenshot from 2022-12-10 13-19-58.png

Sachin Shrestha

unread,
Dec 11, 2022, 1:11:34 AM12/11/22
to gaffe...@googlegroups.com
If you want to override the shaders, then you can use the ShaderTweaks node. There is a ShaderQuery node as well. You won’t be able to access the entire shader graph in node graph form but with these two nodes you should be able to do a lot.

-Sachin

--
You received this message because you are subscribed to the Google Groups "gaffer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gaffer-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gaffer-dev/96086ec6-59e6-4e5e-afba-445db6f629d3n%40googlegroups.com.

aurora

unread,
Dec 12, 2022, 2:12:57 AM12/12/22
to gaffer-dev
Thanks for the reply Sachin.

Shader Tweaks sounds great. Unfortunatelly Im having issues even getting the cycles shaders from my USD scene to render.
I am using Blender's USD branch, which allows for Cycles Shaders in USD exports. With Blender's default exports Gaffer complains about no been able to load the shader:

WARNING [IECoreCycles::ShaderNetworkAlgo] Couldn't load shader "cycles_principled_bsdf"

I manually modified the USD file to strip out the "cycles_" part of the attribute value so Gaffer has the correct shader types name.
That doesn't work either and the render throws this error:

WARNING [IECoreCycles::ShaderNetworkAlgo] Couldn't find socket output "bsdf" on shaderNode "shader:45dcac2f5b201101400570e099a58d78:Principled_BSDF"

Using a Shader querry node I can load the shader parameters, but I rather use python to recreate them.

Also, I can see the lights coming in, but they dont have any effect on the rendered image. Anything special I need to do to make them work?

I am attaching test files, including blender file, USDAs (natively exported and modified) and my .gfr script.

cycles_usd_test.zip

Thank you for any tips.

A

John Haddon

unread,
Dec 12, 2022, 6:10:13 AM12/12/22
to gaffe...@googlegroups.com
On Mon, Dec 12, 2022 at 7:12 AM aurora <auro...@gmail.com> wrote:
I manually modified the USD file to strip out the "cycles_" part of the attribute value so Gaffer has the correct shader types name.

For our own USD export, we're using "cycles:" as the prefix on the shader type, since ":" seems to be the standard namespace separator in USD. The Cycles Hydra backend seems to be accepting either "cycles:" or "cycles_". Would be good to have some guidance as to which is right. I don't suppose you know why Blender chose one over the other?
 
That doesn't work either and the render throws this error:

WARNING [IECoreCycles::ShaderNetworkAlgo] Couldn't find socket output "bsdf" on shaderNode "shader:45dcac2f5b201101400570e099a58d78:Principled_BSDF"

This seems to be a case sensitivity issue. The Cycles API reports a name of "BSDF" (upper case) which is what we're using in GafferCycles. But the USD file has "bsdf" (lower case). There are also case mismatches for the "Distribution" and "Subsurface_Method" parameters. Do you know why Blender might write a USD file with inconsistent naming like this?

It would be easy enough for us to correct for the mismatch at render time (and it actually looks like the Cycles Hydra backend has a correction for it). But I think it would be preferable to fix it in the Blender exporter, so the data is consistent in the first place, and every single client doesn't need special-case handling.

Also, I can see the lights coming in, but they dont have any effect on the rendered image. Anything special I need to do to make them work?

We don't yet have support for translating UsdLux lights to Cycles. There's some work-in-progress towards that goal in https://github.com/GafferHQ/gaffer/pull/4936.

Cheers...
John

aurora

unread,
Dec 12, 2022, 3:37:50 PM12/12/22
to gaffer-dev
Thank you John.
I tried to change the case for the shader out[ut, but there are still some issues:
WARNING : IECoreCycles::ShaderNetworkAlgo : Couldn't find socket input "" on shaderNode "output"

Anyway, I may look into this project to see how they do it:
https://github.com/tangent-opensource/hdBlackbird
Cheers!
A

John Haddon

unread,
Dec 12, 2022, 6:24:59 PM12/12/22
to gaffe...@googlegroups.com
On Mon, Dec 12, 2022 at 8:37 PM aurora <auro...@gmail.com> wrote:
I tried to change the case for the shader out[ut, but there are still some issues:
WARNING : IECoreCycles::ShaderNetworkAlgo : Couldn't find socket input "" on shaderNode "output"

I think I've reproduced that here too (or something very similar), and this one is definitely a bug in GafferCycles. I'll try to find some time to get it sorted.

For the various case issues, I'm not completely opposed to adding workarounds in Gaffer, but I do think it'd be worth asking the Blender guys about it first. If it can be fixed once in Blender, that's better than everyone else working around it...

Cheers...
John

aurora

unread,
Dec 12, 2022, 6:54:06 PM12/12/22
to gaffer-dev
Agreed. The USD option of the version of blender I am using is actually  not merged into the main branch. The main branch doesn’t have the option to write Cycles shaders yet. So probaly not even being used by many artists at this point. Not sure when this feature is planned to come in. Hence why I want to look into the Houdini plugin I posted above.
Anyway, thanks for looking into this John. Probably good to consider all this just some good old experimentation.
Best
A

John Haddon

unread,
Dec 13, 2022, 4:01:14 AM12/13/22
to gaffe...@googlegroups.com
On Monday, December 12, 2022 at 3:24:59 PM UTC-8 John Haddon wrote:
On Mon, Dec 12, 2022 at 8:37 PM aurora <auro...@gmail.com> wrote:
I tried to change the case for the shader out[ut, but there are still some issues:
WARNING : IECoreCycles::ShaderNetworkAlgo : Couldn't find socket input "" on shaderNode "output"

I think I've reproduced that here too (or something very similar), and this one is definitely a bug in GafferCycles. I'll try to find some time to get it sorted.

I've fixed this specific problem in https://github.com/GafferHQ/gaffer/pull/5008. If you know the right place to open a discussion about the other bits with the Blender devs, let me know and I'll ask some questions...
Cheers...
John 

aurora

unread,
Dec 13, 2022, 11:20:36 AM12/13/22
to gaffer-dev
Thanks so much John

Alex Fuller

unread,
Dec 21, 2022, 7:10:19 PM12/21/22
to gaffer-dev
Hey that's pretty cool that there's a build of Blender which can already transport the shaders from Cycles to Gaffer via USD! I guess just don't try UsdGeomSubset assignments...

I also have USD preview surface and USD lux light conversion code here: https://github.com/boberfly/gaffer/tree/update/cyclesUSDLightShaders but I am currently stuck on a few things, like the HDRI not appearing that I need time to look into, as well as matching with other renderers and their interpretation of the lux lights eg. size/normalise/strength matching.

aurora

unread,
Dec 21, 2022, 7:57:57 PM12/21/22
to gaffer-dev
Yeah. Will be great when it finally works. I am not sure if the feature in the Blender branch will make it to the Master. I also read somewhere that this may be a better approach: https://github.com/GPUOpen-LibrariesAndSDKs/BlenderUSDHydraAddon and that it may be possible that will get into one of the upcoming Blender versions.
Reply all
Reply to author
Forward
0 new messages