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

    Viewport depth of field affects the content drawn using drawtexture()

    Scheduled Pinned Locked Moved Cinema 4D SDK
    2025python
    5 Posts 2 Posters 30 Views 1 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.
    • chuanzhenC Offline
      chuanzhen
      last edited by chuanzhen

      hi,
      I have a OBJECT_GENERATOR plugin and I encountered some problems while drawing it. I am drawing something in screen space use BaseDraw.DrawTexture(), and when I turn on depth of field of viewport, the drawn content is also affected. How to make the drawn content not affected by depth of field.
      Thanks for any help!

      相信我,可以的!

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

        Hey @chuanzhen,

        Thank you for reaching out to us. Please remember our support procedures. It is very difficult to help you without seeing the relevant code.

        My guess would be that you are drawing into a draw pass which intentionally is affected by viewport effects such as depth of field, e.g., DRAWPASS:OBJECTS. The C++ code examples contain the Drawing with OCIO Colors in a Viewport example; which is likely very close to what you want to do. The example draws textures in both the object and handle pass, where the object pass will be affected by DOF while the handle pass will not.

        4cba6810-c75f-4622-bacf-8186b19ea3ed-image.png

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        chuanzhenC 1 Reply Last reply Reply Quote 0
        • chuanzhenC Offline
          chuanzhen @ferdinand
          last edited by

          @ferdinand Thanks,
          DRAWPASS::HANDLES There is a limitation that only displays when I select the object, and my goal is to keep it displayed (select or not select)
          code:

              def Draw(self,op, drawpass, bd, bh):
          
                  
          
                  if drawpass == c4d.DRAWPASS_OBJECT:
                      #draw
                      bd.SetMatrix_Screen()
                      
                      window_dict = bd.GetSafeFrame()
                      
                      bd.SetLightList(c4d.BDRAW_SETLIGHTLIST_NOLIGHTS)
                      # set uv ... info
                      uvadr = [c4d.Vector(), c4d.Vector(), c4d.Vector(), c4d.Vector()]
                      uvadr[1] = c4d.Vector(1, 0, 0)
                      uvadr[2] = c4d.Vector(1, 1, 0)
                      uvadr[3] = c4d.Vector(0, 1, 0)
                      padr = [c4d.Vector(), c4d.Vector(), c4d.Vector(), c4d.Vector()]  
                      padr[0] = c4d.Vector(window_dict['cl'], window_dict['ct'], 0)
                      padr[1] = c4d.Vector(window_dict['cr'], window_dict['ct'], 0)
                      padr[2] = c4d.Vector(window_dict['cr'], window_dict['cb'], 0)
                      padr[3] = c4d.Vector(window_dict['cl'], window_dict['cb'], 0)
                      map = xx  # this can be any images
                      cadr = [c4d.Vector(1), c4d.Vector(1), c4d.Vector(1), c4d.Vector(1)]
                      nadr = [c4d.Vector(1), c4d.Vector(1), c4d.Vector(1), c4d.Vector(1)]
                      if map:
                          bd.DrawTexture(map, padr, cadr, nadr, uvadr, 4, c4d.DRAW_ALPHA_NORMAL, c4d.DRAW_TEXTUREFLAGS_TEMPORARY)
                  
                  return c4d.DRAWRESULT_OK
          

          相信我,可以的!

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

            Yes, it is intentional that the handle draw pass is only being drawn when the object is selected. You can try the box pass, I think it is also drawn when the object is not selected and might not be subject to viewport effects. The highlight pass is also only drawn when an object is selected. The X-Ray pass should be drawn when an object is not selected, but should also be subject to viewport effects. But the box pass is also subject to camera transforms, just as the object pass, which makes it not a very good choice to draw HUD information.

            All statements above are from my recollection and could be wrong, you just have to check yourself.

            But what you are trying to do is also a bit unusual. Typically, objects should not draw persistent HUDs (what I assume you are trying to do) into the viewport. That would be the job of a SceneHookData plugin. But that hook has never been exposed to Python, mostly out of performance concerns.

            Your code is also missing the OCIO handling the C++ example showcases. You will be drawing with incorrect colors (unless the bitmap(s) you draw happen to have the color profile of the render space of the document - which is very unlikely).

            MAXON SDK Specialist
            developers.maxon.net

            chuanzhenC 1 Reply Last reply Reply Quote 0
            • chuanzhenC Offline
              chuanzhen @ferdinand
              last edited by

              @ferdinand Thanks for reply
              Other channels(BOX,X-Ray....) also seem to be unfeasible, and currently it seems only can accept this limitation (affected by depth of field)
              Due to the current not to transfer to C++, some plugin ideas are indeed somewhat unusual
              only using some simple C4D drawings to generate Bitmaps, so I did not pay attention to the handling of Ocio. I will carefully read the manual on this aspect in the document.

              相信我,可以的!

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