Game Development Community

Blury Road and textures

by Rob Grubb · in Artist Corner · 08/20/2008 (8:58 pm) · 15 replies

Hey everyone,

Does anybody know how to get rid of the blur on this road, as soon as the road gets like 3-4 meters away from me the texture just blurs completely, a sort of similar effect happens with the brick wall layed on its side. Does anybody know how to make it sharp? in most games, road markings do not blur like this. see pic

i397.photobucket.com/albums/pp58/cyn9431/bluryroad.jpg

#1
08/20/2008 (9:09 pm)
Looks to me like poor texture filtering. I'm not very knowledgeable on the subject, but I'd assume you'd need to make some engine changes to play around with filtering methods.
#2
08/20/2008 (9:29 pm)
Anisotropic filtering.

Depending on your graphics card, there should be a setting for it. Also in Options there is FSAA (jaggy edge control) for the application itself. I prefer to tweak my card settings for better performance but be warned - Anisotropic Filtering eats performance.
#3
08/20/2008 (10:15 pm)
The problem isn't the filtering mode and aside from sucking up fillrate, anisotripic filtering won't help much.

The issue is that your using autogenerated mipmaps which do a simple bilinear filter without regard for the content of the texture. This fails to preserve the features of the road and as you get to smaller maps your texture slowly becomes a solid grey.

Have your artist generate the mipmaps by hand taking care to keep the stripes from bluring into the asphalt. Depends on your engine how you load those mipmaps, but for TGEA you can have him export a DDS file.

This fixes it really well and with a few tweaks you should get it looking nearly perfect.

Really any texture that has clearly contrasting lines or patterns should have artist tweaked mipmaps. If not you loose a ton of quality as the surface becomes perpendicular to the camera.
#4
08/20/2008 (10:52 pm)
Hey Matt and Steve,

FSAA is set to 4 in that screen shot with forced high res textures, so i now know it can't be fixed in the games options. I just noticed that it only blurs when I'm looking at the road at less than a 45degree angle. Here's a screen shot from above the road. Sorry i screwed the screen shot up.

i397.photobucket.com/albums/pp58/cyn9431/torqueroad.jpg
The exact same blur thing happens in 3dsmax 9 unless you turn down the blur setting in the material editor and that fixes the problem. I tried turning the blur down in 3dsmax and re-exporting the road to torque but the same blur comes back once in the tgea engine. Below are 2 renders from 3dsmax, the first is with the blur on default and the second is the blur turned down.

i397.photobucket.com/albums/pp58/cyn9431/3dsmaxsameblur.jpg
i397.photobucket.com/albums/pp58/cyn9431/3dsmaxblurreduced.jpg
Does anybody know if there is a way to turn blur textures off in TGEA?
#5
08/20/2008 (11:04 pm)
Hey Tom

Didn't see your reply, started replying to the others then had to run out for half an hour and didn't refresh. I'll have to put some research into creating mipmaps and ill post back here to let you know how we go. If we get lost and stuck i hope you can help us further. Thanks for pointing us in the right direction.
#6
08/20/2008 (11:10 pm)
No prob.

Yea... please post some before and afters. I've seen others ask this question and it would be useful for anyone searching in the future to see how to fix it.

... by the way you image posting problem is that your using IMG and not IMAGE.
#7
08/21/2008 (3:41 am)
Hmmmm okay I've hit a wall. I tried to make my own dds texture file using the plugin for photoshop from nvidia but kept getting the same blur. So I went over to the citylife game website and found a premade road dds file to use on my road for testing purposes. You can see the dds file in that forum for download. The screen shot JasonJ posted of the dds road in the game citylife looks superb. But in TGEA its the same old blurry road problem. Is there something i need to change in the torque engine code? Or is this just the way the torque engine renders textures?

http://www.citylifecrew.net/forum/viewtopic.php?f=4&t=53
#8
08/21/2008 (4:33 am)
Hi.


I remember seeing this same thing before when I was trying out the "8 textures for atlas" resource. If I recall correctly I disabled the mipmappin when loading/defining the texture in the C++ side and the textures went even overly crisp (sorry, don't have access to source code right now).

I assumed this would be fixed with the DDS textures but it sounds to me like they might be disregarding the pre-generated mip levels (?)
#9
08/21/2008 (8:15 am)
@Rob

I'll blame it on being rusty... i haven't looked at road textures since my stint making racing games 6 years ago.

Step one... absolutely use DDS with artist tweaked mip maps. Automip generation is evil for important high contrast textures.

I was right on that one... i just skipped two other important points. ;)

Two... drop some mip map levels. The texture from the forum post has 11 mips... from 1024x1024 to 1x1. About at 32x32 you start to completely loose the lines. You can build truncated mipmap chains in DDS and Torque will load and use them properly.

Three... use texture lod bias. This is exposed via GFX->setTextureStageLODBias(). The default is 0 for no bias. By setting it to negative values you can bias texture lookups by complete mipmap levels. This feature is not exposed to the material system at the moment, but i'll be sure to get that fixed in future Torque releases.

So here are some concrete results (click to see high res image):

farm4.static.flickr.com/3260/2783581551_60f4cf1018.jpg
This is the original DDS with 11 mipmaps and setTextureStageLODBias set to 0. You can see that the texture although high resolution quickly drops off to small mip levels and gets very muddy. Not a good result.

farm4.static.flickr.com/3105/2783580967_d6d5d73749.jpg
This the same texture with setTextureStageLODBias set to -2. This means that when it normally would use the 32x32 texture it will bias the mip lod down 2 levels to 128x128. While its vastly improved... it still looks a little crappy in the distance. We can do better!

farm4.static.flickr.com/3109/2783580223_ac2046ab9b.jpg
This is a modified DDS with only the first 4 levels... 1024,512,256,128... and using a setTextureStageLODBias at 0. You can clearly see the difference with distant elements being very crisp. Still around the mid-range it looks a little soft... lets try some bias!

farm4.static.flickr.com/3185/2784430918_5c598f9fba.jpg
Now this is looking good. Its the same 4 mip DDS using setTextureStageLODBias at -2. It looks sharp all the way into the distance. Maybe too sharp....

At -2 you get a little noisy shimmer when the camera moves. This is because you've lost the antialiasing that mipmaping provides. If you go higher it gets much worse. For really good looking mipmap lod bias you should also have FSAA enabled to fight this (in fact the LFS screenshot looks like it might have FSAA).

---

All this said... dropping mips and lod bias can really affect performance. One reason for mips is to reduce texture cache misses when sampling large textures that cover very few pixels on screen. What we've done here will make each pixel rendered on the road more costly.

As always measure the performance on your target systems and adjust. If needed you could slide the texture lod bias up or down based on system performance. You could even drop mips at game load time depending on system specs.

Hope this helps.
#10
08/21/2008 (9:21 pm)
Wow Tom,

First of all thanks so much for explaining this thoroughly. I currently only have access to the demo version of TGEA (buying the full version next week) so i can't see the GFX folder which i assume is in the source engine folder. So i cant test setTextureStageLODBias(), i did however get the mip map in the dds file to work properly like you explained. I grabbed the 1024x1024 image of the road and put it into a new photoshop doc, then i saved that image as a dds file with only 4 auto generated mip maps. This gave me this result, which is the same as you have shown.

i397.photobucket.com/albums/pp58/cyn9431/muchbetter.jpg
You mentioned here "You could even drop mips at game load time depending on system specs."

Does that mean its possible to get the same result as above without having to change dds file to only have 4 mip maps? Is there a way to change the torque engine to use only the first 4 mip maps? while still having the option to use up to 10 for example, for lower level systems>?

Can this setTextureStageLODBias() be used on individual materials? or will all the materials in the game receive the same LODBias?

Btw that would be cool to have the option to change the bias in the world editor.

Thanks so much again
#11
08/21/2008 (9:45 pm)
@Rob -
Quote:First of all thanks so much for explaining this thoroughly.
No prob... its as beneficial to me to explain it as it is for you to learn it. ;)

Quote:i assume is in the source engine folder
Yea setTextureStageLODBias() is a function on the graphics system object and you would have to have source code to access it. In my case i was working from some code that was directly rendering the surface... so i could tweak the texture stage however i liked it.

Quote:Can this setTextureStageLODBias() be used on individual materials?
In your case its more complex. I assume thats a DIF or DTS your player is standing on. You would need the material system to expose this setting to the Material() you created for the surface. Unfortunately thats not a stock TGEA feature at the moment... but i'll make sure it gets into the next release.

Quote:Does that mean its possible to get the same result as above without having to change dds file to only have 4 mip maps?
Not without modifications. You would either need to modify the DDS loader to drop them at load time or the GFXTexture to change the mip range at runtime. I haven't experimented with this myself... but it should be possible to do with a little coding effort.

Quote:Btw that would be cool to have the option to change the bias in the world editor.
Actually what i want to get working is a simple material editor accessible from the mission editor. It would make things a ton easier to work with. If only i can get some time to make it happen. :)
#12
08/24/2008 (2:22 pm)
This is great stuff, maybe you should put it up as a resource ;-)
#13
08/25/2008 (12:02 am)
Yeah this is really helpful stuff and very clear. If Tom doesn't have time to put this up as resource, I can put it up (just need to figure out how).Thanks once again Tom
#14
08/25/2008 (12:05 am)
@Rob - Feel free... actually i would suggest putting it up on TDN.
#15
12/19/2008 (10:13 pm)
I am trying to make a city, what would be the best way to do the street roads? making on 3dmax and export, or painting with torque terraing editor?

How can i make my own mipmaps and put it in to torque?

I just want the Tom Spilman quality.