Get color as it is presented on screen?

Hi all,

I was just writing a script that converts a panda model to a 2d svg-like format (so I let panda calculate the 2d screen positions of each polygon then write them to the file), and I came up with a question.
Is it possible to get the color of a polygon as it is presented on screen? Something like bake the lighting into the vertex colors?

Secondly, I wondered whether it was possible to check whether the polygon was really visible or behind something else – so I would need to write less polygons to my file, since the model can’t be rotated anyway when converted.

Thanks in advance,

These things are theoretically possible, but you either have to do it by figuring out some clever way to map the pixels of the rendered image back to the vertices that generated them, or you have to re-engineer the work that the graphics card is doing for you.

In short, possible, but not at all easy.


Thanks for your quick reply.
Okay, so I guess I’ll have to loop through the polygons and calculate the shading (I’m not even calling run() so speed is not an issue) and multiply that with the vertex color. Right?

Is there any basic panda function that handles my second question?

No, same answer. Normally Panda doesn’t even know what’s in front or what’s behind another object. The graphics card solves this when it renders the scene, via the Z-buffer. So to get the final answer, you either have to figure out some way to ask the graphics card, or you have to re-engineer everything the graphics card does.

In fact, there is a way in low-level Panda to ask the graphics card this question, via GSG::begin_occlusion_query(). But this interface is too low-level to expose to Python.