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
    • Register
    • Login

    Change render Space (Color Profile) - how?

    Scheduled Pinned Locked Moved Cinema 4D SDK
    20252026python
    2 Posts 2 Posters 12 Views 2 Watching
    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.
    • M Offline
      mogh
      last edited by

      Dear Dev Team,

      I have a plugin that renders (Standard C4d Renderer - fastest for plain color at the time) a flat color rendering (no dithering, shading, or lights) of object display color (yes plain object color, no textures). Input and output have to be the exact same color, to evaluate if the camera "sees" an object. This plugin worked before 2025.2 with "sRGB linear" workflow.
      Render output looks like this (the more objects the more colors of course):
      example.png

      Quick solution for me is to change the "Render space" to legacy "sRGB linear workflow"
      2026-08-25 16_24_25-Convert Render Space.png
      Question: -> how would I do that in python ? (and back to the users render Color-space so it does not mess up the users settings)

      Is there a better way to get Input object color and rendered color to be exactly the same with no color space change? A color transform on the bmp? how would I do that?

      thank you for your time

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF Offline
        ferdinand @mogh
        last edited by ferdinand

        Hey @mogh,

        the answer can be found in the OCIO examples, specifically here. In the example I do the exact opposite from what you want to do, I convert a scene from legacy/basic mode to OCIO. Its inverse would look somewhat like what I show below. I hope this helps.

        Cheers,
        Ferdinand

        """Demonstrates how to convert a document from OCIO color management to basic color management.
        """
        import c4d
        
        
        op: c4d.BaseObject | None # The primary selected object in the scene, can be None.
        doc: c4d.documents.BaseDocument # The currently active document.
        
        def main() -> None:
            """Runs the example.
            """
            # The document is already in basic mode, so no conversion is needed.
            if doc[c4d.DOCUMENT_COLOR_MANAGEMENT] == c4d.DOCUMENT_COLOR_MANAGEMENT_BASIC:
                return c4d.gui.MessageDialog("The document is already in basic mode. No conversion is needed.")
        
            # Get the converter, and the active render space, which by default will be ACEScg.
            converter: c4d.modules.render.SceneColorConverter = c4d.modules.render.SceneColorConverter()
            renderSpace: str = doc.GetOcioRenderingColorSpaceNames()[0]
        
            # Initialize the converter with:
            #              doc, from-low   , from-high   , to
            converter.Init(doc, renderSpace, renderSpace, "scene-linear Rec.709-sRGB")
        
            # Convert everything in the document (we pass the document itself as the second argument). The
            # undo management is only needed so that our DOCUMENT_COLOR_MANAGEMENT below is reversible. The
            # ConvertObject call creates undo steps on its own with the default flag we pass. 
            doc.StartUndo()
            doc.AddUndo(c4d.UNDOTYPE_PRIVATE_DOCUMENTDATA, doc)
            if not converter.ConvertObject(doc, doc):
                print(f"Failed to color convert document '{doc}'.")
        
            # Finally, set the color management mode to basic/legacy. It is absolutely important that we do
            # things in this order, otherwise SceneColorConverter will not work correctly.
            doc[c4d.DOCUMENT_COLOR_MANAGEMENT] = c4d.DOCUMENT_COLOR_MANAGEMENT_BASIC
            doc.EndUndo()
            c4d.EventAdd()
            
        if __name__ == "__main__":
            main()
        

        MAXON SDK Specialist
        developers.maxon.net

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