PDA

View Full Version : Texture distortion



SoulSharer
11-17-2012, 01:01 PM
http://img69.imageshack.us/img69/9773/defaq.png

What could cause that?
Any ideas?

This stuff happens when I use subregion from an atlas texture. (font atlas in this case)

Tried applying offsets, like I did for DirectX9.0c before (where I was mapping texels to pixels), however this strategy doesn't seem to work here. =(

Thanks.

Dark Photon
11-18-2012, 12:01 PM
Let's see an image of your atlas. Are you using premultipled alpha blending?

Mikael Ara
11-19-2012, 08:09 AM
hey, I don't know what you did in code, but you should try normalizing and unitizing your texture, i can suggest glm loader.
From the other side, you should not use textures for your text, it will be better to use this (http://www.lighthouse3d.com/tutorials/glut-tutorial/bitmap-fonts/).

Mike

tonyo_au
11-20-2012, 12:11 AM
From the other side, you should not use textures for your text
http://www.angelcode.com/products/bmfont/ is a good bitmap font system - particularly if you use distance fields

tanzanite
11-20-2012, 11:54 PM
Tried applying offsets, like I did for DirectX9.0c before (where I was mapping texels to pixels), however this strategy doesn't seem to work here. =(Tried? As-in, did not in original attempt? OpenGL and Direct3D different here - be sure you do it the OpenGL way (well, the default way for OpenGL).

Just in case reference: (0,0) is where all the texture corners meet (when tiling) - _exactly_between_ the corner texels themselves. Ie, per dimension:

texel_center_texcoord = (texel_nr + 0.5) * (1 / texture_size)

The same is true for screen coords (in normalized device coordinates, [-1,1], (0,0) is the bottom left corner of the bottom left pixel) - be sure it is also correct in regards of your texture sampling.

SoulSharer
11-23-2012, 06:08 AM
Thanks everyone, I've managed to handle the problem before post was approved by moderator. I was converting to premultiplied alpha with a typo in code, found out when looked up texture stored on device (with debugger).