Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default nodes when creating a new node tree using new_engine_node_tree #737

Merged
merged 6 commits into from
Mar 31, 2024

Conversation

GottfriedHofmann
Copy link
Contributor

When creating new node trees, usually a functional minimal sample of a node tree is already created (Eevee, Cycles, Geometry Nodes, Compositor Nodes). This is not possible directly when the node tree type is defined via Python but Dream Textures has a secondardy operator new_engine_node_tree that is exposed in the render engine settings. Using this operator, we can simulate the default Blender behavior.

For the default nodes, I have selected Stable Diffusion and Output because they are the bare minimum render properties because that way the user will not run into the error of resolution mismatch between render engine and the stable diffusion output.

grafik

… the minimum required nodes and synchronize open editors
engine/engine.py Outdated
node_sd.location = (200, 200)
node_out = node_tree.nodes.new(type="NodeGroupOutput")
node_out.location = (400, 200)
node_tree.links.new(node_sd.outputs['Image'], node_out.inputs[''])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this connects the image to the virtual socket on the Group Output. You might need to add an image socket to it first, then link to that socket.

Copy link
Contributor Author

@GottfriedHofmann GottfriedHofmann Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It worked without but of course it should reflect what the user would get if they did it themselves so adding a color socket first is the cleaner solution for sure 👍🏻
grafik

Copy link
Owner

@carson-katri carson-katri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small suggestion to simplify the new tree lookup.

engine/engine.py Outdated
node_sd = node_tree.nodes.new(type="dream_textures.node_stable_diffusion")
node_sd.location = (200, 200)
node_out = node_tree.nodes.new(type="NodeGroupOutput")
node_tree.outputs.new('NodeSocketColor','Image')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this before, outputs and inputs were removed in Blender 4. Could you add a check here for the bpy.app.version, and in Blender 4.0 use the .interface.new_socket(...) API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to latest iteration but was not able to test yet.

@carson-katri carson-katri merged commit 454e994 into carson-katri:main Mar 31, 2024
@GottfriedHofmann GottfriedHofmann deleted the defaultnodes branch May 8, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants