Fuzzy images?

Started by
12 comments, last by raytracer03 18 years ago
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?
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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...
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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).
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.
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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
Seems you´re using texture filtering. Try setting the min and mag filter to D3DTEXF_POINT using SetSamplerState, that could help.
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement