problem exporting PNG via jit.gl.asynread/jit.matrix
I'm seeing a noticeable decrease in dynamic range when trying to capture a still image of a rendered OpenGL scene that employs alpha blending. I've attached an example patch and two images, one a direct screen grab of the render window, the other a PNG generated with the "exportimage" message to jit.matrix. To my eyes the screen grab clearly has a greater dynamic range.
Would anyone care to take a look and point me in the right direction here? The end goal is to be able to capture pixel accurate still captures of my rendered scene.
Mac OSX 10.7.5
Macbook Pro, 2.3Ghz i7
8GB RAM
AMD Radeon HD 6750M
I gather after doing some more research that this is an issue with jit.matrix, and is really nothing to do with readback from OpenGL. The export seems to work properly if I specify JPEG or BMP as the file type in the exportimage message. The other formats I've tried (PNG, TIFF, TGA, SGI) all have the same dynamic range issue. The PICT format does give the correct dynamic range but resizes to a different pixel resolution, and the file itself won't open in Photoshop CS5.1.
It would be nice to hear from Cycling why the above uncompressed export formats do not work properly.
it seems to be because your context elements contain transparent alpha values.
the matrix export is doing exactly what you tell it, and exporting with transparency (for formats that support it, such as png), and the image viewing app (Preview on the mac) is matting your transparent image with some solid color, probably grey.
either create a fully opaque black background layer, or don't export a format that supports transparency.
let me know if that doesn't fix the problem.
Thanks for the explanation Rob. Would @erase_color 0. 0. 0. 1. not be a fully opaque black background layer? That's what I have in the original patch.
I believe I've solved this by simply stripping the alpha channel from the jit.matrix coming out of jit.gl.asyncread, and setting it all to 255. That seems to work with any export file format.
erase_color isn't a layer, it's simply the color that overwrites from frame to frame, and has doesn't come into play when exporting.
glad you figured it out.