DGL
https://delphigl.com/forum/

2D Tip - Rotating/Moving a Quad
https://delphigl.com/forum/viewtopic.php?f=19&t=9226
Seite 1 von 1

Autor:  Stucuk [ Sa Mai 22, 2010 05:01 ]
Betreff des Beitrags:  2D Tip - Rotating/Moving a Quad

What iv recently noticed is if you rotate a Quad or move an object with floating point coordinates the quad's texture will look like it has artefacts as the edge pixels get merged together. The solution that i found was to modify my textures so that instead of having a completly transparent background to my images which will get rotated or moved i would have a background to them that has the lowest transparency possible and coloured with RGB(127,127,127). That way when the edge pixels are merged you don't notice any difference as there all the same colour + hard to see.

This has one slight problem, since the background pixels now have some solidity to them you can sometimes notice a lighter area where your texture is. To minimise this you can make it so the background part only extends say 4 pixels around the actual image and you can change the RGB used in the background (For dark backgrounds black is best).

Autor:  Coolcat [ Sa Mai 22, 2010 08:43 ]
Betreff des Beitrags:  Re: 2D Tip - Rotating/Moving a Quad

The reason for these artifacts is the texture filter which interpolates linearly between 4 neighboring texels. On the texture border it might happen that you interpolate say 95% of the border texel and 5% of a texel outside of the texture. If the outside texel differs a lot from the inner texel you will get artifacts. To avoid these artifacts there are several approaches:
  • Move your texture coordinates at the edges by a small epsilon inwards, say 1/20 texel.
  • You can set texture wrapping to GL_REPEAT or GL_MIRRORED_REPEAT. See glTexParameter. For GL_REPEAT obviously you need a seamless texture.
  • Extend the texture by a one texel on each side. If you don't have image data, just copy the border texels. In case you use anisotropic filtering you will need a 4 texel border for correct results. Of course you will need to adjust your texture coordinates. This approach is also used for Virtual Texturing to avoid artifacts between cached tiles.

Autor:  Stucuk [ Sa Mai 22, 2010 16:35 ]
Betreff des Beitrags:  Re: 2D Tip - Rotating/Moving a Quad

With images that have transparency(Which i was talking about) your solutions are wrong. OpenGL ignores the pixels which are fully transparent so the artefacts are not necessarily right on the edges of the texture. My solution works in all cases.

P.S GL_REPEAT is defaultly on and you still get artefacts. No clue about anything else you said with a non-transparent image, but i doubt they would help a non-transparent image.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/