pythonocc-core icon indicating copy to clipboard operation
pythonocc-core copied to clipboard

dumping Graphic3d_BT_Depth does not dump the depth buffer

Open daniel1v opened this issue 5 years ago • 4 comments
trafficstars

I am trying to render depth images and therefore modified the "core_offscreen_rendering.py" example as follows:

from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox
from OCC.Core.Graphic3d import Graphic3d_BT_Depth

offscreen_renderer = Viewer3d(None)
offscreen_renderer.Create()
offscreen_renderer.SetSize(1024, 768)
offscreen_renderer.SetModeShaded()
my_box = BRepPrimAPI_MakeBox(10., 20., 30.).Shape()
offscreen_renderer.DisplayShape(my_box, update=True)
data = offscreen_renderer.GetImageData(Graphic3d_BT_Depth)
offscreen_renderer.View.Dump('./capture_jpeg.jpeg', Graphic3d_BT_Depth)

The rendered image only contains the value 1 for every pixel. Is this a bug or am I doing something wrong?

Also: The exported image is of another size than the renderer: 1040x807. This happens also when using Graphic3d_BT_RGB.

daniel1v avatar Jun 13 '20 09:06 daniel1v

I have the same result than you get, on Linux the image generated using Graphic3d_BT_Depth buffer type is black. I'm afraid I can't help, I never studied this part of the opencascade code.

tpaviot avatar Jun 16 '20 06:06 tpaviot

okay, although, thrank you for your answer. i solved my issue by writing my ownn shader. now the values are as expected. maybe the default shader uses the depth buffer for sth different than depth.

daniel1v avatar Jun 21 '20 17:06 daniel1v

@daniel1v I have the same issue as you. Could you please help me with the shader? How did you solve the problem that the images are of different size than the renderer? The same is for me. Thank you

pridi avatar Mar 21 '21 06:03 pridi

I am sorry, I cannot remember, how I solved it exactly.

The core of the solution was to use a custom opengl renderer. Somewhere in the pythonocc-demos repo is a simple example for that.

daniel1v avatar Mar 24 '21 15:03 daniel1v