Jump to content
  • Advertisement
Sign in to follow this  
Endemoniada

Textures are Blocky

This topic is 2508 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

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.

Share this post


Link to post
Share on other sites
Advertisement
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!

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!