iridescence icon indicating copy to clipboard operation
iridescence copied to clipboard

Bug in light_viewer.cpp when reading depth buffer - float array too big

Open MPierer opened this issue 1 year ago • 1 comments

There is an issue when reading the depth buffer

The call https://github.com/koide3/iridescence/blob/8451c81e2dd5c6fcb3b86ee953f54ee6da37672f/src/guik/viewer/light_viewer.cpp#L720 uses the default argument int num_elements = 4 in texture.hpp template <typename T> std::vector<T> read_pixels(GLuint format = GL_RGBA, GLuint type = GL_UNSIGNED_BYTE, int num_elements = 4) const;

Hence, the resulting float buffer is 4x too large. (Also note, there are more places in iridescence where the omitted num_elements might be wrong, e.g. GLCanvas::pick_info when reading pick id)

Also the line https://github.com/koide3/iridescence/blob/8451c81e2dd5c6fcb3b86ee953f54ee6da37672f/src/guik/viewer/light_viewer.cpp#L723 should rather use depth (although their sizes always match) Eigen::Vector2i size = canvas->frame_buffer->depth().size();

MPierer avatar Nov 06 '24 11:11 MPierer

Thanks. I fixed the mismatched num_elements and the texture size target. I also added I also added a warning to find mismatched combinations of format and num_elements. https://github.com/koide3/iridescence/pull/147

koide3 avatar Nov 10 '24 02:11 koide3