Jump to content
  • Advertisement
Sign in to follow this  
cppcdr

Fuzzy images?

This topic is 4441 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to load a texture from a file using the D3DXCreateTextureFromFileEx () function. It works, but my images are fuzzy. I would like to be able to see the actual pixels instead of a blurry image. Anyone know why it is blurry?

Share this post


Link to post
Share on other sites
Advertisement
What dimensions are the image - both in the original file, in memory and how its rendered.

If you try to load non-2n dimension images into Direct3D it will sometimes (depending on flags and HW) resize it to the nearest 2n dimension. This can introduce some blurriness.

You can verify this by calling IDirect3DTexture9::GetLevelDesc(0, ...) to see what dimension it exists in memory. You can also use D3DXGetImageInfoFromFile() to check what dimensions its stored as.

When it comes to rendering there are two possible problems:

1. You're not following the "Directly Mapping Texels to Pixels" guideline (see docs for an article of the same name).

2. You're not rendering it exactly the same size, at which point the filtering mode you've selected (e.g. Linear, Anisotropic..) is re-sampling it from the stored dimensions to the rendered dimensions.

hth
Jack

Share this post


Link to post
Share on other sites
My texture is a 16x16 bmp (for testing) and I am rendering it to a 16x16 square.
Are there any flags that make this blurriness possible? Mayby I set one without thinking...

Share this post


Link to post
Share on other sites
Did you check this suggestion out:
Quote:
1. You're not following the "Directly Mapping Texels to Pixels" guideline (see docs for an article of the same name).

??

What texture and position coordinates are you using?

Jack

Share this post


Link to post
Share on other sites
Yes I read the article. I didn't understand all of it, but I got the thing about texture coords not being placed correctly at the corners...

But it's not just the corners that are blurred, it's my whole image.

As for the texture and pos coords, I have 4 verts with texture coords (x, y, z, u, v) that are respectively (0, 0, 0, 0, 0) (0, -5, 0, 0, 1) (5, 0, 0, 1, 0) (5, -5, 0, 1, 1).

Share this post


Link to post
Share on other sites
If the corners are not aligned, then the other pixels are not aligned as well. You must really make sure that all the pixels are being matched perfectly.

Anyway, you should disable texture filters (Linear, Anisotropic, etc) if you're not going to be using them.

Share this post


Link to post
Share on other sites
Your texture coordinates do not follow the results of that article, and I would put money on that being the reason you get blurry results [smile]

Offset by 0.5/width and 0.5/height respectively.

hth
Jack

Share this post


Link to post
Share on other sites
I have changed the texture coords, and I have not gotten better results (mayby a little better, but not much).
Here are the new coords (0, 0, 0, -0.5/1024, -0.5 / 768) (0, -5, 0, -0.5/1024, 1-0.5/768) (5, 0, 0, 1-0.5/1024, -0.5 / 768) (5, -5, 0, 1-0.5/1024, 1-0.5/768).


Here are some photos that show the problem (I am comparing to maya because I am making a modeler)...
My version
Maya's version

Share this post


Link to post
Share on other sites
Seems you´re using texture filtering. Try setting the min and mag filter to D3DTEXF_POINT using SetSamplerState, that could help.

Share this post


Link to post
Share on other sites
hmm, somethings not making sense here...

Your image looks more like something to do with linear filtering..

Quote:
I have 4 verts with texture coords (x, y, z, u, v) that are respectively (0, 0, 0, 0, 0) (0, -5, 0, 0, 1) (5, 0, 0, 1, 0) (5, -5, 0, 1, 1).
So you're specifying your vertex positions in 3D space - not pre-transformed? And you're defining a 10x10 grid (-5..+5) for a 16x16 texture.

How are you making sure that the final rasterized results are a 1:1 mapping? Even if your texture coordinates are correct, if the final rasterized quad is not a 1:1 (16x16 in this case) area then you'll get stretching that'll get smoothed out by the linear filtering.

Try setting it to POINT filtering.

hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!