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

    Baking textures for PBR object

    Cinema 4D SDK
    2
    2
    777
    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.
    • K
      krfft
      last edited by

      Is it possible to bake the values of the reflection channel into textures using "Bake object"?

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by

        Hi krftt thanks for reaching out us.

        With regard to your question, if the intent is to bake the final appearance of a PBR material on a texture, I confirm that there are no means to achieve this considering that the baked data will also be camera-dependent.

        If, on the contrary, your goal is to sample the shader used in any of the reflection layers used in a PBR material you can consider BaseShader::Sample() and, given a ChannelData, retrieve the color at a specific point - see this thread.

        To browse through the different channel you can use something like:

            # check for an active material
            mat = doc.GetActiveMaterial()
            if mat is None:
                return
            
            # retrieve the reflection layers count
            layersCount = mat.GetReflectionLayerCount()
            
            # loop through the layers
            for i in xrange(layersCount):
                # get the ReflectionLayer instance and the related data ID
                reflLayer = mat.GetReflectionLayerIndex(i)
                reflLayerData = reflLayer.GetDataID()
                # check for the instance to be the one currently active in the Attribute Manager
                if reflLayer.GetFlags() & (c4d.REFLECTION_FLAG_TAB):
                    # retrieve the color
                    color = mat[reflLayerData + c4d.REFLECTION_LAYER_COLOR_COLOR]   
                    # try to retrieve the shader
                    colorShader = mat[reflLayerData + c4d.REFLECTION_LAYER_COLOR_TEXTURE]
        
                    # do something with the data retrieved
                    if colorShader is None:
                        print "Selected layer is ", reflLayer.GetName(), "and uses color: ", color
                    else:
                        print "Selected layer is ", reflLayer.GetName(), "and uses shader: ", colorShader.GetName()
        

        Best, Riccardo

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