TexToTex transform

I’m trying to transform one texture to another.
Algorithm is simple:
a).calculating color difference of pixels between these two textures
b). adding/subtracting the certain value to color value in first texture to get necessary color value (like in second texture)
c). if adding/subtracting value is small, then it possible to get fluent transformation from one texture to another (because shedders ere executing 60 times per 1 second it means that if adding/subtracting value is in sixty(for example) once smaller then difference, then transformation time will be exactly 1 second)

But it’s theory.
In practice I have something strange.
And I hope it’s just my mistakes.

When I’m trying to transform one texture to another (pic1 to pic2) I’m getting next result (pic3)
And even when I’m trying to transform one texture to itself (in theory nothing should happen) I’m getting the same strange result (pic4).
Where is the problem?

PS All files are in textotex.zip.

textotex.rar (15.9 kB)

the problem you see comes from texture filtering. in your setup the magnification filter comes into account which is set to LINEAR in all your texture samplers. set it to POINT and try again.

btw. i don’t quite get what you are doing. is it more than simply blending between two textures? blending could be achieved much simpler:

float4 result = color1step + color2(1-step);
result.a = 1;
return result;

if what you are doing is more sophisticated i just didn’t get it.

hi max!

i simplified the effect for you.
and i put in the POINT filtering:

sampler BlackTextureSamp = sampler_state
{
Texture = (BlackTex);
MipFilter = POINT;
MinFilter = POINT;
MagFilter = POINT;
AddressU = wrap;
AddressV = wrap;
};

and the same at the WhiteTextureSampler and the grey one.

if haven’t seen this page yet, you should have a look. it is quite useful stuff…

more links

greets to moldova,
sebastian

BlackToWhite.fx (4.6 kB)