Skip navigation.

exploreopera

| Help

Sign up | Help

A Blag About Graphics and Programming and Stuff

Map Your Texels to Pixels!

Directly Mapping Texels to Pixels.
The main problem is, that when texels are not aligned to pixels, Linear filtering blurs the texture and it ends up looking ugly(a bit more info than the msdn article).

Another problem is that the is image is slightly offset. By 0.5 texels to be exact. This isn't really a problem if the resolution is high. But what happens if you want to stretch a low res texture on the entire screen?
Bloom is a perfect example: render something a small texture (128x128), blur it vertically (render to another 128x128 texture), blur the result horizontally (render to a 128x128 texture), stretch the result over the screen.

If you aren't aligning texels to pixels, the image is "slightly" offset three times. But surely that can't add up to anything noticeble?!
O RLY..? ("And don't call me Shirley" :wink:)
Without alignment:
With alignment:(Yes, the red circle thingy is blooming green, it's just to make the problem more visible)

As the articles state, all you have to do, is offset the vertices (or texture coordinates) by half a texel:
Pos-= 1.0/ textureSize* 0.5;

So if your render target is 800x600 and your texture is 128x128 you need to do
Pos-= 1.0/ 128.0* 0.5;


Have a nice day.

Demo: GPU FractalsSlimDX

Comments

avatar
Anonymous writes:

"Pos-= 0.5/128.0;" looks simpler. And you don't have to do this in D3D10 anymore.

By anonymous user, # 7. March 2008, 01:32:48

avatar
imbusy writes:

The last post was mine :smile:

By anonymous user, # 7. March 2008, 01:33:41

avatar
Yeah, forgot to mention that this doesn't apply to D3D10. And that reminds me that I should play around with D3D10 more...

By nerius, # 7. March 2008, 11:57:59

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

Please type this security code : 0a232c

Smilies

July 2008
SMTWTFS
June 2008August 2008
12345
6789101112
13141516171819
20212223242526
2728293031