Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Register
    • Login

    Use new node in an RS material

    Cinema 4D SDK
    c++ 2024 windows
    2
    4
    542
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      spedler
      last edited by

      I've written a new node which outputs a colour and I want to use this in an RS material in the node editor - but it isn't present in the node list.

      The node itself is fine and does what it is supposed to. It is in the node list in the category I want (Color) and I can add it to the node editor, if - and only if - the editor mode is 'Scene'. If I change the mode to 'Material', or create an new RS standard material and edit it, then my node disappears from the node list (so do a bunch of other nodes in the Color category) so I can't use it in the material.

      My question is simply what other steps are needed to make this node available in the node list when the editor is in material mode? There must be something I haven't done - the node is just a core node written as shown in the SDK. What have I omitted to do?

      Thanks,
      Steve

      M 1 Reply Last reply Reply Quote 0
      • M
        m_adam @spedler
        last edited by m_adam

        Hi, this is not really possible to create a node that will work in RS.

        When you implement a node there is different terms you need to know:

        • User Node: This is the UI of the node, defined via the resource editor (like a .res for a BaseObject).
        • Core Node: This is the process unit, this one have the logic of each nodes.
        • Node Template: Similar to an asset but coded. Its a blueprint that re-use other node templates or core nodes. Typical logic is load an user node (the UI), create others core nodes or node template and connect them together.
        • True Node: A User Node + a Core Node or a Node Template. This term is used in documentation to hint at a node as a typical user would understand it.

        Then regarding how a graph is being executed, in the case of Scene Node and Standard there is two main stages to know:

        • Compile Time: All nodes are unrolled and their data are flatten as much as possible. If you do a simple addition with 2 value nodes, during this phase the 2 values are added together, and only the result will be used (like in C++ if you do constexpr). But if one of the two initial values is dynamic (e.g. like the output of another node) then the logic will be executed at Run Time.
        • Run Time: The previously unrolled graph with all "constant" data and all core nodes that rely on dynamic data are executed.

        In the case of Redshift, the execution of the graph differs. It doesn't utilize the two previous stages. Instead, it examines the graph generated in Cinema 4D and replicates it internally as a GPU shader graph. As a result, there is no compile-time execution in Redshift.

        With all these information, the real answers to your question is you can create node for everything that is not bound to the Redshift Execution so this means only:

        • Create a Node Template that re-use only existing nodes.
        • Create a Node Template that will work only at compile time. See ColorInvertNode Compile Time Example. But since RS for the moment did not support compile-time for most of there nodes, this will be quickly limited, but for Standard render that does use more compile-time node and it can make sense to go for that.

        So I would say this leave very little room for implementing any meaningful shader for RS.

        Finally regarding your question, in order to make your node visible in a node space, you should implement the method NodeTemplate::SupportsImpl and return true to inform if your node template support the given node space. Note that each core node get wrapped into a default node template, and this default nodetemplate call the NodeSystem::SupportsImpl methods, which is the methods defined by a NodeSpace to specify which nodes to accept.

        If you have any other question, please let me know, but please keep in mind that we will have reduced Levels of Support between 22/04 and 26/04.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        S 1 Reply Last reply Reply Quote 2
        • S
          spedler @m_adam
          last edited by

          Hi @m_adam

          Thanks very much for this, it's extremely helpful and gives a lot of detail about how nodes actually work.

          From what you say, it does indeed sound as though implementing a shader in RS is basically not possible. That's a shame, but at least I won't be wasting time trying to get it to work but not knowing it can't be done! Still, I've learnt quite a lot while trying to make it work, so it's not all bad.

          Thanks again,
          Steve

          1 Reply Last reply Reply Quote 0
          • M
            m_adam
            last edited by

            One things I forget, is that if you want to extend redshift currently the only way would be via the OSL node they provide, and provide an asset for this OSL node.

            Cheers,
            Maxie.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • First post
              Last post