Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


Textures are Blocky


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Endemoniada   Members   -  Reputation: 312

Like
0Likes
Like

Posted 01 February 2012 - 08:10 PM

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.

Sponsor:

#2 InvalidPointer   Members   -  Reputation: 1439

Like
0Likes
Like

Posted 01 February 2012 - 11:24 PM

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.

#3 Endemoniada   Members   -  Reputation: 312

Like
0Likes
Like

Posted 02 February 2012 - 02:05 AM

Here is an image, the texture is on the left, I'm simply rendering a textured quad, look how blocky it is:

Posted Image

#4 Tsus   Members   -  Reputation: 1046

Like
0Likes
Like

Posted 02 February 2012 - 03:01 AM

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.
  • 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.
  • Set the sampler state.
    SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR)
Cheers!

#5 Evil Steve   Members   -  Reputation: 1983

Like
0Likes
Like

Posted 02 February 2012 - 09:34 AM

What format is the texture in? It's not a DXT compressed texture is it?

Steve Macpherson
Systems Programmer

Rockstar North


#6 Endemoniada   Members   -  Reputation: 312

Like
0Likes
Like

Posted 02 February 2012 - 09:33 PM

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 ?

#7 Tsus   Members   -  Reputation: 1046

Like
1Likes
Like

Posted 03 February 2012 - 02:43 AM

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!

#8 Adam_42   Crossbones+   -  Reputation: 2560

Like
1Likes
Like

Posted 03 February 2012 - 04:07 AM

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.

#9 Endemoniada   Members   -  Reputation: 312

Like
0Likes
Like

Posted 03 February 2012 - 07:44 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS