Textures are Blocky

Started by
7 comments, last by Endemoniada 12 years, 2 months ago
Hi guys, I made a windowed app to create particle systems for my game and I can't figure out why the textures are blocky. I'm using pretty much the same code that's in my game where the textures are fine. The only difference is that the app is windowed.

I'm using D3DXCreateTextureFromFile() to load the texture.

I'm calling:

SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR)
SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);

The screen output is smaller than the texure, in fact, the smaller the output size is the worse the blockiness becomes.

What can be wrong ? This is killing me.

Thanks.
Advertisement
Pictures are worth a thousand words ;) This does sound filtering-related, though.
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.
Here is an image, the texture is on the left, I'm simply rendering a textured quad, look how blocky it is:

filteru.jpg
Hi!

Do you generate and use mipmaps?
Maybe your windowed app has another default value for the mipmap filtering.
This comes to my mind because Min and Mag filter alone can still produce visible edges at pixel centers.

  1. Allocate mip maps when you create the texture. (D3DXCreateTexture creates the full mipmap chain)
    If you use another function to create the texture, specify D3DX_DEFAULT for the parameter "MipLevels" to create the full chain.
  2. Set the sampler state.
    SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR)

Cheers!
What format is the texture in? It's not a DXT compressed texture is it?
I'm not using mipmaps and the texture is a standard 24-bit BMP created in photoshop.

I created a new simple app based off the tutorials and the texture is not blocky. I then used the exact same code in my other app and it is blocky. The only difference is that in one app (without the blockiness) the window is not a child window and in the other app (with the blockiness) the window is a child window.

I don't understand why that would make a difference.

Any ideas ?
Hi!

I can’t imagine that it makes any difference to Direct3D, where the window comes from.

I’d rather suspect that there is a difference in a render state or a resource parameter.
You could use PIX to check whether all states are in both apps the same.
Also make sure that the textures are created with the same parameters.
Perhaps not all members of the descriptions were written and you forgot to initialize them (e.g. by ZeroMemory). This could cause inconsistencies.

Besides, it would be better if you use mipmaps. Min and Mag filter won’t help you much if a texel after mapping to the viewport is more than two times smaller or bigger than a pixel.

Cheers!
If you look closely at the right hand image what's happened is that some rows and columns of pixels have been duplicated. I suspect the back buffer isn't the same size as the client area for that child window.
Hi guys,

Adam_42 is exactly correct. That's what the problem was. I was resizing my child window based on the mainframe's size but not resizing the back buffer. For now I'll just keep the child window a constant size until I learn how to resize the back buffer (maybe with Reset()?)

Thanks everyone, I wouldn't have figured this out on my own.

PS - thanks Tsus, I'm going to learn about mipmaps for sure now.

This topic is closed to new replies.

Advertisement