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 www.HiEnd3D.com/demos.html. 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.


[prev]
Image of the Day Gallery
www.flipcode.com

[next]

 
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.
 
Flawless

April 18, 2002, 11:15 AM

Very nice!! :-)

I'm looking forward to try doing this!!

 
Frank Krueger

April 18, 2002, 11:22 AM

Very nice algorithm! I agree, games have been getting a bit "muddy" lately, the high contrast given here is refreshing. The only problems I see are aliasing effects when the images get very small. However, those same effects appear with bilinear, so I'm sure some mip-mapping scheme built into your software renderer will clear that up..

Great work!

 
ecko_53

April 18, 2002, 11:26 AM

Very impressive, the demo crashes on shut down tho, p3 gf2go

 
Rasmus Christian Kaae

April 18, 2002, 11:26 AM

Uhm, you could also do a bicubic spline interpolation of the colours, that would save the trouble of finding adjacent texels.

 
Potato

April 18, 2002, 11:28 AM

How about letting us see the original 2048x1024 image for comparison?
Really looks excellent.

 
Squint

April 18, 2002, 11:29 AM

Does that texture tesselate all the way around, or does it get messed up on the back?

I think it's quite clever anyway ;)

 
lycium

April 18, 2002, 11:30 AM

cooool! :) a very nice idea!

 
CGameProgrammer

April 18, 2002, 11:38 AM

I've been thinking about things like this. I really hate the full-texture blending, and currently the only way around it is to split the polygon into several, and render each one with a different texture, which is very slow and also limited. Something like this is really cool.

I wonder, can it be implemented in a pixel shader? I've never written a shader, plus I only have a GeForce2 so I can't. But maybe it's possible to write a pixel shader that applies this effect when a texture is magnified?

 
memon

April 18, 2002, 11:41 AM

I've got a .zip dated somewhere in the 1999 which contains the same stuff (by the same author) :) But anyway, it's as impressive as it was back then.

 
=[Scarab]=

April 18, 2002, 11:58 AM

The smart filtering demo looks ultimately cool. Very nice job.

BTW, I'd also be interested to know if this can be done in a hardware shader.

 
Politik

April 18, 2002, 12:02 PM

I'd like to see this on a texture with more fine detail.

 
Navreet Gill

April 18, 2002, 12:08 PM

Good Work!

Your webpage does a lot better job explaining how the technique works :).

Simple and effective =)

 
Alexander Blach

April 18, 2002, 12:08 PM

Really impressive! I hope that the next video card generation can do this in hardware.

 
Fil

April 18, 2002, 12:10 PM

hehey nice work, it resembles photoshop's dust and scratches!

Fil.

 
mikie

April 18, 2002, 12:10 PM

This is quite interesting, but on the other hand might not suit many situations.

Also the image could just as well be a 4bit image which could have huge dimensions - thus not need any of this.

Or it could be a big compressed texture of some kind.

who needs such huge textures, as geometry increases - textures
can become much more 'base' items - including interesting multitexturing to add dirt and stuff.

And think of the memory sizes for future graphics cards..

I think processor/gpu time should be put towards more interesting things - procedual effects.

Mikie

 
MaxSt

April 18, 2002, 12:11 PM

Thanks for kind words, folks.

2 Rasmus Christian Kaae :
I have to trouble finding texels. :)
"Bicubic color interpilation" sounds like a lot of trouble to me. :)

2 Potato :
In some next version I hope to write an interactive analizer, so everybody could try their own texures.

2 Squint :
No mess! Just download the demo, you'll see.

2 CGameProgrammer and =[Scarab]= :
I implemented function selection in switch-case fashoin, and I heard that currect hw pixel shaders do not support conditional statements. Maybe it would be possible in HW in not-so-distant-future.

2 memon :
Haha! That 256-colors-badly-dithered-cube-spinning DOS stuff? :)
That sooo 20th century... Try the new one! Cheers! :)

Maxim Stepin.

 
Fant

April 18, 2002, 12:19 PM

Hi you lamers ;)

This filter is a fake. Just change the included TGA-File any see by yourself.

fun...
fant

 
Kurt Miller

April 18, 2002, 12:25 PM

">>This filter is a fake. Just change the included TGA-File any see by yourself. "

Did you read the description of how it works? ;]

 
MC BAXTON

April 18, 2002, 12:26 PM

That may be horribly slow
Just because I think so

 
MaxSt

April 18, 2002, 12:29 PM

No, it is not. :)

You may wonder, why I used 32-bit TGA, not 24-bit? Because there are some additional information hidden in 4th channel. Just open this TGA file in Photoshop, choose "Channels" tab - and you'll see what I'm talking about.

Maxim Stepin.

 
Fil

April 18, 2002, 12:37 PM

I don't know much about shaders, but if the problem is "no conditional" it can be made with functions...

if var is integer, in stead of:
switch(var){
case 1:
45
case 2:
30
case 3:
75.2
}




we could have the slower, more complicated, unreadable version:

= __max(2-var, 0)*45 + (1-var%2)*30 + __min(var-2, 0)*75.2;




And like I said I don't know much about shaders so I can't even garantee this is "doable"

PS - I am not going to exemplify a version of this with out the use of __min() and __max(), but the modulus(%) is quite handy for that

 
coda

April 18, 2002, 12:40 PM

This is very nice.

I approve.

 
noxa

April 18, 2002, 12:48 PM

I find it interesting that my FPS is the same using all 3 methods - because of this, I can't really tell the speed tradeoff of your method: do you know? I would imagine that using your texture filtering would be a bit slower than just dumping the texture out, but by how much?

(And doing this in a pixel shader would be really cool :)

 
KieranIsOK

April 18, 2002, 12:50 PM

??

 
Peter Mackay

April 18, 2002, 12:56 PM

This is really cool. I'd love to see this in hardware!

 
MaxSt

April 18, 2002, 12:59 PM

What's your exact FPS number? Is it the same as your monitor refresh rate, by any case?

Anyway, try moving the model closer (using left mouse button), FPS should drop down.

What's your computer configuration, by the way?

Maxim Stepin.

 
nemes1s

April 18, 2002, 01:03 PM

nice looking demo. I like your choice of object and texture. looks like a paper box for real.

 
Olio

April 18, 2002, 01:49 PM

Cool looking, but is it good for more than just big outlines?-)

 
[-WD40-]

April 18, 2002, 01:55 PM

Good work, that's the most impressive thing I've seen for a long time.

Excellent work.

Keep it up!

(btw your demo crash upon exiting...Win2k/128mb ram/GeForce 256 ddr)

 
Twig

April 18, 2002, 02:01 PM

Mine changes a little - between no filtering and smart filtering it drops from about 18 to 14 fps if i'm zoomed in, or from about 50 to 40 fps if i'm zoomed out... and there's hardly any speed difference between biliniar and smart filtering which is pretty impressive

Mine also crashes on exit though - gf2gts, xp

 
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.