Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Sa Dez 21, 2024 17:44

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: 2D Tip - Rotating/Moving a Quad
BeitragVerfasst: Sa Mai 22, 2010 05:01 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
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).

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: 2D Tip - Rotating/Moving a Quad
BeitragVerfasst: Sa Mai 22, 2010 08:43 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 29, 2005 12:28
Beiträge: 2249
Wohnort: Düsseldorf
Programmiersprache: C++, C#, Java
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.

_________________
Yeah! :mrgreen:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: 2D Tip - Rotating/Moving a Quad
BeitragVerfasst: Sa Mai 22, 2010 16:35 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jul 21, 2004 22:39
Beiträge: 360
Wohnort: UK, Scotland
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.

_________________
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.009s | 16 Queries | GZIP : On ]