How to set a custom color for a node?
-
It's me again!
I'm wondering if there is an example to explain how we can use a custom color for a node? the nodes are grey by default but we can change their color
-
Hi @momoko,
You should take a look at create_redshift_nodematerial_2024.py, I will show you a custom and easier solution with Renderer lib, see codes[1], you can check how it works but you must have a basic understanding of Node Graph.
And if you use c4d above 2024.3.0, you are highly suggested to look Graph Description Manual , see codes[2]
Cheers~
DunHouimport c4d, maxon from Renderer import Redshift,EasyTransaction def main() -> None: material: c4d.BaseMaterial = Redshift.Material("MyMaterial") with EasyTransaction(material) as tr: surface = tr.GetRootBRDF() tr.SetShaderValue( surface, "com.redshift3d.redshift4c4d.nodes.core.standardmaterial.base_color" , maxon.Vector(1,0,0) ) tr.InsertMaterial() if __name__ == '__main__': main()
import maxon from maxon import GraphDescription GraphDescription.ApplyDescription( GraphDescription.CreateGraph(name="Basic Example"), { GraphDescription.Type: "Output", "Surface": { GraphDescription.Type: "Standard Material", "Base/Color": maxon.Vector(1, 0, 0), } } )
-
@Dunhou Thanks but I mean the color of the node itself, not the base color
-
well @momoko
To change or edit the flag color of a "true node", you need to modify the "maxon.NODE.BASE.COLOR" attribute.
Cheers~
DunHou -
@Dunhou Thank you. Do you know how I can see what kind of values I can set for it?
-
Hey @momoko,
thank you for reaching out to us and thank you @Dunhou for all the community answers you all provide!
@Dunhou's second answer would be the solution, you must to run
myGraphNode.SetValue("maxon.NODE.BASE.COLOR", maxon.Color(1, 0, 0))
. With graph descriptions you can just type out the things you want to do, under Graph Descriptions: Callbacks I have shown how to color in title bars. But you would not have to use a callback, you can also type outBasic/Color
manually for each node.As data types are
maxon.Color
andmaxon.Vector
or their four component variants fine. Graph descriptions also allow you to use tuples orc4d.Vector
and will convert the data for you.Cheers,
Ferdinand -
@ferdinand You are amazing! Thanks