0

I am trying to re-texture an image on top of a series of images using HLSL and a UV render pass, but the resulting images have a number of artifacts (Overall pixelated image, aliasing artifacts within the image).

The background and the UV-pass can be found in an album here

resulting image:

I am guessing that the issue is with the MIP levels and that I somehow have to calculate them for each frame, and my question is simply how would one go about doing that, can this be done in the pixelshader?

Here is a quick rundown of what I am doing:

float4 UVPass = UVSRV.Sample(SamplerWrap, input.Tex);
float4 Background = backgroundSRV.Sample(SamplerWrap, input.Tex);
float4 Composit = compositImageSRV.Sample(SamplerWrap, saturate(UVPass));

Then using the alpha of the UVPass as a mask, I decide if I should return Composit or the Background.

My sampler uses D3D11_FILTER_MIN_MAG_MIP_LINEAR.

  • What artifacts do you mean? Why not use standard alpha-blending instead of choosing either of the layers? – Nico Schertler Jul 07 '16 at 10:26
  • The composited image is severely pixelated and aliased compared to the source image. Obviously the edges would look better when some form of alpha-blending is implemented to smooth them out, but I the issue I am focusing on is the aliasing that can be seen on for example the visor and in his beard. – Konglobemeralt Jul 07 '16 at 10:37
  • Can you verify if the texture is uploaded in the correct size and that mipmaps are created? What happens if you render the image in a traditional way? – Nico Schertler Jul 07 '16 at 10:42
  • When rendered using the UV of the quad I get this: [link](http://i.imgur.com/n9nPA0n.png) I have looked in the graphics debugger and it appears as if the standard 10 MIP levels are created. – Konglobemeralt Jul 07 '16 at 12:13
  • Are you sampling the texture inside an if-statement or for-loop or similar structure? – Nico Schertler Jul 07 '16 at 12:21
  • Everything is sampled directly when the pixelshader runs, as can be seen in the codebox. The only if statements I have are the ones checking the alpha of the UV-pass. – Konglobemeralt Jul 07 '16 at 12:28

1 Answers1

0

Solved it. The issue was not caused by the code, but by Maya tonemapping the UV pass causing the artifacts. The code itself works.