OK, so we’re back to the definition of “pixel-perfect” textures again. You’re really asking for a texture which can scale to multiple different sizes without blurriness, which is different from what most people mean when they say “pixel-perfect” textures.
There are only two ways to achieve this: (1) ship your game with different resolutions of the texture, one for each resolution that your users will run the game in, and use the appropriate texture according to the game resolution. Or (2) enable anisotropic filtering.
Anisotropic filtering is available on virtually every graphics card in use today. It does not really have much performance cost, especially if you only use it for a few onscreen buttons.
No? Actually I want a single resolution without blurriness ( “the pixel perfect resolution”) and other resolutions with smoothing. Of course it can[t look pixel perfect in higher resolutions, thats just common sense. And you explained me that scaling it down will cause blurriness because 3d hardware uses a low quality filter by default. Okay.
You also said that some blurriness might occur if panda scales it to the next bigger power of two, but like I said if I enable non power of two textures, the blurriness is still there. And its the same if I used power of two textures on a computer which doesnt support power of two textures, right? So blurriness in this case shouldn’t exist, but its still there. This one confuses me.
Well, the fundamental principle is: you have to ensure that the original texture is applied one-to-one on a card of the appropriate size. All of those cards appear to be the same size, yet you say the textures are not the same size? How can this be?
If you create a texture, and apply it to a card that is sized so that the onscreen size of the card is the same size as the original texture, then there should be no rescaling and therefore no need to apply any filter.
Uh, these images were taken with screencapture and added to a single image. I would need to exit my application and edit the Config file each time, wouldn’t I?
They are all, except the power of 2, to which I just added transparent canvas, the same size.
Have you tried setting the minfilter attribute to NEAREST as drwr suggests, but not magfilter? This should interpolate the texture only at higher resolutions.
Actually when you scale an image down there should be some smoothing, otherwise it will look ugly.
But I tried anyway and it looks even worse, on 800x600 screen
Yes the image is 200x64. The ‘power of two’ image has transparent borders added, but it is still generated with egg-texture-cards so the geometry is the same size.
Like I said I photoshoped the results to a single image.
Hmm, OK, I begin to see the problem. I think what is happening is that when you set “textures-power-2 none”, and Panda asks your driver to load a texture of 200x64 pixels, then the driver itself is actually scaling the texture internally to 256x64 without telling us, and in doing so it introduces the blurriness you see.
To avoid this, I think you’ll have to go with always using power-of-2 textures. Assuming you only want to use the leftmost 200 pixels of a 256-pixel texture, you’ll need to create a card that’s 200/256 units wide, with UV’s ranging from 0 to 200/256. You can’t do this with egg-texture-cards, so you’ll have to create the appropriate cards by hand, for instance with CardMaker, or by hand-editing the egg file generated by egg-texture-cards.
Increasing the multisamples enables your driver’s built-in antialiasing. If that’s causing blurriness, then it’s your driver’s fault, not Panda’s, and the only way to disable it is not to enable antialiasing in the first place (by not increasing the multisamples, for instance).
Does this happen with your hardware too?
I remember blurriness on all PCs I tried, I’ll try again.
Oh… I rather have them blurry. Don’t know about other engines, but when I didnt know programming I was into modding games and dont remember images with transparent borders.
Increasing the multisamples enables your driver’s built-in antialiasing. If that’s causing blurriness, then it’s your driver’s fault, not Panda’s
[/quote]
I’ll try this on other hardware too.
Indeed it does. And now that I look more closely, I see the true source of the problem. It is the line:
model2.setX(-0.092)
This is shifting your polygon by 0.092 units, which moves it off of a precise pixel boundary onto a position halfway between two pixels. Since your window is 800 units wide, you will have to always move it by an integer fraction of 800, for instance 0.09. Making this correction snaps your text into focus.
You don’t need to paint transparent borders. Simply don’t use the part of the texture that’s beyond the size you want. Cut off the card before the texture gets to that part of it. That’s what I mean by adjusting the UV’s.
That’s a funny thing to say. It’s always an option, it’s just a question of what you’re willing to trade for it. But it’s your code, after all. For the record, increasing the multisamples has no effect on blurriness on my hardware.
With all the menus and submenus and gui elements I use I’m afraid I cant use such numbers in all cases.
I’ll have to change the GUIs look. And I think thats just wrong.
What?
meh, the things I’ll trade for it are important. thats why its not an option.
At least that.
Anyway I’ll try on other hardwares too
Of course you can. If you were using integer pixel numbers, you wouldn’t have any trouble using integers always, would you? It’s the same thing. You just have to divide the integers you would have used by 300 each time.
(Note that I gave you the wrong calculation above–because you are parenting to aspect2d, where the x coordinate is scaled to match the y coordinate–you have to always ensure your offsets are an integer divisor of 300, not 800.)
Or, parent all of your gui elements to pixel2d, which allows you to use integer coordinate numbers. But then you’ll have to rescale them by yourself if you want them to change size with the window, and you’ll need to use different parameters to egg-texture-cards.
Or, introduce your own child of aspect2d which has a scale of 300, then you can always use the same integer coordinate numbers no matter what the size of the window.