I'm currently running into an issue where I don't know how to create mipmaps for a specific area of my texture. What I'm going for is that I have a target image and a lot of smaller images that try to re-create the target image. They inherit their color from the target image in a way that I calculate the average RGBA-value underneath that spot in the target image. However, I'm not sure how to accomplish this. I've tried mipmap generation with OpenGL's glGenerateMipmap()
but it only generates maps based on the whole texture.
I am unable to create the mipmaps manually since they are of random size, rotation and location each time. The maps could be generated based on the texture coordinates. I've also thought about cropping the texture each time but that would be slow and glStorePixeli()
doesn't have a parameter for a rotated image so I don't consider this as an option.
EDIT: One example
Target image: https://i.postimg.cc/sghWs4R1/tokyo.jpg
Object image: https://i.postimg.cc/m2xzVF9s/Cloud-Decor01.png
Result: https://i.postimg.cc/RFNd1nHt/output.png (NOTE: this was made with paint and is just directive)
And of course tell me if there is a better way to get the average color underneath since I'm dying to know. :) Performance is crucial since I need to render thousands of objects as fast as possible.