通过在 GLSL 中为不同的屏幕区域着色来识别 mip 贴图级别
我不想用代码轰炸这篇文章。我有一个主文件、片段着色器和顶点着色器文件。
我需要知道根据 mipmap 级别为屏幕着色应采取的步骤?即循环应该去哪里,要求 mipmap 级别,然后相应地设置颜色。我不知道在哪里实现这个或如何实现,一个简单的例子就足够了,非常感谢。
I don't wish to bombard this post with code. I've got a main file, fragment shader and a vertex shader file.
I need to know the steps that I should take to color the screen according to mipmap level? I.e. where the loop should go that asks for mipmap level, then sets colour accordingly. I don't know where to implement this or how, a simple example would suffice many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该为每个级别创建具有不同颜色的纹理,然后在片段程序中检索该颜色。也可以使用 dFdx(texcoord.x) 和 dFdy(texcoord.y) 来计算。
You should create a texture with a different color for every level, and then retrieve that color in your fragment program. It might also be possible to compute it using
dFdx(texcoord.x)
anddFdy(texcoord.y)
.就像 tibur 所说,一个简单的方法是使用调试纹理,每个级别都有不同的颜色,如下所示 此处。
现在,如果您需要手动计算 mipmap 级别(通常是浮点值),这是另一个故事,因为您将需要导数,但是 这应该会让你走上正轨。
Like tibur said, an easy way to do this is to use a debug texture that have a different color for every level as seen here.
Now if you need to compute the mipmap level by hand (usually a floating point value), this is another story since you will need derivatives, but this should put you on track.
http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter28.html
这篇 GPU Gems 2 文章实现了您想要的东西。
http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter28.html
This GPU Gems 2 article implements something like what you want.