Not logged in, Join Here! or Log In Below:  
News Articles Search    

Submitted by Maxim Stepin, posted on April 18, 2002

Image Description, by Maxim Stepin

One day I realized that implementing texture magnification by using simple bilinear filter is just not good enough. Very often, a texture contains several color-uniform areas with apparent borders between them and these borders get blurred as the rest of the texture. Just start any modern FPS game, move a character very close to a wall with some sign on it, and if the texture resolution is not high enough, you_ll experience a "bad eyes" effect - everything looks too blurry, you don't see any sharp borders anymore.

In order to solve this problem, I developed my own "smart" texture filter. It keeps borders between color-uniform areas look sharp regardless of texture magnification level and, at the same time, keeps interiors of those areas as smooth as bilinear filter does.

The idea is to use independent interpolation function for each group of four adjacent texels. I developed a set of such functions - most of them describe how border(s) intersect the interval between these texels_ centers. To determine, which function to use for each group of four texels, some additional information needs to be stored along with a texture. In my demo, I used 8 additional bits per texel for that purpose. Because these interpolation functions describe pretty much a sub-texel level of the texture, on preprocessing (analyzing) stage I had to use a much bigger version of the same texture. For example, for this demo I analyzed 2048x1024 image to get the final 512x128 texture with correct interpolation function information.

You can find the demo and full source code at I used software rendering for obvious reasons, so please don_t expect very high speed. Artwork is inspired by M.C. Esher drawings.

Fell free to ask any questions. Comments and suggestions are very welcomed.

Maxim Stepin.

Image of the Day Gallery


Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

April 18, 2002, 02:16 PM

I thought this crash-on-exit bug was fixed... apparently not.
Only happens with Win2000 and WinXP. That's a problem... I only have Win98...
If someone with Win2K could help me solve this, I would be very appreciated.


Ron Bakker

April 18, 2002, 02:21 PM

Quite original .. haven't done that yet.
Great !!!

- Ron


April 18, 2002, 02:21 PM

Heh heh - I just tried rendering difference clouds for the alpha layer in photoshop - it made quite an interesting effect ;)

I would love to try out some other textures though to see how it copes in different situations...

Very very impressive!


April 18, 2002, 02:30 PM

Looks awesome!

One thing, though - when you zoom out from the figure a long way, the lines that are so clear when zoomed in are broken - I know this is something that happens when you zoom out from 3D figures normally, but do you think that you could make it so that the outlines stay constant? I mean, The figures in the picture are solid color surrounded by black outlines. The outlines should get thinner, not dotted, and the color stays the same.

I still think it looks awesome.

Oh, and about the "crash-on-exit" thing. I think it has something to do with the screen resolution.


April 18, 2002, 02:33 PM

I must agree with everyone (except mc baxton, as usual...), this is very impressive! One of the most interesting thing I saw here.
Nice work!

Sniper BoB

April 18, 2002, 02:39 PM

cool, call up nVidia and demand hardware support!


btw- closing the app resulted in a WindowXP error report. I am running XP Home, amd 1600xp+, 512 ddram, geforce 3


April 18, 2002, 02:42 PM

I knew someone will ask this qwestion... :)
My answer - Yes, it also good for all sort of "DANGER" signs too. :)

I have an idea for the next version - "soda can" model with authentic "Coke" or "Fanta" texture. With an option to create and assign your own texture - that would be fun.

Maxim Stepin.


April 18, 2002, 03:01 PM

great work, I must also second that this is one of the most interesting post I've seen here. Hope Nvidia and ATI will adopt it for hardware.

Looks alot like marching squares in my eyes (maybe >alot).

keep it up


April 18, 2002, 03:01 PM

This paperbox is cool

it is almost that cool like usual paper boxes which are cool as well.

They are cool because people who make it are cool
People are cool just because paper boxes are cool
paper boxes are cool just because people who make it are cool
I am cool because I decided to be cool



April 18, 2002, 03:14 PM

supply me with the original , and I will show you why it is pointless


April 18, 2002, 03:16 PM

">> With an option to create and assign your own texture"

So how did you create the Lizard-texture?


April 18, 2002, 03:17 PM

I mean you have wasted 8bits of data on the alpha channel to encode the image..... the whole thing is 32bit... it is like a crime - it could all done in 4bits and increase the quality of the inner filtering!


April 18, 2002, 03:18 PM

you are even sillier than me. and that's quite hard.

Andreas Magnusson

April 18, 2002, 03:29 PM

Yes it's a magic tga-file. It makes everything possible, I myself did a program with global illumination for a complete city in realtime. The only bad thing was that I had to use this texture everywhere!


April 18, 2002, 03:29 PM

Very Cool, I thought about doing something similar with my own rasterizer, it's essentially an extension to those old monochrome image scaling routines, The Black Book of Graphics coding contains a whole lot of documentation on it. Great work, maybe if I have the time when I get home, I'll take a peak at the source and see if I can sort out your win2k issues. That is if someone else doesn't get to it first :)



April 18, 2002, 03:30 PM

Change following:

if (wParam==VK_ESCAPE)
PostMessage(hWnd, WM_CLOSE, 0, 0);
return 0L;


if (wParam==VK_ESCAPE)
PostMessage(hWnd, WM_CLOSE, 0, 0);
return 0L;

It is the easiest way to fix this.


April 18, 2002, 03:34 PM

Oh my g.., the "i need sleep" bug. *schlägt sich gegen den kopf*

start your "my i is my interpreter" parser and you will see that "code" is "cpp". Realy ;)

Andreas Magnusson

April 18, 2002, 03:35 PM

Oh, and MaxSt great work btw. I really like it, I've always been disturbed by the blurryness of textures close-up. Now I just have to wait for more advanced pixel-shaders... (though 38 fps is probably not so bad on an AMD1.4GHz, in this case)


April 18, 2002, 03:42 PM

First of all, I mesuared some elements of M. C. Esher "Lizards" tiling.
Then I wrote a "generator" program to render big 2048x1024 texture - mostly Bresenham lines + some flood filling. Lines ware 5 pixel thick. Then I used my "analyzer" program to convert each 4x4 pixels block from this image to 1 pixel + 1 another byte (this byte describes what's going on inside this 4x4 pixels block) of resulting image. That's basically it.


April 18, 2002, 03:51 PM

A very interesting work, at least in the theory field.
It would be interesting to see a hardware accelerated implementation (by card programmability or supported natively by the hardware), so it becomes an applicable way of texturing to everybody in every situation required.

I think it's a really good work to write a white paper about it and patent it :-)


April 18, 2002, 04:01 PM

okay, okay - sorry for my post ;)

i've dont got that 4th layer =)

thanx a lot


April 18, 2002, 04:17 PM

access denied


April 18, 2002, 04:25 PM

This is very neat. But have you thought that you may have also created a interesting image compression algarithim.


April 18, 2002, 04:25 PM

I haven't looked at the source, but would it be possible to pull this off with hardware using pixel shaders? The extra 8 bits could be stored in the alpha channel.

Manuel Astudillo

April 18, 2002, 04:26 PM

I wonder if this filtering technique could be used in video playback. For example, when you have a low resolution video and you want to make it bigger without blurring the image too much.
I know that the divx codec uses some kind of filters to blur the macroblocks, but it would be also nice to have some kind of filter like yours to improve quality when runing videos at fullscreen.




April 18, 2002, 04:28 PM

I'll upload the original (2048x1024) texture in few hours, if you insist. ;)

You'll see that 512x256 texture with smart filter looks almost as good as 2048x1024 texture with bilinear filter. So smart filter makes sense - it helps dramatically reduce resolution without big quality sacrifice.

Maxim Stepin.


April 18, 2002, 04:31 PM

What a chance. A few days ago I was thinking how sucky bilinear interpolation is and was seeking what alternatives could be done.

Your results are pretty good. But it looks like impractical in its curent form(8bits of xtra info., preprocessing, need for a bigger texture etc.).

To beat the blurring effect of bilinear interpolation you have to use more local information I think. May be a local directional gradient finding(on a 3x3 window edge detector maybe) during initialization. And using a local weighted averaging( definitely bigger than a 2x2 window, maybe 5x5 ) during rendering was the first thing that came into my mind.

Using a bigger texture to start with is the biggest cheating possible I think ;) Preprocessing is not a big problem actually, because it can be done in hardware during the texture loading. Also the xtra information needed is not a big deal if you cant make it calculated automatically.

Anyway, your results are great.


Rasmus Christian Kaae

April 18, 2002, 04:50 PM

Hmm, yes, the bicubic spline interpolation would slow down the process, but i'm quite sure that rendering a slope will give you a nicer detail level than if you simply bicubically interpolate the colours.

As an example, you can try the zoomer-software from, which uses the mentioned technique.

zed zeek

April 18, 2002, 05:03 PM

my gut reaction (something from nothing)
im having great difficulty in seeing how this will work (surely its an impossiblity practically?)

btw i havent downloaded the demo (which i will do)


April 18, 2002, 05:11 PM

This is great work!

But I'm surprised nobody's yet mentioned that a similar effect can be acheived using 2 passes with alpha testing on the second pass. Sure, it's probably not quite as nice looking, but it's already in-hardware. It will still have a "rounded" jaggieness to it, but at least you'll have nice crispy edges.

This thread contains 118 messages.
First Previous ( To view more messages, select a page: 0 1 2 3 ... out of 3) Next Last
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.