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
    • Login

    How to know inside a shader what exact object is the shader attached.

    Cinema 4D SDK
    c++
    1
    3
    501
    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.
    • R
      rui_mac
      last edited by

      I created a shader that needs to know exactly what object it is attached to.
      So, if a material that contains that shader in, for example, the Color channel, is assigned to different objects, it will produce different results.
      I know that the VolumeData contains a list of all objects being rendered and that each object in the VolumeData, obtained by GetObj(i) contains a RayObject that contains the texture_link parameter.
      But, inside my shader, I get ALL the objects that include the material that contains the shader.
      So, from inside the shader, how can I know what is the exact object that is being rendered?

      1 Reply Last reply Reply Quote 0
      • R
        rui_mac
        last edited by

        I guess I can only make sure I know what is the object being rendered from inside the Output method, as in the InitRender method I can't make sure what is the one being affected.

        1 Reply Last reply Reply Quote 0
        • R
          rui_mac
          last edited by

          Ok, found out what is wrong.
          The code inside the Output is being executed in multiple threads.
          So, one thread may be calculating the color of one object but the data I have in my struct is from another object being calculated by another thread.
          Is there any way to force a shader to be only calculate in a single thread?
          Or, is there any way to get a unique value from each object so that I can store a set of structures in the InitRender method, and detect which one is being rendered in the Output method and use the correct structure of data?

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