Solved How to get Viewport pixel color

Hi,
I want to know the active viewport color value of each pixel .
Like the red rectangular area I marked in the figure未标题-1.png

Thanks for any help!

相信我,可以的!

Hello @chuanzhen,

thank you for reaching out to us. In Python there is no really good way to do this. Your best option is to render the BaseDraw you are interested in with RenderDocument with the OpenGL renderer as the render engine. Which will work fine if you only need a viewport representation once in a blue moon, but will quickly become a giant bottleneck if you need access to a viewport framebuffer dozens of times per second. In this case I would recommend moving to C++, as you have there somewhat direct access to the viewport draw buffer with BaseDraw::GetViewportImage.

Cheers,
Ferdinand

MAXON SDK Specialist
developers.maxon.net

Hello @chuanzhen,

thank you for reaching out to us. In Python there is no really good way to do this. Your best option is to render the BaseDraw you are interested in with RenderDocument with the OpenGL renderer as the render engine. Which will work fine if you only need a viewport representation once in a blue moon, but will quickly become a giant bottleneck if you need access to a viewport framebuffer dozens of times per second. In this case I would recommend moving to C++, as you have there somewhat direct access to the viewport draw buffer with BaseDraw::GetViewportImage.

Cheers,
Ferdinand

MAXON SDK Specialist
developers.maxon.net

@ferdinand Thanks for your hlep!

相信我,可以的!

@ferdinand Hi,i use RenderDocument in python,although it is a little slow and needs to wait for a second, it works successfully.

Thanks for your help,gif show it works:
ssss.gif

相信我,可以的!