Sign in to follow this  
Weesals

Nvidia GPU quality issue

Recommended Posts

My game(s) in the past have been rendering fine with ATI, but recently I got a new laptop with Nvidia 9600M GT and Intel 4500HD, I'm not sure why but my textures appear to be reading in at a lower res than they were created. The scene below is first rendered to a render target texture created with D3DXCreateTexture(d3d,1024,768,1,D3DUSAGE_RENDERTARGET,D3DFMT_A2B10G10R10,D3DPOOL_DEFAULT,&texture); and then rendered to the screen at 1024*768 using the following pixel shader sampler GSampler = sampler_state { Texture = <GTex>; MinFilter = point; MagFilter = point; MipFilter = none; }; float4 PSFunct( float2 Tex0 : TEXCOORD0) : COLOR0 { return tex2D(GSampler,Tex0); } ATI: [img]http://weesals.fiffa.net/Images/ATIs.png[/img] Nvidia: [img]http://weesals.fiffa.net/Images/Nvidias.png[/img] Intel: [img]http://weesals.fiffa.net/Images/Intels.png[/img] The same happens if I use the fixed function pipeline, is there some limitation with creating render targets of non-power-of-2 sizes? Am I missing a parameter in D3DXCreateTexture? When I get back, I'll try to post up a demo of the problem so people can run it and look at the code I'm using, although it should be pretty standard. EDIT: Sorry about the images not working

Share this post


Link to post
Share on other sites
Try changing:

MinFilter = point;
MagFilter = point;
MipFilter = none;

To:

MinFilter = linear;
MagFilter = linear;
MipFilter = linear;

Point filtering almost always looks awful when using it for anything other than 2D sprites.

Share this post


Link to post
Share on other sites
That does fix it, however that makes the whole scene look blury, and rendering a render target texture the same size as the screen to the screen should not need linear filtering (especially not mip mapping, that would lose more quality)

Share this post


Link to post
Share on other sites
My fault. I just assumed that those textures on your 3D models were being drawn with point filtering. For the copying of the render target to the back buffer you do want point filtering, but you'll also want to take into account the offset pixel centre in D3D9 - see http://msdn.microsoft.com/en-us/library/bb219690(VS.85).aspx

Since those screenshots aren't full size I'm not certain, but you may also have forgotten to call AdjustWindowRectEx() to make the client area match the back buffer size (1024x768).

Share this post


Link to post
Share on other sites
I assume using the fixed function pipeline wouldnt require setting the offsets for pixels, so its probably not that.

As for the call to AdjustWindowRectEx, I was actualy missing that, instead i was grabbing the window and client sizes and trying to compare them to get border size, then resizing to include border sizes ( :S )

I have a working demo of this issue at http://weesals.fiffa.net/Files/D3DTestbed.cpp. After running you should see a triangle with jagged edges (caused by this render to texture issue)

It seems to be limited to non-square texture sizes, I hope there is a way around it so that I can keep using arbitrary render target sizes.

Thank you for your help so far :)

Share this post


Link to post
Share on other sites
That's a very common problem that people have when mapping texels to pixels
Your second pass does a 1:1 mapping between texels in your rendertarget and pixels on the screen and you need correct adjusting of screen coords.

The fact that it "works on ATI" is just by accident.

Mapping texels to pixels (NV)

Mapping texels to pixels (MS)

They basically tell you the same thing. Your screen is a grid, sampling happens at regular interval on that grid. If you position your geometry such that the sampling happens exactly in between two texels, chances are that you're going to sample the wrong one (varying based on floating point approximations).

LeGreg

Share this post


Link to post
Share on other sites
Quote:
Original post by LeGreg
That's a very common problem that people have when mapping texels to pixels
Your second pass does a 1:1 mapping between texels in your rendertarget and pixels on the screen and you need correct adjusting of screen coords.

I've removed the pixel shader, but still get the issue. Just tried offsetting the quad positions by .5/size, and using a shader to offset pixel reads .5/size, by but doenst help :(

The code is at http://weesals.fiffa.net/Files/D3DTestbed.cpp

EDIT: oh my, it works :D, it was as LeGreg said, requiring to offset the texture coordinates by .5/size. I'm not sure why doing it in the shader didnt work, but I dont care as long as it works :D

Thanks LeGreg and Adam_42 :)

[Edited by - Weesals on November 20, 2008 9:47:52 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this