Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Login

    Get all shaders use in a material

    SDK Help
    0
    3
    487
    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.
    • H
      Helper
      last edited by

      On 24/10/2017 at 00:47, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R18 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Hello.

      I need to know if there is any Color Shader in a Material parameter.
      To do that I parse the inserted shaders in the material via GetFirstShader and GetNext.
      I suppose I also have to parse the retrieved shaders recursively.

      Is this the correct way to get all the shaders used in a material ?

      Thank you for your time !

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 24/10/2017 at 01:21, xxxxxxxx wrote:

        Hi Peterakos, your assumption is correct.
        Actually traversing the shader tree almost behaves to the same "rules" of traversing the scene tree.

        Best, Riccardo

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 26/10/2017 at 05:17, xxxxxxxx wrote:

          Hi Peterakos,

          in general Riccardo's answer is correct. But we figured out, one will be missing a few corner cases with this approach.
          There are some shaders which support sub-shaders, but for historic and/or architectural reasons these do not insert their sub-shaders into the shader tree of a material.
          For these you will need to do a separate traversal starting with the shader(s) from their parameters.

          Here are the shaders, their IDs and shader parameters:

          Colorizer (ID: Xcolorizer from xslacolorizer.h, parameter SLA_COLORIZER_TEXTURE)

          MoGraph MultiShader (ID: 1019397, parameters MGMULTISHADER_LAYER_LINK (first shader, next ones follow by +1) and MGMULTISHADER_LAYERCOUNT (number of shaders) from xmg_multi.h)

          Sketch&Toon Art Shader (ID: 1012161, parameters ARTSHADER_TEXTURE, ARTSHADER_SHADOW_TEXTURE and ARTSHADER_BACKFACE_TEXTURE from xartshader.h)

          Sketch&Toon Hatch Shader (ID: 1012166, parameter HATCHINGSHADER_TEXTURE from xhatchingshader.h)

          Sketch&Toon Spots Shader (ID: 1012160, parameter SPOTSHADER_GAP_TEXTURE from xspotshader.h)

          You might consider to browse the descriptions of shaders for shader links to end up with a generic implementation. But then be extra careful you don't end in an endless loop, with shaders which do insert sub-shaders intro the tree (e.g. layer shader).

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