WIP: MaterialX: Implement Script node #113341

Draft
Georgiy Markelov wants to merge 5 commits from DagerD/blender:matx-add-script-node into main

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

Purpose

Implement conversion for Script node

Technical steps

Implemented conversion for Script node

Ref: #112864

### Purpose Implement conversion for Script node ### Technical steps Implemented conversion for Script node Ref: https://projects.blender.org/blender/blender/issues/112864
Georgiy Markelov added 3 commits 2023-10-06 13:00:20 +02:00
Georgiy Markelov requested review from Bogdan Nagirniak 2023-10-06 13:00:31 +02:00
Georgiy Markelov requested review from Vasyl Pidhirskyi 2023-10-06 13:00:31 +02:00
Bogdan Nagirniak requested changes 2023-10-06 14:06:31 +02:00
@ -66,0 +74,4 @@
/* Look for first script node with assigned file.
* If it's found, we load content and ignore everything other. */
LISTBASE_FOREACH (bNode *, node, &material->nodetree->nodes) {
if (node->typeinfo->type == SH_NODE_SCRIPT) {
Contributor

move this part with if to separate function

move this part with `if` to separate function
DagerD marked this conversation as resolved
@ -66,0 +102,4 @@
Text *text = reinterpret_cast<Text *>(node->id);
if (text) {
script_found = true;
std::string text_content;
Contributor

Seem std::stringstream suits better here.

Seem `std::stringstream` suits better here.
DagerD marked this conversation as resolved
@ -66,2 +126,3 @@
bNode *output_node = ntreeShaderOutputNode(material->nodetree, SHD_OUTPUT_ALL);
if (output_node) {
if (output_node && !script_found) {
Contributor

Should be

if (!script_found) {
....

Otherwise else block will beexecuted

Should be ``` if (!script_found) { .... ``` Otherwise `else` block will beexecuted
DagerD marked this conversation as resolved
Georgiy Markelov added 1 commit 2023-10-06 17:08:59 +02:00
Georgiy Markelov requested review from Bogdan Nagirniak 2023-10-06 17:09:40 +02:00
Georgiy Markelov requested review from Brian Savery (AMD) 2023-10-06 17:10:12 +02:00
Bogdan Nagirniak requested changes 2023-10-06 20:58:50 +02:00
@ -57,0 +72,4 @@
if (node->typeinfo->type == SH_NODE_SCRIPT) {
NodeShaderScript *script = static_cast<NodeShaderScript *>(node->storage);
if (script->mode == NODE_SCRIPT_EXTERNAL) {
if (script->filepath[0] != '\0') {
Contributor

Use explicit STREQ(script->filepath, "")

Use explicit `STREQ(script->filepath, "")`
DagerD marked this conversation as resolved
@ -57,0 +92,4 @@
material->id.name,
node->name);
}
break;
Contributor

I think no need to use script_found just return true here

I think no need to use `script_found` just `return true` here
DagerD marked this conversation as resolved
@ -87,0 +138,4 @@
* If it's found, we load content and ignore everything other. */
script_found = export_script_node(doc, depsgraph, material);
if (!script_found) {
Contributor

if (!export_script_node(doc, depsgraph, material)) {

`if (!export_script_node(doc, depsgraph, material)) {`
DagerD marked this conversation as resolved
Georgiy Markelov added 1 commit 2023-10-09 11:12:24 +02:00
Bogdan Nagirniak approved these changes 2023-10-09 17:25:28 +02:00
Bogdan Nagirniak left a comment
Contributor

Tested - works good

Tested - works good
Georgiy Markelov requested review from Brecht Van Lommel 2023-10-09 17:25:42 +02:00
Brecht Van Lommel requested changes 2023-10-09 17:54:04 +02:00
Brecht Van Lommel left a comment
Owner

I thought a script node would work like the existing ones, where it gets inputs and outputs that you connect to other things. If it's just using the first script node in the shader graph and ignores everything else, it doesn't seem like that functionality should be a node at all.

This sounds more like it sound be a material wide property that disables the node graph for that material. And then later it could support viewing and editing the contents of the MaterialX file in Blender.

I thought a script node would work like the existing ones, where it gets inputs and outputs that you connect to other things. If it's just using the first script node in the shader graph and ignores everything else, it doesn't seem like that functionality should be a node at all. This sounds more like it sound be a material wide property that disables the node graph for that material. And then later it could support viewing and editing the contents of the MaterialX file in Blender.
Georgiy Markelov changed title from MaterialX: Implement Script node to WIP: MaterialX: Implement Script node 2023-10-11 15:31:31 +02:00
Author
Member

Yes, your proposal looks better, need to investigate more this task, set to WIP.

Yes, your proposal looks better, need to investigate more this task, set to WIP.
This pull request has changes conflicting with the target branch.
  • source/blender/nodes/shader/materialx/material.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u matx-add-script-node:DagerD-matx-add-script-node
git checkout DagerD-matx-add-script-node
Sign in to join this conversation.
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
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#113341
No description provided.