Viewport depth of field affects the content drawn using drawtexture()
-
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! -
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.
Cheers,
Ferdinand -
@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 -
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
SceneHookDataplugin. 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).
-
@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.