Adaptive Background

Im trying to make an adaptive background shader.

But in the begining i see a curios thing, i dont know why but when i render with shader and loop in the queue render in the sader again it is offset in one pixel in X and in Y.

I need to make a transformation dependat of the render backbuffer to correct the error.

show you an example

BGAdaptive.rar (2.7 kB)

A liitle Update.

Know going to objetive there is another problem, i use a divisor make minimum adjust when the change it over threshold, i like if this number it bigger, but i loose a lot of presission because i only have an integer range between 0-256.

If i can get in memory float4x4 be great, but i dont know how JAJA

send you un update file.

You can see objects in movement make invisible, or try to this jaja

BGAdaptive.rar (2.9 kB)

Well im done for today
Im newbie in vvvv and this help me for practice and learn a lot of things a dont know.

Embed in code texture offset
Add new Control Parameters

Put here the last version, it works great for me, hope your feedback i upload…

BGAdaptive.rar (3.1 kB)

works nice, just a coding hint. the distance function returns a single float value that is the distance between the two vectors and the shader language allows to write vector calculations that work on all components of a vector very simple, the code can be reduced to:

float4 adapt(vs2ps In): COLOR
float4 col = tex2D(Samp, In.TexCd);
float4 col_back = tex2D(Samp2, float2 (In.TexCd.x+0.5/Width,In.TexCd.y+0.5/Heigth));
float tmp = distance(col_back, col);
float4 diff = col-col_back;

if (tmp > abs(HighThreshold))

return col;

Ty a lot for the hint, ill will update the code :)

i used to work with bg subtraction and lately i used a plugin by u7, here :)
It is GPU based and i’d like to make some test on patch i already know and use, can u update code and post the last version u have please ? thank u :)

I update the code

this line launch error, its keep as old version
if (tmp > abs(HighThreshold))

i put a TOGGLE button to get backgroung in first adjust, its a toggle because its an LFO dependat and with BANG dont work at every time.

BGAdaptive.rar (3.3 kB)

change tmp to a float type, not float4. like i explained, the distance function does not return a float4 type…

yes you are right, sorry missing that point.
The last

BGAdaptive.rar (3.2 kB)