Of course, this is the coda thet puts the watermark/message in the original texture:
Dx's HLSL code:
this is the shaders that makes the detection of the watermark:
It works perfectly when the device is the REF reference software rasterizer, however, fails when using HAL device. Sometimes it returns inverted bit patterns, and often completely fails and returns random bit patterns.
The watermark texture is a black A8R8G8B8 texture. His n-th texel has b = 255 if the n-th bit of the watermark is 1, or 0 otherwise.
With REF rasterizer, after the detection phase I should obtain a black texture with white texels where a even odd number (watermark = 1) was found. There sould be no clues of the original image, only a bit pattern.
However, with HAL device, after the dection phase the result texture is like this:
regards
Dx's HLSL code:
Code:
struct PS_INPUT {
float2 uv : TEXCOORD0;
};
sampler image : register(s0); // original image
sampler watermark :register(s1); // texture containing the bit pattern of the watermark in the blue channel
float4 main (PS_INPUT In) : COLOR
{
float4 pix1 = tex2D(image,In.uv);
float4 pix2 = tex2D(watermark,In.uv); // read the bit
float tmp = floor(pix1.b*255); // transform it to integer space
if(pix2.b == 0) // it is a 0?
{
pix1.b = ((int)tmp/(int)2)*2; // then put an even number in the output image's blue channel
}
else
{
pix1.b = ((int)tmp/(int)2)*2+1; // put an odd value
}
pix1.b = pix1.b/255; // un-transform to float
return pix1; //put value
};
this is the shaders that makes the detection of the watermark:
Code:
struct PS_INPUT {
float2 uv : TEXCOORD0;
};
sampler image : register(s0);
float4 main (PS_INPUT In) : COLOR
{
float4 pix1 = tex2D(image,In.uv); // read texel
pix1.b = floor(pix1.b*255); // transform to integer
float tmp = fmod(pix1.b,2); // calculate module
if(tmp == 0) // if module was 0, the number was even
{
pix1 = 0; // so put a {0,0,0,0} to the output
}
else
{
pix1 = 1; // it was a odd number: put white {1,1,1,1} to the output
}
return pix1;
};
It works perfectly when the device is the REF reference software rasterizer, however, fails when using HAL device. Sometimes it returns inverted bit patterns, and often completely fails and returns random bit patterns.
The watermark texture is a black A8R8G8B8 texture. His n-th texel has b = 255 if the n-th bit of the watermark is 1, or 0 otherwise.
With REF rasterizer, after the detection phase I should obtain a black texture with white texels where a even odd number (watermark = 1) was found. There sould be no clues of the original image, only a bit pattern.
However, with HAL device, after the dection phase the result texture is like this:
regards