Shader feedback undesired scroll


I am trying to build a shader (my first one) which will require feedback. Before trying to implement what I need I decided to build the simplest possible feedback shader based on Mr.Benedikt example “difference_textures” copying the feedback trick from his other example “game_of_life”.

I created a new technique which simply does a bypass based on the feedback texture and much to my surprise the result is a dissolving scroll moving down and to the right.

First I thought the problem was related to the scale applied to the Shader and tried to tweak its value without success.

Now I rest clueless looking at the feedbacked texture scroll and dissolve into something useless for my purposes.

Here attached I send the patch, shader and textures. The technique I created is called “feedback”.

What am I doing wrong? how to make a feedback which results in a stable image?

Thanks in advance,

CrossfadeShader.rar (31.0 kB)

this is a half pixel default shift by a your graphicscard. you fix it either in the advanced options of your video driver (called ‘alternate pixel centers’ or so) or by translating the texture by a half pixel.

i wouldnt use the advanced options, as you would need to set it on any computer where you need to run your patch. and on any computer where this flag is set, all correct patches would show the scrolling effect. so its a good thing graphic card vendors hide this option deeper and deeper in the control panals…

thanks for the info, cracked me up a while ago, too.

Hi, thank you all for the replies. Also, Mr. Benedikt replied directly sending me a example patch and suggesting that I could correct this by adding a small offset to the calculations outside and/or inside the shader, like tonfilm had suggested.

Actually none of this really worked. But I found the solution (I guess by chance) in another of Mr.Benedikt’s example: Game Of Life.

Having added feedback to this example I noticed that unlike the others, this one was immediately stable. Comparing the code I found out that the way the “sampler” was declared was different:

In Game Of Life:

{CODE(ln=>1)}sampler ReferenceSamp = sampler_state
Texture = (ReferenceTex);
MipFilter = None;
MinFilter = Point;
MagFilter = Point;
AddressU = wrap;
AddressV = wrap;

In my example:

{CODE(ln=>1)}sampler SampReference = sampler_state
Texture = (Reference);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;

To be honest I still didn’t investigate on what each of these mean, but I tried to change it and found out that if MagFilter is set to Point instead of LINEAR the feedback is immediately stable.

So, now, having set MagFilter to Point, everything works fine.

Thank you all for helping me!


POINT basically switches interpolation off.
using the wrong coordinates in POINT mode might reduce the bug to only one horizontal or vertical line.