如何在像素着色器中访问先前着色的纹理?

发布于 2024-09-02 07:30:27 字数 161 浏览 3 评论 0原文

在 WPF 中,我想使用像素着色器来修改合成图像,即覆盖在先前着色图像之上的新图像。新图像作为基本上透明的图像出现,除了有数据的地方(想想数学函数 - 正弦波等)。无论如何,这个过程需要非常快速地重复 - 将当前着色的纹理与新图像合成,然后对合成图像进行着色。问题是我不知道如何从着色器中访问先前着色的纹理。

In WPF, I want to use a pixel shader to modify a composite image i.e. a new image overlaid on top of a previously shaded image. The new image comes in as a largely transparent image except where there is data (think mathematical functions - sine wave, etc). Anyway this process needs to repeat pretty rapidly - compose the currently shaded texture with a new image and then shade the composite image. The problem is that I don't know how to access the previously shaded texture from within my shader.

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

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

发布评论

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

评论(1

小猫一只 2024-09-09 07:30:27

基本上,您需要在着色器中添加一个 Texture2D 变量,然后将该参数设置为在绘制新纹理之前需要访问的纹理(我不确定 WPF 中的该过程)。您可以执行以下操作:

//blahblahblah variables here
Texture2D PreviousTexture;
Sampler PreviousTextureSampler = Sampler2D { Texture = PreviousTexture; };
//blahblahblah code here

然后您可以使用 tex2D 调用对纹理进行采样。

Basically, you need to add a Texture2D variable in your shader, then set that parameter as the texture you need to access before drawing the new one (i'm unsure of that process in WPF). You do something like this:

//blahblahblah variables here
Texture2D PreviousTexture;
Sampler PreviousTextureSampler = Sampler2D { Texture = PreviousTexture; };
//blahblahblah code here

then you can sample the texture with a tex2D call.

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