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
    • Recent
    • Tags
    • Users
    • Login
    The Maxon SDK Team is currently short staffed due to the winter holidays. No forum support is being provided between 15/12/2025 and 5/1/2026. For details see Maxon SDK 2025 Winter Holidays.

    Passing BaseObject to ShaderData [SOLVED]

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 251 Views
    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 Offline
      Helper
      last edited by

      On 10/02/2015 at 04:16, xxxxxxxx wrote:

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

      ---------
      Hi everyone.

      I'm having a problem with a shader I've created which gets various values from a BaseObject and converts them to colour values for the shader.

      It works fine in the viewport (and renders fine there too) but it seems that the object doesn't get passed when I render to picture viewer.

      This appears to be where it goes wrong:

        
      INITRENDERRESULT MiscShaderPluginClass::InitRender(BaseShader* sh, const InitRenderStruct& irs)
      {
      	
          BaseContainer* dat = sh->GetDataInstance();
          
          target = dat->GetObjectLink(SDK_OBJECTLINK, GetActiveDocument()); // Gets the linked object
        
          if (!target)
      	{
      	GePrint("NO OBJECT FOUND")
      	return INITRENDERRESULT_UNKNOWNERROR;
      	} 
        
          else{
      	"Do shader stuff"
      	return INITRENDERRESULT_OK;
              }
      }
      

      I just get my NO OBJECT FOUND message.....
      Does anyone know why this doesn't work?

      Thanks,

      Adam
      (sorry about the slightly weird code formatting)

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

        On 10/02/2015 at 04:45, xxxxxxxx wrote:

        Probably the active document is not the same the one you are rendering (maybe a temp copy). Try passing sh->GetDocument() to GetObjectLink() instead of GetActiveDocument().

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

          On 10/02/2015 at 04:53, xxxxxxxx wrote:

          Amazing. Worked like a charm.

          Thanks.

          Adam

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