fwidth glsl 函数实际用于什么?
每次我喝醉浏览时,我都会看到一个未回答的 fwidth
问题。 这让我想知道它的实际设计目的是什么。
阅读文档它是: abs(dFdx(p)) + abs(dFdy(p))
因此,它不是经典的 mip 选择,即 max(dx,dy)
。 是为了替代mip选择吗?但我没有找到更好的情况。 一定有一些我完全缺少使用该功能的签名纸或通用算法。它一定非常受欢迎,因为它被纳入 GLSL 中。 我唯一能想到的是我缺少一些 2d 后置滤镜。
但什么? 我相信这里有人知道,一旦你看到它,就很明显了。 那么:什么算法使用 abs(dx) + abs(dy)
?
Every time I drunk browse so I see an unanswered fwidth
question.
And it makes me wonder what it actually was designed to do.
Reading the docs it is:abs(dFdx(p)) + abs(dFdy(p))
So it is not classic mip selection which is max(dx,dy)
.
Is it for alternative mip selection? But I fail to find a case where abs(dx) + abs(dy)
would be better.
There must be some siggraph paper or common algorithm I am completely missing that uses that function. And it must be really popular because it made it into GLSL.
The only thing I can think of is some 2d post filter I am missing.
But what?
I am sure somebody here knows and once you see it it's obvious.
So: What algorithm uses abs(dx) + abs(dy)
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是函数 DF = dF/dx*dx + dF/dy*dy 的全导数。看到相似之处了吗?
fWidth >= DF 或者换句话说,fWidth 是任何当前片段相邻像素之间片段变量F 的最大可能变化。即 3x3 邻域中的 8 个周围像素。
this is the total derivative for the function DF = dF/dx*dx + dF/dy*dy .see the similarity?
fWidth >= DF or in words fWidth is maximum possible change in a fragment variable F, between any of a current fragmants neighboring pixels. ie the 8 surrounding pixels in the 3x3 neighborhood.
实际上,您对 2D 过滤建议非常满意。任何依赖于某种像素与其邻居之间的变化率度量的过滤器都可以从此函数中受益。
例如抗锯齿、边缘检测、各向异性过滤。我相信人们还可以想到更多的例子。
从您的问题和评论看来,您希望将这个函数包含在 GLSL 中有一个令人兴奋的理由。我只想说这是一个有用的功能。也许对该函数的实际内部结构有更深入了解的人可以提供有关幕后发生的情况的更多详细信息(即,与 dFdx 和 dFdy 的手写等效项相比,是否有任何性能改进)。
You're actually quite on the money with the 2D filtering suggestion. Any filter which relies on some sort of metric for the rate of change between a pixel and its neighbors could benefit from this function.
Examples would be anti-aliasing, edge detection, anisotropic filtering. I'm sure there are more examples one could think of.
It seems from your question and comments that you expect there to be a mind-blowing reason for this function to be included in GLSL. I would just say that it's a useful function to have. Perhaps someone with more in-depth knowledge about the actual internals of this function could provide more detail on what happens behind the scenes (i.e. if there is any performance improvement over a handwritten equivalent with dFdx and dFdy).