How to access previously shaded texture in a pixel shader?

In WPF, I want to use a pixel shader to change a composite image, i.e. a new image, overlaid on top of a previously hatched image. The new image is delivered in the form of a transparent image, except when there is data (think of mathematical functions - a sinusoid, etc.). In any case, this process needs to be repeated quite quickly - now make up the 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 my shader.

+4
source share
1 answer

Basically, you need to add the Texture2D variable to your shader, and then set this parameter as the texture you need to refer to before drawing a new one (I'm not sure about this process in WPF). You are doing something like this:

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

then you can try the texture with tex2D call.

+2
source

Source: https://habr.com/ru/post/1310011/


All Articles