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

    Materials and BaseShader

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 395 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

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 13/09/2012 at 15:59, xxxxxxxx wrote:

      Hello again, sorry about all the posts, I've been trying a bunch of new stuff recently.

      I'm trying to copy a bitmap texture  from the color channel and apply it  to other channels.  This works if it's directly into one of the default channels, but if I'm doing a nested channel(Filter Shader) I get a black preview image instead of the correct bitmap image.

      To test it out add a bitmap channel and then run the code, then check the diffusion channel and click on filter.

        
      import c4d  
      from c4d import gui  
        
      def main() :  
        mat = doc.GetActiveMaterial()#Get the active material  
          
        bsbit = c4d.BaseShader(c4d.Xbitmap)  #create a bitmap baseshader  
        bsbit[c4d.BITMAPSHADER_FILENAME] =mat[c4d.MATERIAL_COLOR_SHADER][c4d.BITMAPSHADER_FILENAME]  
        #get the bitmap name from the color channel and apply it to this one  
          
          
        bsdiffusion = c4d.BaseShader(c4d.Xfilter)#Create a filter baseshader  
        bsdiffusion[c4d.SLA_FILTER_TEXTURE] =bsbit#assign the bsbit shader as this ones texture  
        mat[c4d.MATERIAL_DIFFUSION_SHADER]= bsdiffusion #set this shader as the materials diffusion shader  
          
        mat.InsertShader(bsbit)#insert the shaders  
        mat.InsertShader(bsdiffusion)  
          
        mat.Message(c4d.MSG_UPDATE)#update  
        mat.Update(True, True)  
        c4d.EventAdd()  
      if __name__=='__main__':  
        main()  
        
      

      I'm not sure what I'm missing.  
      Thanks in advance for any help! I've been learning so much from all of the answers.

      Dan

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 13/09/2012 at 23:11, xxxxxxxx wrote:

        i guess you want to insert the bitmap shader under the fusion shader and not under the material. So use bsdiffusion.InsertShader(bsbit) instead of mat.InsertShader(bsbit)

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 14/09/2012 at 08:42, xxxxxxxx wrote:

          Thanks a bunch, affa! It's all working perfectly now.

            
            
          import c4d  
          from c4d import gui  
            
          def main() :  
            mat = doc.GetActiveMaterial()#Get the active material  
              
            bsbit = c4d.BaseShader(c4d.Xbitmap)  #create a bitmap baseshader  
            bsbit[c4d.BITMAPSHADER_FILENAME] =mat[c4d.MATERIAL_COLOR_SHADER][c4d.BITMAPSHADER_FILENAME]  
            #get the bitmap name from the color channel and apply it to this one  
              
              
            bsdiffusion = c4d.BaseShader(c4d.Xfilter)#Create a filter baseshader  
            bsdiffusion[c4d.SLA_FILTER_TEXTURE] =bsbit#assign the bsbit shader as this ones texture  
            mat[c4d.MATERIAL_DIFFUSION_SHADER]= bsdiffusion #set this shader as the materials diffusion shader  
              
            bsdiffusion.InsertShader(bsbit)#insert the shaders under the shader that uses then  
            mat.InsertShader(bsdiffusion)  
              
            mat.Message(c4d.MSG_UPDATE)#update  
            mat.Update(True, True)  
            c4d.EventAdd()  
          if __name__=='__main__':  
            main()  
            
          

          Dan

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 17/09/2012 at 14:54, xxxxxxxx wrote:

            Now I 'm trying to create a Layer shader for a material and I'm running into trouble.  How do I insert new shaders into it?  I saw this thread, https://developers.maxon.net/forum/topic/5480/5499_how-to-access-in-the-layer-shader&KW=layer+shader, about reading what's in it, but I want to create the material.

            Dan

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