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

    Remapping textures in non-diffuse channels

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 293 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 21/03/2016 at 10:49, xxxxxxxx wrote:

      I'm working on some basic pipeline tools for R17, and I just ran into my first problem that I can't seem to solve based on the documentation that's currently available.  Essentially -- I'm only able to figure out how to modify the texture applied to a color / diffuse channel, and not reflection.  (I haven't tried it on any other channel just yet.)

      Here is the function I'm writing:

      def changeTexture( mat, tex_path, channel=c4d.MATERIAL_COLOR_SHADER ) :
          ''' Changes the texture on a material's specified channel.  Defaults to the color channel. '''
          tex = c4d.BaseList2D(c4d.Xbitmap)
          tex[c4d.BITMAPSHADER_FILENAME] = tex_path
          mat[channel] = tex
          mat.InsertShader(tex)
          mat.Message(c4d.MSG_UPDATE)
          mat.Update(1,1)
          c4d.EventAdd()
          return True
      

      This works fine when operating on the default c4d.MATERIAL_COLOR_SHADER container.  And, based on what i'm seeing in mmaterial.h, should work on all the other channels as well.  Except i see a comment above the other channels referring to them as "legacy illumination values" -- so i'm assuming something changed when the reflectance model changed recently.

      I can get a BaseShader object for the reflection channel with the following:

      shd = mat[c4d.MATERIAL_REFLECTION_SHADER]
      

      .. but based on the BaseShader documentation, I don't see a way to access bitmap file data.

      Any nudge in the right direction would be helpful.

      Thanks!

      m

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

        On 21/03/2016 at 11:59, xxxxxxxx wrote:

        I seem to have found the solution, under the documentation for c4d.Material (hah, duh).

        Using the above function as a base:

        refl_shd = mat.GetAllReflectionShaders()
        for rs in refl_shd:
            rs[c4d.BITMAPSHADER_FILENAME] = tex_path
        

        ... does the trick nicely.  The mat.GetAllReflectionShaders() is what I was looking for.

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

          On 22/03/2016 at 03:06, xxxxxxxx wrote:

          Hello,

          BaseMaterial is the base class for all materials of Cinema 4D, Material is the class defining the standard material.

          GetAllReflectionShaders() returns all shaders used by reflection layers. These shaders may or may not be Bitmap shaders. So before you edit the BITMAPSHADER_FILENAME parameter you should check if the given shader is a Bitmap shader (c4d.Xbitmap) or not.

          Best wishes,
          Sebastian

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