有没有一种方法可以计算片段着色器中某物的DFDX(DFDX())?

发布于 2025-01-18 15:05:10 字数 565 浏览 0 评论 0 原文

所以我已经知道指出:“表达表示高阶衍生物(例如DFDX(DFDX(n)))的表达式不确定,而混合衍生物(例如DFDX(dfdy(n)))也是如此。”如果这样的表达不确定,是否可以在片段着色器中获得某些表达的高阶导数?

我听说DFDX从相邻片段中获取信息,并发现邻居的值与该片段的值之间的差异。也许有一种方法可以手动从附近的片段中获取信息?

我认为有一个公式可用于查找二阶导数:

(f(x+h,y+h) - f(x+h,y) - f(x,x,y+h) +f(x,y))/h^2

但我的问题是,我们如何获得术语 f(x+h,y+h) f(x) +h,y) f(x,y+h)?我们还如何获得 h ,片段之间的距离是哪个?

So I already know that the documentation for dFdx, dFdy, and fwidth states that "expressions that imply higher-order derivatives such as dFdx(dFdx(n)) have undefined results, as do mixed-order derivatives such as dFdx(dFdy(n))." If such expressions are undefined, is it possible to get higher-order derivatives of some expression within a fragment shader?

I hear that dFdx gets information from neighboring fragments and finds the difference between the neighbor's values and this fragment's values. Perhaps there is a way to manually take information from neighboring fragments?

I think there is a formula that can be used to find the second-order derivative:

(f(x+h,y+h) - f(x+h,y) - f(x,y+h) + f(x,y))/h^2

But my question is, how do we get terms f(x+h,y+h), f(x+h,y), f(x,y+h)? How do we also get h, which is the distance between fragments?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九局 2025-01-25 15:05:10

也许有一种方法可以手动从相邻片段中获取信息?

即使您可以(并使用

片段着色器在2x2 Quads中执行起诉,其中4个由4个彼此相邻的调用。衍生功能仅在四方中的水平/垂直片段中的数据之间差异。如果四方中的一个或多个碎片恰好在原始区域之外被栅格化,则仍然被执​​行(为了计算衍生物),但没有明显的效果。这些称为“助手召唤”。

无论如何,四边形中的调用只能与同一Quad 中的其他调用交谈。而且,如果您想获得更高的衍生品,则不仅需要从一个相邻的片段中进行采样。

Perhaps there is a way to manually take information from neighboring fragments?

Even if you could (and with some subgroup extensions, you can), it wouldn't help.

Fragment shaders execute invocations in 2x2 quads, with groups of 4 invocations that are directly adjacent to each other. The derivative functions merely take the difference between data in the horizontal/vertical fragments in the quad. If one or more of the fragments in a quad happens to be outside of the area of the primitive being rasterized, it still gets executed (in order to compute derivatives), but it has no visible effects. These are called "helper invocations".

Regardless, invocations in a quad can only talk to other invocations in the same quad. And if you wanted to get higher order derivatives, you would need to sample from more than just a single adjacent fragment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文