目前,我遇到了一个问题,我不知道如何为我的纹理的特定区域创建mipmaps。我要想要的是我有一个目标图像和许多试图重新创建目标图像的较小图像。他们从目标图像中继承了颜色,我计算目标图像中该位置下方的平均RGBA值。但是,我不确定如何实现这一目标。我尝试使用OpenGL的 GlGenerateMipMap()
使用MIPMAP生成,但它仅根据整个纹理生成地图。
我无法手动创建MIPMAP,因为它们每次都有随机的大小,旋转和位置。可以根据纹理坐标生成地图。我还考虑过每次裁剪纹理,但这会很慢, glstorepixeli()
没有旋转图像的参数,因此我不认为这是一个选项。
编辑:
一个示例
目标图像:
https://i.postimg.cc/sghws4r1/tokyo.jpg
https://i.postimg.cc/m2xzvf9s/m2xzvf9s/cloud-decor01.png
结果:
httpps://i.postimg.cc/rfnd1nht/output.png
(注意:这是用油漆制成的,只是指令)
,当然要告诉我,因为我渴望知道,是否有更好的方法来获取下面的平均颜色。 :)性能至关重要,因为我需要尽快渲染数千个对象。
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.
发布评论