生成纹理特定区域的mipmap

发布于 2025-02-09 04:10:11 字数 923 浏览 0 评论 0 原文

目前,我遇到了一个问题,我不知道如何为我的纹理的特定区域创建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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文