View Full Version : Way to change filter when loading images
Traveler
20-09-2007, 08:55 PM
Hi Andreaz,
Again I have a question for you :)
I've uploaded this image
http://upload3.postimage.org/181080/soccerplayer.jpg (http://upload3.postimage.org/181080/photo_hosting.html)
(The jpg compression has made this sample a tad bit worse, but it'll still do.)
The right soccerplayer including the grass behind it, is actually from a screenshot taken while running a demo made with Phoenix.
The left soccerplayer is added in photohop, to make it clear what it is actually supposed to look like.
As you can see, the right image is more blurred. It is especially visible on the t'shirt.
I was wondering if there is a way to load the images they way they are, without any filtering applied to them.
Thanks,
Diaboli
20-09-2007, 10:05 PM
i've been thinking about that too, though i didnt really understand why my sprites were of so much lower quality.
(originally 24x32 pixelart-sprites, that gets blurred... strange artefacts now and then)
Andreaz
21-09-2007, 04:56 AM
There's two ways of doing that, if you want to do it for all images use
Uses phxTexture;
setDefaultTextureFilter (tfNearest, tfNearest);
ImageList.LoadImage(...);
or for a single image
TPHXTextureManager.getInstance.setFilter(tfNearest , tfNearest);
ImageList.LoadImage(...);
However, they aren really loaded with a filter, the pixeldata is untouched after the loading. But the filtering appears when streching the texture, whitch is defined with the texture magnification and minification functions.
Traveler
21-09-2007, 10:40 AM
Thanks for the quick reply. I'll give that a try later today, when I get home from work.
Traveler
21-09-2007, 08:28 PM
An update on my previous post.
The suggestion to call setDefaultTextureFilter improved the sprite slightly.
However, the real solution was actually to resize the image.
I found out that I had accidently cropped the spirte to the odd size 200x214. Once I had it corrected to 256x256 things went back to normal again. :)
Andreaz
22-09-2007, 10:04 AM
Ah, i see, the good old non power of two problem :)
Diaboli
22-09-2007, 02:27 PM
well, my problem is still there. maybe it doesent have anything to do with this at all?
i sometimes get artefacts from the above animation (in the spritesheet), and there seems to be some blurring of the sprites themselves.
http://thorins.net/prob4.png
heres one of my spritesheets:
http://thorins.net/bodies.png
any suggestions as to what is causing this?
Traveler
22-09-2007, 05:01 PM
Your spritesheet is 288x256pixels. I'm not sure if that is also what you're using in your game, but I think you would get better results using a size of 256x256
Diaboli
22-09-2007, 05:54 PM
I dont do any resizing at all, so there really shouldnt be any problem.
each sprite is 24x32pixels, and 24 does not add up to 256.
i dont see any reason for having spritesheets that are uniform in sixe either, as long as the sprites fit and have the correct spacing.
(mine is automatically created, so sizing and spacing is allways correct)
I have used these spritesheets with unDelphiX and Gamemaker, and they work there, so why not with phoenix?
heres a pic of the char as it is in phoenix, and they way it should be
http://thorins.net/prob4-2.png
Andreaz
23-09-2007, 09:50 AM
I dont do any resizing at all, so there really shouldnt be any problem.
each sprite is 24x32pixels, and 24 does not add up to 256.
i dont see any reason for having spritesheets that are uniform in sixe either, as long as the sprites fit and have the correct spacing.
(mine is automatically created, so sizing and spacing is allways correct)
I have used these spritesheets with unDelphiX and Gamemaker, and they work there, so why not with phoenix?
heres a pic of the char as it is in phoenix, and they way it should be
http://thorins.net/prob4-2.png
Its not a problem regarding resizing or streaching, it's a limitaion of the software in the modern GPU's, for speed resons they work best with textures that are power of two (32x32, 64x64 128x128 256x256). And as phoenix renders images as textured quads instead of plotting pixels such artifacts occur.
I know that some other libs to the resizing on load time, but I've decided not to for a few reasons, it messes with the patterns and takes time.
I dont know about gamemaker, but DelphiX doesnt use the 2D in 3D approach wich is why it works there, in DelphiX state changes is not an issue either for the same reason.
So resize the texture to the next power of two size and try again, it could be good to add a 1px border between each pattern aswell, but the latter can be helped with the texture filter as above.
One thing to note is that the non power of two textures work good on some hardware but far from all...
Diaboli
23-09-2007, 02:31 PM
So if I resize my patterns to 32x32 (blank space on both sides of characters), and put some spacing between petterns, it will look better?
will it help if i in addition to that resized the spritesheet to the double size (so that a 32x32 sprite becomes a 64x64 sprite)?
Thx for the help! :)
Traveler
24-09-2007, 09:02 AM
I'm not sure if its the patternheight -width that should be a power of two as well, but the texture as a whole should be. (in your sample from Sep 22 it's 256x256)
Andreaz
25-09-2007, 06:48 PM
I'm not sure if its the patternheight -width that should be a power of two as well, but the texture as a whole should be. (in your sample from Sep 22 it's 256x256)
Pattern sizes doesnt matter, only texture size does
jdarling
25-09-2007, 07:06 PM
Your problem is from the render width of the sprite itself. Take a look at your rendered sprite in Pheonix and your 24x32 charas sprite sheet. The widths of the two are different (almost 4 pixels). Thus you are getting "Smooth Scaling" and thats not what you want. Make sure that when you render your sprites you are rendering them pixel for pixel.
Reading some of the other information, it also appears that you have overlapping pattern rectangles. Try scaling your images by hand in Photoshop to Power of 2 (I use 512x256 for Charas sheets) and see if things get cleaned up. If they do, then likely Phoenix isn't properly remembering the original image dims when it up scales the image.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.