So, I am trying to do something fairly simple. Copy the content from one texture into another and then copy the result texture inside the first. (I'll also do some additional editing on the result texture and that's why I am copying the result back).
But I am getting some strange results and the photo is loosing quality.
Here is the Compute Shader I've used:
Texture2D ObjTexture : register(t0);
RWTexture2D<float4> ObjResult : register(u0);
SamplerState ObjWrapSampler : register(s0);
[numthreads(32, 32, 1)]
void main(uint3 DTid : SV_DispatchThreadID)
{
float width, height;
ObjTexture.GetDimensions(width, height);
width -= 1; // X = [0 ... width-1]
height -= 1; // Y = [0 ... height - 1]
float2 uv = float2(DTid.xy) / float2(width, height);
ObjResult[DTid.xy] = ObjTexture.SampleLevel(ObjWrapSampler, uv, 0);
return;
}
and here is how I copy the result image back into the input one
ID3D11Resource * inputTexture;
inputTextureSRV->GetResource(&inputTexture);
mContext->CopySubresourceRegion(inputTexture, 0, 0, 0, 0,
mTexture.Get(), 0, NULL);
I also tried copying the first texture inside the second texture and use an Unordered Acess View from the first texture, but I got the same result ...
Is there something I am doing wrong here?
This is the original texture
This is the texture after ~60 passes
And this is after ~240 passes. This is 'the final result' because it doesn't change anymore.
As you can see, the image lost it's quality.