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

    Sample Bitmap Shader Path

    Scheduled Pinned Locked Moved PYTHON Development
    6 Posts 0 Posters 673 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 23/06/2016 at 13:47, xxxxxxxx wrote:

      Hello Forum,

      I'm trying to sample a bitmap shader with code inside a Python Generator object.  When the BITMAPSHADER_FILENAME is just set to a file name('somtjpg.jpg') and the file is inside the tex folder in the same directory as the document, InitRender() returns INITRENDERRESULT_ASSETMISSING.  If BITMAPSHADER_FILENAME == the full path to the file, InitRender() returns INITRENDERRESULT_OK.

      If I just set BITMAPSHADER_FILENAME like inside the Python Generator:

      original_color_shader[c4d.BITMAPSHADER_FILENAME] = bitmap_path
      

      the actual material in the document gets updated.  I do not want this.

      Here is my questionable solution that clones the shader and sets the path:

      original_color_shader = material[c4d.MATERIAL_COLOR_SHADER] 
      if not original_color_shader: 
          return 
      bitmap_filename = original_color_shader[c4d.BITMAPSHADER_FILENAME] 
      bitmap_path = c4d.GenerateTexturePath(doc.GetDocumentPath(), bitmap_filename, "") 
      color_shader = original_color_shader.GetClone() 
      color_shader[c4d.BITMAPSHADER_FILENAME] = bitmap_path
      

      This works, but seems hacky.

      Is cloning the shader necessary?

      Also, I would like to know if c4d.GenerateTexturePath() sets up paths properly for Team Render Server?

      Thank you,

      Joe Buck

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

        On 24/06/2016 at 02:00, xxxxxxxx wrote:

        Hi Joe,

        I'm sorry, you have found a bug in the Python layer. Unfortunately the InitRenderStruct does not get initialized correctly. As the document does not get set in there, InitRender has no chance to resolve the texture path. I have filed a bug report.

        In your workaround the cloning is necessary, you are not allowed to change the scene from within the Python Generator.

        GenerateTexturePath is generally the right approach to resolve texture paths. In a TR situation, I don't think it has to work on the server. The clients request assets from the server, but in your case the asset (the image) is already handled by the bitmap shader. On client side the texture will be stored in the tex folder and will have no path in the bitmap shader. Then your Python Generator comes in on client side and can resolve the texture path via GenerateTexturePath.

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

          On 24/06/2016 at 07:06, xxxxxxxx wrote:

          Mr. Block,

          Thanks for your fast and expert help.

          Joe Buck

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

            On 24/06/2016 at 07:08, xxxxxxxx wrote:

            You are welcome 🙂
            And Andreas, please. Or should I to change to Mr. Buck?

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

              On 24/06/2016 at 08:04, xxxxxxxx wrote:

              Nope.  Just showin' some respect.  You guys are doing a really good job these days.

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

                On 24/06/2016 at 08:40, xxxxxxxx wrote:

                Thanks 🙂

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