Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411275 Posts in 69323 Topics- by 58380 Members - Latest Member: bob1029

March 28, 2024, 08:47:37 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Direct X Texture Blur
Pages: [1]
Print
Author Topic: Direct X Texture Blur  (Read 8175 times)
handCraftedRadio
The Ultimate Samurai
Level 10
*



View Profile WWW
« on: June 19, 2007, 02:04:53 PM »

I am currently writing a 2D Game Engine in Direct X and I am having trouble with the textures, they seem to blur whenever I apply them to the polygons. I have tried many things to fix it but cannot seem to find the solution.

Original Image:


In Game Image:


The Blurring is very faint, but you can see it a lot better zoomed in.

Original:


In Game:


Any help would be greatly appreciated. Thanks.
Logged

Oddball
Level 10
*****


David Williamson


View Profile WWW
« Reply #1 on: June 19, 2007, 04:59:55 PM »

I'm more of an OpenGL man myself, but I believe to get pixel perfect 2D in 3D using DirectX you have to offset your textured quad by 0.5 of a pixel. Also ensure that one texel equals one pixel exactly.
« Last Edit: June 19, 2007, 05:02:19 PM by Oddball » Logged

Bad Sector
Level 3
***


View Profile WWW
« Reply #2 on: June 19, 2007, 06:01:43 PM »

What Oddball said. you just need to calc offx=0.5/screen_width, offy=0.5/screen_height and add these to your texture coordinates.

Also your ingame image seems a little smaller than the actual image.
Logged

~bs~
Chris Whitman
Sepia Toned
Level 10
*****


A master of karate and friendship for everyone.


View Profile
« Reply #3 on: June 19, 2007, 09:06:11 PM »

What those guys said, but also disable bilinear filtering, if it's on.

However, you will still get dropped or stretched pixel artifacts unless you adjust your texture coordinates correctly.
Logged

Formerly "I Like Cake."
Alex May
...is probably drunk right now.
Level 10
*


hen hao wan


View Profile WWW
« Reply #4 on: June 20, 2007, 01:37:51 AM »

There should be some way to change the magnification and minification filter from bilinear to nearest neighbour. That may help but if it's 1:1 on the screen and still blurring then it sounds like the texel issue to me.
Logged

handCraftedRadio
The Ultimate Samurai
Level 10
*



View Profile WWW
« Reply #5 on: June 22, 2007, 05:49:10 AM »

I have tried adding the offset, but nothing seemed to change. I also found that when I go full screen, the image appears perfectly, without any blurriness. And how do I ensure that one texel equals one pixel exactly?
Logged

Bad Sector
Level 3
***


View Profile WWW
« Reply #6 on: June 22, 2007, 06:41:49 AM »

Possibly your viewport (window client area/rendering area) is smaller in windowed mode than in full screen. As already said, your in-game sprite seems a little squashed when compared to your normal sprite.

Here is a hint: when you create your window for "windowed mode" do you take in account the window's borders and title bar size? When you ask Windows to create a new window, the size you request includes the borders and title bar, so the actual area you get to render in, is a little smaller than what you want.

In order to fix this (if this is the case), use the code:
Code:
RECT r;
int flags = WS_BORDER|WS_TITLE; // or other flags you may use
r.left = 0;
r.top = 0;
r.right = width;
r.bottom = height;
AdjustWindowRect(&r, flags, FALSE); // or TRUE if you use a menu

// and in your CreateWindow... //
win = CreateWindow("yourclass", "My uber game", flags, winLeft, winTop,
        r.right - r.left, r.bottom - r.top, NULL,
        NULL, (HINSTANCE)GetModuleHandle(NULL), NULL);

Obviously, AdjustWindowRect is what does the magic.
Logged

~bs~
handCraftedRadio
The Ultimate Samurai
Level 10
*



View Profile WWW
« Reply #7 on: June 22, 2007, 08:02:30 AM »

Yep, Bad Sector, that was the problem. Works perfectly now. Thanks a lot guys!
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic