USD: Export Cycles Shader networks as USD material networks. #119180

Open
Charles Wardlaw wants to merge 5 commits from CharlesWardlaw/blender:feature/usd_cycles_shaders into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

By default the networks are not exported, but are available now as an option on the export operator.

This is only the Export side of this patch, but it should allow for the HDCycles delegate to pick up these networks for rendering.

By default the networks are not exported, but are available now as an option on the export operator. This is only the Export side of this patch, but it should allow for the HDCycles delegate to pick up these networks for rendering.
Charles Wardlaw added 1 commit 2024-03-07 20:09:05 +01:00
5b66a37c5e USD: Export Cycles Shader networks as USD material networks.
By default the networks are not exported, but are available now as an option on the export operator.
Charles Wardlaw requested review from Michael Kowalski 2024-03-07 20:09:24 +01:00
Charles Wardlaw added the
Interest
USD
label 2024-03-07 20:09:32 +01:00
Charles Wardlaw added this to the Pipeline, Assets & IO project 2024-03-07 20:09:39 +01:00
Charles Wardlaw modified the project from Pipeline, Assets & IO to USD 2024-03-07 20:09:45 +01:00
Charles Wardlaw self-assigned this 2024-03-07 20:09:56 +01:00
Charles Wardlaw added 1 commit 2024-03-07 20:10:40 +01:00
Charles Wardlaw added 2 commits 2024-03-07 23:53:16 +01:00
Michael Kowalski reviewed 2024-03-07 23:58:20 +01:00
@ -90,1 +111,4 @@
static const pxr::TfToken bsdf("bsdf", pxr::TfToken::Immortal);
static const pxr::TfToken closure("closure", pxr::TfToken::Immortal);
static const pxr::TfToken vector("vector", pxr::TfToken::Immortal);
} // namespace cyclestokens

I believe the cyclestokens can be removed as they are used in usd_writer_cycles.cc.

I believe the `cyclestokens` can be removed as they are used in `usd_writer_cycles.cc`.
CharlesWardlaw marked this conversation as resolved
Charles Wardlaw added 1 commit 2024-03-08 00:42:59 +01:00

The shader node export code is not very generic, it requires work to maintain this as we add or change nodes. If we are going to have to maintain this going forward, I would look to have a good use case for this, and at the moment it's not clear to me who this is for.

By itself it's not that useful to be able to export to a USD file and then only render that in HdCycles, since you could have just rendered from Blender directly. If there was some way to edit these outside of Blender it could make some sense, but I don't know of concrete plans for someone to make a good editor for that?

So I would like to better understand which concrete use cases this is meant to address.

The shader node export code is not very generic, it requires work to maintain this as we add or change nodes. If we are going to have to maintain this going forward, I would look to have a good use case for this, and at the moment it's not clear to me who this is for. By itself it's not that useful to be able to export to a USD file and then only render that in HdCycles, since you could have just rendered from Blender directly. If there was some way to edit these outside of Blender it could make some sense, but I don't know of concrete plans for someone to make a good editor for that? So I would like to better understand which concrete use cases this is meant to address.

@brecht I suppose another option might be to implement Cycles to USD conversion as a Python export hook, but I haven't thought through all the pros and cons of doing it that way.

@brecht I suppose another option might be to implement Cycles to USD conversion as a Python export hook, but I haven't thought through all the pros and cons of doing it that way.

But can you explain who this functionality is for, in which workflow it is useful? As in, are there real world cases where people are using Cycles shader nodes in other software, or planning to do so?

But can you explain who this functionality is for, in which workflow it is useful? As in, are there real world cases where people are using Cycles shader nodes in other software, or planning to do so?
First-time contributor

Hi @brecht , we are a 30 people studio that use primarily Blender and Houdini, since a few months back we've been starting to adopt Gaffer, this was a no brainier since it now uses Cycles, we developed our own python exporter to be able to write cycles materials, but it is less than ideal.
What I've seen so far is that the user profile that gets exposure to Cycles in the Gaffer community brings a complementary perspective that I feel benefits Cycles, everything that makes Cycles more accessible from outside independently to Blender I think is just going to push this amazing tool forward in ways that are not evident inside the Blender bubble.

Answering your question more concretely, for us it would be super useful to be able to pull Cycles materials from a USD file to convert the materials to Gaffer (for this I think Alex Fuller proposed a schema ), I know there is software in development right now which uses Cycles and it would also be useful among other things to make bridges or translators to look dev apps, painting apps, etc.

Hi @brecht , we are a 30 people studio that use primarily Blender and Houdini, since a few months back we've been starting to adopt Gaffer, this was a no brainier since it now uses Cycles, we developed our own python exporter to be able to write cycles materials, but it is less than ideal. What I've seen so far is that the user profile that gets exposure to Cycles in the Gaffer community brings a complementary perspective that I feel benefits Cycles, everything that makes Cycles more accessible from outside independently to Blender I think is just going to push this amazing tool forward in ways that are not evident inside the Blender bubble. Answering your question more concretely, for us it would be super useful to be able to pull Cycles materials from a USD file to convert the materials to Gaffer (for this I think Alex Fuller proposed a schema ), I know there is software in development right now which uses Cycles and it would also be useful among other things to make bridges or translators to look dev apps, painting apps, etc.
First-time contributor

We'd also find this useful at our workplace.

We have some folk using houdini+hdcycles, others using vanilla blender, and others running hdcycles via usd python. We keep getting surprised that although we're all targeting the same renderer (cycles vs hdcycles hair splitting aside), its not easy for us to share materials.

Right now the solution is very manual; get blender and houdini open side by side, and if we manually replicate material nodes one by one we can get something working. I'd planned to write a little script to speed this up, but if this functionality already exists there's no point reinventing the wheel!

For us its also about the being able to use the best tool for the job. Houdini and hdycles is better for procedural shot building. Blender is better for interactive lookdev for artists. Usd and python is better for developers and pipeline/farm focused workflows. Being able to fluidly move cycles materials between those 3 use cases would hugely boost our productivity.

As an aside while materialx sounds great, its still feels at least a year or two away from being production ready, vs moving this feature from the usd branch and into the main blender line would help with production issues right now.

We'd also find this useful at our workplace. We have some folk using houdini+hdcycles, others using vanilla blender, and others running hdcycles via usd python. We keep getting surprised that although we're all targeting the same renderer (cycles vs hdcycles hair splitting aside), its not easy for us to share materials. Right now the solution is very manual; get blender and houdini open side by side, and if we manually replicate material nodes one by one we can get something working. I'd planned to write a little script to speed this up, but if this functionality already exists there's no point reinventing the wheel! For us its also about the being able to use the best tool for the job. Houdini and hdycles is better for procedural shot building. Blender is better for interactive lookdev for artists. Usd and python is better for developers and pipeline/farm focused workflows. Being able to fluidly move cycles materials between those 3 use cases would hugely boost our productivity. As an aside while materialx sounds great, its still feels at least a year or two away from being production ready, vs moving this feature from the usd branch and into the main blender line would help with production issues right now.

Ok, good to know there are some real world users for this.

However the implementation should be easier to maintain, I don't think we would accept something that is structured like this. Adding a shader node to Blender currently requires changing many files, we are trying to reduce that and this would go in the opposite direction.

Ideally we'd have a situation where conversions Blender -> Cycles, Blender -> USD, USD -> Cycles, , USD -> Blender are just dealing with generic nodes and data types, rather than each needing to be updated whenever a node is added or changed.

We could change the Cycles sockets to better match Blender sockets, properties and enum items (we rather not change the latter for blend file and API compatibility). There can be some generic method to loop over the relevant RNA properties on the Blender node.

When a node needs specialized code should also be handled through a callback on the node type info, see the way this was done for MaterialX.

Ok, good to know there are some real world users for this. However the implementation should be easier to maintain, I don't think we would accept something that is structured like this. Adding a shader node to Blender currently requires changing many files, we are trying to reduce that and this would go in the opposite direction. Ideally we'd have a situation where conversions Blender -> Cycles, Blender -> USD, USD -> Cycles, , USD -> Blender are just dealing with generic nodes and data types, rather than each needing to be updated whenever a node is added or changed. We could change the Cycles sockets to better match Blender sockets, properties and enum items (we rather not change the latter for blend file and API compatibility). There can be some generic method to loop over the relevant RNA properties on the Blender node. When a node needs specialized code should also be handled through a callback on the node type info, see the way this was done for MaterialX.
First-time contributor

Right now we loop through all the nodes and write them to a USD file and then solve discrepancies with an importer on the other side, it is slow and in very few cases prone to errors but gets the job done.

Right now we loop through all the nodes and write them to a USD file and then solve discrepancies with an importer on the other side, it is slow and in very few cases prone to errors but gets the job done.
This pull request has changes conflicting with the target branch.
  • source/blender/editors/io/io_usd.cc
  • source/blender/io/usd/intern/usd_writer_material.cc
  • source/blender/io/usd/usd.hh

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u feature/usd_cycles_shaders:CharlesWardlaw-feature/usd_cycles_shaders
git checkout CharlesWardlaw-feature/usd_cycles_shaders
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#119180
No description provided.