Author Topic: Disabling DirectX 11 makes picture fuzzy  (Read 28849 times)

soulburner

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 22
    • View Profile
Disabling DirectX 11 makes picture fuzzy
« on: December 06, 2014, 09:04:31 AM »
Here's a short reproduction:
  • Create a new project, import NGUI, create 2D GUI
  • Set "Game" view to 1280x720
  • Set UI Root to "Constrained" scaling and "fit heigth 360" (you may also set width=640, no fit)
  • Create a pixel-perfect texture, set Point filter and RGBA32 bit
  • Create UI2DSprite and set your imported picture, set default coords (0,0,0)

That's it.

Then, switching DirectX 11 in Build Settings->Player Settings will turn bug on and off.

In my case I'm using a sharp checkboard texture.

It is perfectly OK in DX11 is on.

But when I switch it off, I get this:



The lower-right triangle is OK, but the top-left one is broken.

I'm confused. Its OK with any other height I set: 720, 180, 90, etc. But when I set height just 50% of my window size, I get this.

I can't change the resolution of my project. It should be exactly x2-pixel-size at 1280x720 resolution.
Programmer at LazyBearGames.com
Making Punch Club and Graveyard Keeper

soulburner

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #1 on: December 06, 2014, 09:29:35 AM »
PS: Dividing UI Root height by 2 and setting it to 180 and setting UI Camera size to 2 fixed the issue.

But that's very strange anyway.

Seems like the reason is floating point numbers somewhere in the engine...


PS: Nope, that didn't fix the issue in all cases. In some rare cases I still have sprite fuzzyness.
« Last Edit: December 06, 2014, 01:08:30 PM by soulburner »
Programmer at LazyBearGames.com
Making Punch Club and Graveyard Keeper

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #2 on: December 06, 2014, 09:18:21 PM »
Isn't that perhaps just the DX9 half pixel offset? Try to move a parent game object by 0.5 on either axis and see if that helps.

see more http://drilian.com/2008/11/25/understanding-half-pixel-and-half-texel-offsets/

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #3 on: December 06, 2014, 10:29:37 PM »
Constrained root = UI will never be pixel perfect to begin with.

After switching from DX9 to DX11 or vice versa you need to hit Play to refresh the changes.

soulburner

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #4 on: December 07, 2014, 06:21:53 AM »
Isn't that perhaps just the DX9 half pixel offset? Try to move a parent game object by 0.5 on either axis and see if that helps.

see more http://drilian.com/2008/11/25/understanding-half-pixel-and-half-texel-offsets/
No, that is not related to half-pixel offset. That was my 1st guess and I tried to move the camera with no result.
Programmer at LazyBearGames.com
Making Punch Club and Graveyard Keeper

soulburner

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #5 on: December 07, 2014, 06:27:46 AM »
Constrained root = UI will never be pixel perfect to begin with.
So, what's the solution?

I've got GUI drawn in 640x360. So, I want it to be pixel-perfect in two resolutions: 1280x720 (exactly x2) and FullHD (exactly x3)

After switching from DX9 to DX11 or vice versa you need to hit Play to refresh the changes.
When I tick DX11 checkbox the window with apply settings appear. The picture changes after I click "Apply" button. Further pressing "play" doesn't change anything.
Programmer at LazyBearGames.com
Making Punch Club and Graveyard Keeper

soulburner

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #6 on: December 09, 2014, 12:27:55 AM »
Any ideas?

Here's the example project (you need to import NGUI for yourself): https://www.dropbox.com/s/ipx07yyt3y0c0rd/NGUI_bug.zip?dl=0
Programmer at LazyBearGames.com
Making Punch Club and Graveyard Keeper

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #7 on: December 09, 2014, 01:50:58 PM »
Pixel perfect means it corresponds to actual pixels on the screen 1:1. What you are trying to do is not pixel perfect by definition. I'm not sure what solution you are looking for here. As I mentioned, after changing from DX9 to DX11 and vice versa you need to actually hit Play for the changes to take effect properly.

soulburner

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #8 on: December 10, 2014, 05:36:01 AM »
Pixel perfect means it corresponds to actual pixels on the screen 1:1. What you are trying to do is not pixel perfect by definition. I'm not sure what solution you are looking for here. As I mentioned, after changing from DX9 to DX11 and vice versa you need to actually hit Play for the changes to take effect properly.
I'm getting fuzzy pictures (as an image in the 1st post shows) in the described situation in DX9 mode. No matter - in editor, in play mode or in compiled .exe
Programmer at LazyBearGames.com
Making Punch Club and Graveyard Keeper

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #9 on: December 11, 2014, 08:44:26 AM »
Of course you do. And I've mentioned it twice already. Constrained = not pixel perfect.

Want crispness? Use a Flexible UIRoot.

soulburner

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #10 on: December 12, 2014, 03:32:54 AM »
Sorry for misunderstanding, but what's the solution?

I've tried to use Flexible or Constrained modes. The result is always the same when the screen resolution is 720 height and my GUI height is exactly 1/2 of it.

I thought I have a simple situation - I've got a GUI drawn in 640x360 and I want it to be exactly double-pixel in 1280x720.

The best solution I have for now is set constrained height mode with height = 18, and camera size = 20. In this mode I've got the minimum amount of artefacts, but still got some.
Programmer at LazyBearGames.com
Making Punch Club and Graveyard Keeper

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #11 on: December 12, 2014, 11:34:22 PM »
I just did a test.

1. New scene.
2. ALT+SHIFT+S to create a sprite, set to tiled, overlay the whole screen. This also created the UI that defaulted to flexible style.
3. Double-checked the game window, made sure its using even dimensions (1600x900 in my case). Using odd dimensions that don't divide by two cleanly = problems.
4. Sprite is crisp.
5. Switched to DX11, hit Play to refresh. Sprite is still crisp.

soulburner

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #12 on: December 17, 2014, 12:13:38 PM »
I just did a test.

1. New scene.
2. ALT+SHIFT+S to create a sprite, set to tiled, overlay the whole screen. This also created the UI that defaulted to flexible style.
3. Double-checked the game window, made sure its using even dimensions (1600x900 in my case). Using odd dimensions that don't divide by two cleanly = problems.
4. Sprite is crisp.
5. Switched to DX11, hit Play to refresh. Sprite is still crisp.

I just did it too.

1. New scene, imported my GFX (in point filter mode) http://gyazo.com/c0028cd07f40de3490bf14d205f39bce
2. ALT+SHIFT+D (Unity 2D Sprite!!), set the sprite, clicked "Snap", no tiling
3. Used my dimension (1600x900 doesn't have a bug): game window 1280x720, flexible max/min height = 360 (exactly divided by 2)
4. Hit play, no problems
5. Switch DX11 off, hit play

problems:

http://gyazo.com/638734e18cc8a86dd4c9312f039f1f27

sprite settings: http://gyazo.com/f9b014f04ffdd2b855f23e7424ef6f29
sprite png itself: http://gyazo.com/0c9dcef2960d656e89e92022163215d5
Programmer at LazyBearGames.com
Making Punch Club and Graveyard Keeper

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #13 on: December 17, 2014, 03:26:34 PM »
Flexible set to min/max of 360 is the same exact thing as using Constrained = not pixel perfect.

soulburner

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: Disabling DirectX 11 makes picture fuzzy
« Reply #14 on: December 18, 2014, 02:57:33 AM »
Then I don't understand  :(

So, I need my GUI to be excactly double-sized pixel-perfect in 1280x720 resolution. How do I make it? What settings should I set? Other resolutions don't matter.
Programmer at LazyBearGames.com
Making Punch Club and Graveyard Keeper