I’ve implemented a FreeType font renderer. Using OpenGL anything looks
like expected, but when I try to render same text with Direct3D9 i got
some texture artifacts.
The text looks like cut of at bottom and some letters contains texture
fragments at the border edges:
Test text rendered with OpenGL
Test text with artifacts rendered with Direct3D9
I use Bilinear filtering (linear/linear/point) and set UV texture
addressing mode to CLAMP. First I thought there may be addressing
failures and also test
WRAP and BORDER, but I got same issues.
The letters I use for text rendering are rendered to an atlas texture.
Could it possible I got those artifacts while I do not use padding space
the lettes in this atlas texture? If it so, why only on D3D9? Any ideas
what could be wrong?
Please log in or register to post a reply.
Seems like you may be getting bitten by the infamous half-texel offset
of D3D9. See this MSDN
for details - the upshot is you have to adjust your UVs by half a texel
to make them line up correctly with screen pixels. In D3D10-11 they
fixed this so it works the same way as OpenGL does (also known as the
correct way. :D)
Thanks for your advise. I’ve to check this.
As promised I’ve checked your advise and it solves the problem! Reedbeta
thank’s again for your help, you protect me from sleepless nights ! :D
Just one more question concerning to the half-texel offset:
I have read a couple of articles that describe the necessity to move the
texture one half unit of the vertex positions in order to get the
correct mapping between texels and pixels. According to DirectX
documentation, offsetting by half a pixel is only necessary “when
rendering 2D output using pre-transformed vertices”. But how I could
figure out that I’ve got pre-transformed vertices? On vertex buffer
declaration I do not use the FVF flag. So I get into trouble if I always
try to fix the half-texel offset by adding -0.5 to x and y values of the
vertices (especially using OpenGL).
I think by “pre-transformed” vertices it just means vertices that are in
screen space already, such as the quads for text. Another common case is
when doing a full-screen pass for postprocessing. When rendering 3D
stuff you don’t typically have to worry about it.
Screen space only, sounds easy to fix. Thanks again.