Since OpenGL 3.0 you’ve been able to choose a specific mipmap level the target for a write to buffer operation, e.g.
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glFramebufferTexture.xhtml
glFramebufferTexture — attach a level of a texture object as a logical buffer of a framebuffer object
void glFramebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level);
level here is the mipmap level. If understand correctly you can just treat it as a regular buffer with the dimensions reduced to whatever is appropriate for that mipmap level. Then you could have a fragment shader just write straight to the subimage.
I couldn’t find anything specific in the Panda3d documentation that seemed to allow anything like this. Any help would be appreciated.
Another approach would be using imageStore but that doesn’t seem to be able to access mipmap levels directly unless I am missing something. I think there a way to make a subimage the target for a uniform sampler2D in OpenGL generally (to do a specific level one at a time) but I don’t know how to do that in Panda either, e.g.
glBindImageTexture( 0, image.id_GL(), level, GL_FALSE, 0, GL_WRITE_ONLY, GL_R32F);
Some way of writing to subimages (mipmap levels) in shaders would be really useful for generating mipmaps yourself or to modify those sub-images for another purpose. My specific use case was wanting to use a compute shader to generate mipmap levels very quickly on a per frame basis. I need to use a minimum rather than an average to create the texels on the subimages.
As a more general question, I was also wondering when Panda would generate mipmaps automatically and how much control you have over when it is done. I don’t mean when reading in image files, I am more interested in generating a texture level 0 by whatever means and then getting mipmaps for it at a specific time. Thanks.