Scaling 2D Textures without the blurring

Started by
7 comments, last by GD 22 years, 3 months ago
I have just started upgrading my 2D game to 3D using Direct3D, unfotunately Im having some problems. My game uses small sprites which are then scaled up in size 4 times. For example the main character is 16x16, but scaled to 64x64 in the game. Under DirectDraw this worked ok, but in Direct3D whenever I scale up the textures I have problems. For a start they appear very blurred, and some sprites have small black lines around them. All Sprites are stored on large "sprite sheets", these are bitmaps with lots of sprites on. So when I want to draw a sprite I have to copy a rectangular section from the sprite sheet to the screen. Im using the ID3DXSPRITE class to draw the sprites, do anyone know how to scale the sprites without any blurring? Also does anyone know why there are small black lines around some of the sprites? Any help would really be appreciated. -GD
Advertisement
A workaround would be to draw the sprites big (4x), and only scale down. Not good for memory though, I suppose...
That''s not really an option I would like to consider really - it would waste a LOT of memory and be very limiting.
well if you''re enlarging an image/texture you need to ADD data, which effectively means that you need to make up some pixel data between the pixels that you actually KNOW the colour of... therein lies your problem... you cant really get around the blurring very easily... You''re usually okay upto 2x enlargement, beyond that you''re having to make up alot of data...

Jack;

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I dont need to add data, I dont mind if it looks "blocky" (where you can see each pixel with no blending). Thats the look im going for, if you enlarged an image in DirectDraw like that it wouldnt try to blend the pixels, but Direct3D does.

Its like if you zoom into an image with something like PaintShop Pro, and all the pixels get bigger, thats the kind of effect I want.
G''day!

I don''t have docs handy, so this will be in pseudo-DX. When you call d3dxsprite->Begin() it sets all of the renderstates, and I believe the magfilter is one of ''em, so what you have to do is:

d3dxsprite->Begin();
SetRenderstate( MAGFILTER, POINT);
d3dxsprite->Draw();
d3dxsprite->End();

That should do it.

Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
Just turn off bilinear filtering. I don''t know D3D, but I assume this is what DrunkenHyena''s suggestion was.
SetTextureStageState(0, D3DTSS_MAGFILTER , 0);

Was what I was looking for, it works great. Thats for pointing me the right direction.
Ok, the above worked on Windows2000, but I just complied it on WindowsME and it still uses Bilinear Filtering, anyone know why?

Stooopid windowsME, why would it be any different?

This topic is closed to new replies.

Advertisement