Archived

This topic is now archived and is closed to further replies.

Scaling 2D Textures without the blurring

This topic is 5823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
A workaround would be to draw the sprites big (4x), and only scale down. Not good for memory though, I suppose...

Share this post


Link to post
Share on other sites
That''s not really an option I would like to consider really - it would waste a LOT of memory and be very limiting.

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
SetTextureStageState(0, D3DTSS_MAGFILTER , 0);

Was what I was looking for, it works great. Thats for pointing me the right direction.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites