Seemless scaling with Polyvector

Previous topic - Next topic

Ian Price

D'oh - just posted exactly this in the other thread about this.
I came. I saw. I played.

bigsofty

#16
Hi,

The reason for the border is that the end texels don't know what is adjacent to them to calculates a decent anti-aliased pixel, as its on a separate tile .  What I have done here is to wrap to texture. I am not changing the UV coords or UV scale so the texture is not repeating but at the very edge, it uses the information at the opposite border to calculate a new smoother border.

This is done by IMPORTing the OPENGL "glTexParameteri" command and the required GL flags.

The result is no borders, yet retaining the smooth anti-aliased texture at any zoom level, for your tile maps.

Not sure if this is the standard way to do it but it seems to work.

Cheers,


Ian

P.S. I changed the demo to use a couple of textures to show how it works, a little more clearly too. Please see attached code.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

bigsofty

Whoops... here's the correct zip...



[attachment deleted by admin]
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Wampus

Quote from: Cliff3D on 2010-Sep-24
Try:

Code (glbasic) Select
SMOOTHSHADING FALSE  ::)

This should result in very sharp edges. Note though that as a reuls scaling up by a lot may look jagged.

Thanks for pointing that out. In most situations I would probably go with smoothness on with scaling but this is good to know.

Quote from: bigsofty on 2010-Sep-24
Hi,

The reason for the border is that the end texels don't know what is adjacent to them to calculates a decent anti-aliased pixel, as its on a separate tile .  What I have done here is to wrap to texture. I am not changing the UV coords or UV scale so the texture is not repeating but at the very edge, it uses the information at the opposite border to calculate a new smoother border.

This is done by IMPORTing the OPENGL "glTexParameteri" command and the required GL flags.

The result is no borders, yet retaining the smooth anti-aliased texture at any zoom level, for your tile maps.

Not sure if this is the standard way to do it but it seems to work.

Cheers,

That's great Ian. Very interesting. I played around a bit and the only thing I will say is that the extra-pixel border method looks a wee bit smoother on my PC. For some reason there is a slight yellow tinge at the edges the tiles using your routine. Its barely noticeable and can only really be seen when enlarging with the lighter tiles. I'll attach a modification of your routine to demonstrate. Press space to change between border method and glTexParameteri method. The method currently being used is displayed at the top left of the screen.

[attachment deleted by admin]

bigsofty

I can't quite see it, it looks OK to me but I am viewing on a very small netbook screen here?

Cheers,


Ian
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Wampus

Quote from: bigsofty on 2010-Sep-29
I can't quite see it, it looks OK to me but I am viewing on a very small netbook screen here?
That's good because no one is going to be seeing it on a tiny iPhone or iPod screen.  =D

bigsofty

Ha, that logical I suppose!  : :good:
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)