NPR: Shader Node Traits #130192

Merged
Miguel Pozo merged 4 commits from pragma37/blender:npr-shader-node-traits into npr-prototype 2024-11-14 15:45:56 +01:00
Member

The NPR branch needs a way to tell whether the node tree is a group or an NPR tree for correct polling in the UI.
This follows a similar approach to GeometryNodeAssetTraits.

There's still the problem that any node group can still be added to any shader tree type (for example, it's possible to add a Material node group to a World node tree).
This trait system could eventually be used to detect which node groups have tree-type-specific nodes and allow adding them only to compatible trees.

The NPR branch needs a way to tell whether the node tree is a group or an NPR tree for correct polling in the UI. This follows a similar approach to `GeometryNodeAssetTraits`. There's still the problem that any node group can still be added to any shader tree type (for example, it's possible to add a Material node group to a World node tree). This trait system could eventually be used to detect which node groups have tree-type-specific nodes and allow adding them only to compatible trees.
Miguel Pozo added 4 commits 2024-11-12 20:22:57 +01:00

It is too bad that instead of just use bNodeTreeType to different kinds of node trees in general there is another one kind of tree typing just to different shader node trees...

It is too bad that instead of just use `bNodeTreeType` to different kinds of node trees in general there is another one kind of tree typing just to different shader node trees...
Iliya Katushenock added this to the Nodes & Physics project 2024-11-12 20:27:01 +01:00
Author
Member

For now this is an npr-prototype-only thing, but I would appreciate a quick look from @JacquesLucke or @HooglyBoogly, to ensure I'm not doing anything terrible.

For now this is an `npr-prototype`-only thing, but I would appreciate a quick look from @JacquesLucke or @HooglyBoogly, to ensure I'm not doing anything terrible.
Miguel Pozo removed this from the Nodes & Physics project 2024-11-12 20:28:06 +01:00
Author
Member

It is too bad that instead of just use bNodeTreeType to different kinds of node trees in general there is another one kind of tree typing just to different shader node trees...

Geometry nodes work the same way. 🤔
We still need a way to share shader node groups between different shader tree types, so I'm not sure different bNodeTreeTypes would make things better.

In any case that would require a huge refactor that is out of the goals of the NPR prototype.

> It is too bad that instead of just use bNodeTreeType to different kinds of node trees in general there is another one kind of tree typing just to different shader node trees... Geometry nodes work the same way. 🤔 We still need a way to share shader node groups between different shader tree types, so I'm not sure different `bNodeTreeType`s would make things better. In any case that would require a huge refactor that is out of the goals of the NPR prototype.

Just to make sure, nodes use only bNodeType::poll to check if node group/separate built-in node can be placed in some node tree or not. Assets traits (geometry_node_asset_traits) is the way to say if geometry node tree can be runned as modifier/tool/operator/... . So this is like RenderTime/BakeTime shader difference. This mainly used by drag and drop and asset browser rahter then node editor.

Just to make sure, nodes use only `bNodeType::poll` to check if node group/separate built-in node can be placed in some node tree or not. Assets traits (`geometry_node_asset_traits`) is the way to say if geometry node tree can be runned as modifier/tool/operator/... . So this is like `RenderTime`/`BakeTime` shader difference. This mainly used by drag and drop and asset browser rahter then node editor.
Jacques Lucke reviewed 2024-11-12 23:17:13 +01:00
Jacques Lucke left a comment
Member

Overall, it seems like this approach could work, but it's not obvious to me that this is the right way to go yet.
I don't have a fully formed opinion on it yet, sry.

It would be quite nice to reduce the different tree types we have instead of creating more different kinds, but we don't know how to do that exactly yet.

Overall, it seems like this approach could work, but it's not obvious to me that this is the right way to go yet. I don't have a fully formed opinion on it yet, sry. It would be quite nice to reduce the different tree types we have instead of creating more different kinds, but we don't know how to do that exactly yet.
@ -1259,6 +1259,20 @@ void do_versions_after_linking_400(FileData *fd, Main *bmain)
version_legacy_actions_to_layered(bmain);
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 404, 6)) {
Member

Seems like the versioning code should also initialize the type for all the node trees embedded in materials, world, etc?

Seems like the versioning code should also initialize the type for all the node trees embedded in materials, world, etc?
Author
Member

This already happens in the node_tree_set_type call from ntree_blend_read_after_liblink, which runs before do_versions_after_linking.

This already happens in the `node_tree_set_type` call from `ntree_blend_read_after_liblink`, which runs before `do_versions_after_linking`.
JacquesLucke marked this conversation as resolved
Author
Member

Overall, it seems like this approach could work, but it's not obvious to me that this is the right way to go yet.
I don't have a fully formed opinion on it yet, sry.

Ok, that's fine, this doesn't have to be the final design.
I mainly wanted to know if you saw something that could explode badly.
We still have plenty of time until we start looking into merging NPR features into main.

It would be quite nice to reduce the different tree types we have instead of creating more different kinds, but we don't know how to do that exactly yet.

As long as we have different contexts where some nodes are supported and others aren't we need some kind of classification.
At best we can "implement" them as no-ops so at least shaders compile, but there's no meaningful way to support the Principled BSDF in the World shader, for example.

>Overall, it seems like this approach could work, but it's not obvious to me that this is the right way to go yet. >I don't have a fully formed opinion on it yet, sry. Ok, that's fine, this doesn't have to be the final design. I mainly wanted to know if you saw something that could explode badly. We still have plenty of time until we start looking into merging NPR features into main. >It would be quite nice to reduce the different tree types we have instead of creating more different kinds, but we don't know how to do that exactly yet. As long as we have different contexts where some nodes are supported and others aren't we need some kind of classification. At best we can "implement" them as no-ops so at least shaders compile, but there's no meaningful way to support the Principled BSDF in the World shader, for example.

It would be quite nice to reduce the different tree types we have instead of creating more different kinds, but we don't know how to do that exactly yet.

As long as we have different contexts where some nodes are supported and others aren't we need some kind of classification.
At best we can "implement" them as no-ops so at least shaders compile, but there's no meaningful way to support the Principled BSDF in the World shader, for example.

I mean you can do the same thing in flat list of types and in type system where each type have some its internal property, only used by it,, it is only about generalization of the code to maintain\

> >It would be quite nice to reduce the different tree types we have instead of creating more different kinds, but we don't know how to do that exactly yet. > As long as we have different contexts where some nodes are supported and others aren't we need some kind of classification. > At best we can "implement" them as no-ops so at least shaders compile, but there's no meaningful way to support the Principled BSDF in the World shader, for example. I mean you can do the same thing in flat list of types and in type system where each type have some its internal property, only used by it,, it is only about generalization of the code to maintain\
Miguel Pozo merged commit 30a526a183 into npr-prototype 2024-11-14 15:45:56 +01:00
Miguel Pozo referenced this issue from a commit 2024-11-14 15:45:57 +01:00
Miguel Pozo deleted branch npr-shader-node-traits 2024-11-14 15:46:00 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
3 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#130192
No description provided.