1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Blurry textures

Discussion in 'Bob's Track Builder' started by ThreeDays, Dec 10, 2009.

  1. Hi, everyone,

    Here goes another question that strikes me as having a simple answer, but I can't find it.

    I have created a bunch of textures for tarmac with lots of different lines (pit in, pit out, solid, dotted, grid, etc) and they all appear blurry when I'm driving on the track in RFactor. They're OK when I'm almost on top of them, but as I approach them they always appear blurry.

    Funnily enough, I have also created textures for metal and concrete barriers and I don't have that problem. As far as I can think, I've created them following the same process as with tarmac.

    Any thoughts?

  2. That sounds like MIP map bias. Are you running anisotropic filtering in rF? You can sharpen them up well with a MIP map bias of -4, but that doesn't gell too well with anisotropic filtering, which gives a nicer result.

    check it out on wiki:

    It's a trade-off between sparkly and blurry textures, which seems to be solved with anisotropic filtering. There is a current thread here about negative MIP map bias and anisotropic filtering:

    so, you're probably better off making your track with a MIP map bias of 0 on the roads, and running anisotropic filtering in rFactor (if you aren't). Other people might be able to offer you more info.
  3. Thanks, woochoo. I've had to look up a bunch of words in your reply :D, but at least now I know something I can fiddle around with.
  4. Kris Vickers

    Kris Vickers
    Hardware Staff

    I had this same problem, and it took me ages to figure out it was the mips lol

    I just have a single layer texture as track surface now. Its not so much of an FPS hit yet, and it looks very clear.

    Would be interesting to know what problems it could cause though....anyone?
  5. Can anyone help with subject. Please.
    I have the same problem.

    I would like to also find out more about track surface LOD? What is it, and how does it work. Link anyone?

  6. I am no expert on this and far from it, but I have been researching it for a while now and this is basically what I have come up with.

    LOD is Level of detail, it covers a few different areas in the game, in this instance we are talking about mipmap bias lod. which means what level of detail do you want the mip map to cut in.
    Mip map works like this, Main image, mipmap 1 (slightly smaller and a little blurier image of the main), 2, (smaller again), 3 etc, 4, etc, 5, etc, till you get down to a 4 pixel image 2x2 and some times a 1 pixel image, with each mip map the image is shrunk that little bit more.
    The quality of the mipmap is determined when you save the dds file. (Much like most filtering when resizing, bilinear etc). You can also manually make mip maps, which is a lot of effort but your effort is rewarded because you get exactly what you want. The amount of mipmaps (how many mipmap levels are made) is also determined when you save the dds.

    Mipmap bias tells the mipmap when to cut in, normally the mipmap would cut in at x meters and so forth, The main image would stay in view till it hits x meters then the game engine would remove the main image and load up mipmap 1, mipmap 2 would be x + x meters, mip map 3 would be x + x + x meters.
    By setting the mipmap bias to a negative value you prevent the mipmaps from cuting in at x meters, if you set the bias to -1, mipmap 1 would then kick in at x + x meters, mipmap 2 woudl be x + x + x meters and mipmap 3 at x + x + x + x meters.
    This gives you a crisper image when you look into the distance, but at a cost,, you start getting jaggered edges and shimmering, which is then when anti alias transparency needs to be used which sucks up a lot of processing power.

    When utilizing the mipmap bias in the game, you need to make a decision on who your audience is. If you are aiming for the general market then you want to be careful how low you set your mipmap bias, If you are aiming for a market that has high performance computers then a negative mipmap bias will give very nice clear crisp images.
    In general, I have decided to go with 0 mipmap bias and if I find mipmap 1 is too blurry, I manually edit the mipmap to fix it up.

    I would highly recommend to use mipmaps and not a flat image, not only does it make things look smoother, but it puts less load on the system, loading up a full texture takes a lot of resources, a mipmap is a smaller texture hence it uses less resources.

    A good experiment to do is using a road with white lines on the side. make a black texture and put white lines on each side but leave a bit of black at each side (much like the existing road textures in game), use 000000 for black and ffffff for white to make it stand out. Save 3 different versions of that image all at dxt1 no alpha with generated mipmaps.
    In BTB, make 3 roads side by side with a straight and an S curve, make one road texture mipmap -4, make another -2 and the other 0. Load it up and you will see what I mean. Take some screenshots for reference.

    Then go to your display control panel and turn anti aliasing transparency to super sampling and put your AA as high as you can 16 Q if possible and override any game setting. Fire the game up again and have a look, take some screenshots for reference, then compare the screenshots.

    Something this experiment will not demonstrate is how much of an effect AA transp. can have on fps. If you want to see, load a heap of different objects into the project, trees, people, cars, etc etc, make it a lot so it starts to strain your fps, then try the difference between AA transp. off and on.

    You can go on and on with experimenting, you can try huge textures 2048x2048 and small textures 256x256, in all, believe it or not, 256x256 looks better than 2048x2048, because if you think of it,,, look at your monitor, how big is it? mine is 1280x1024, i don't really need a texture any bigger than that anyway and I am never looking at the road with it filling my full screen, most of the time the road is only showing on less than a quater of my screen which means that in reality, it need to be no bigger than 256 x 256. A 2048 x 2048 texture becomes jaggered and shimmering. Because it is being shrunk down and is having to use on the fly filtering in the process, which can be quite random.

    I will have to force myself to stop here, I cant stop myself from typing as there is so much to be said about this subject, I think I have covered most of it. I hope it helps.
  7. Thaks mianiak for taking time and explaining this :)
  8. Yes, Thank you.
  9. very nice write up Mianiak thank you.

    I have to agree on texture sizing, I have just done a track with 256x road textures and it looks heaps better than the 1024 one's..
    at 1980x wide screen...

    I have started to play with the textures now both in mips and sizing, can really make a difference to a track.

    I think it just gets very confusuing... so many textures........
  10. NP guys, sharing knowledge can only lead to gaining knowledge ;)

    On another note, this is slightly off topic but Max's question about LOD covers more than just textures so I'll post it here.

    I have been reading the gMotor Manual and found an interesting entry talking about lod replacement of models and using multiple models with different levels of polygons to maintain a decent framerate.

    So, I take it that this means by setting the LOD of an object, you have 2 objects one has 10 poly's the other 5, set the min LOD for the 5 polly model at 500, max LOD at 2000. Then for the 10 poly model set the min 0 and max 500, this way the 5 poly model will be in view then as you get closer it will fade out and be replaced by the 10 poly model at 500 meters.
    So,, when making models for XPacks, we can make multiple models, set different lod values, then make a complex object that places all the models in the same place.

    Interesting! :D
  11. Kris Vickers

    Kris Vickers
    Hardware Staff

    To be honest, i thought this was done anyway, as its not exactly a new technique.

    And on the subject of mipmaps, as well as setting the bias to negative, couldn`t you just have less mipmaps levels?
    I might have to go do some experimenting, but the way i`d think of it is, say the distance of 500m is what it splits with how ever many mips you have, would it not split it less with fewer mips? OR does each layer of mip have its own cut in distance, regardless of how many there are?

    At the moment, i got round the fuzzy texture issue by not having mipmaps at all on the track surface, but as the amount of detail and objects build up, it is affecting the performance, so is something i`m going to have to look at soon.
  12. I strongly recommend using all mip map levels, I don't know exactly why yet lol, but from what I have learned, it is best to use mipmaps. Play with the mipmap filtering in the nvidia plugin and see what different quality you can get.

    I'm not sure how far they go before they change but I don't think it's a matter of distance, I think its a matter of resolution. I think it goes like this,,, If the area you are looking at is 512x512 then the game will pull up a mipmap that is 512x512, if the area you are looking at is 256 then it will pull up a 256 mipmap. If you are looking at a 384x384 area then it will either mix both the 256 and 512 mipmaps together or it will use either or and filter it accordingly.

    *Thought* U know,, I think it is all starting to make sense to me now. If you have a 1024x1024 texture then it is not going to be used if the area you are looking at is only 512x512, maybe this is where negative LOD comes in so that you see the full 1024x1024 tex in the 512x512 window. hmm.gif

    Back to draw distance of each mipmap level, you can test it out by making a dds texture and manually adding mipmaps. Make each mipmap a different colour then load it in game, you will see how far each is drawn till it changes. The fastest way to do it without making huge calculations is just make any old texture and save it generating mipmaps, then close it and reopen it but allow it to open mipmaps too. then when you save it use existing mipmaps.
  13. Except I wouldn't worry about objects with only 10 polygons. For example, I have one building at the end of the main straight that is essentially a cube with an overhanging flat roof (34 polygons), so I don't bother creating lower polygon versions of this one. However, in the pits I have a covered viewing stand with railings and stairs and open doorways/windows which is at least 400 polygons... you can bet I'll create one LOD that's just a pair of boxes (16 polygons) and probably a second intermediate LOD that fills in some details of around 50 polygons.

    Another example is the track I'm modeling uses a lot of barrels. These, too, will get LODS as there are a lot of polygons needed to make a barrel look respectably round close-up, but not very many are required from a distance.

    When using LODs, set LODin and LODout so they don't overlap. That causes the distant LOD to wink out of existence 1 meter before the close LOD winks into existence. While you might think there'd be a flash as the object disappears and reappears, it won't happen in practice unless your car/camera is traveling at < 0.06 km/hr relative to the object.
  14. Thanks everyone for the comments!
  15. -When making the map (.dds), save it with 6 mipmap levels and set the bias to -2 or -3
    The sharpnes and required size of the texture depends also on Your "per meter coverage"
    Bigger per meter value = bigger texture :
    -Road textures: narrow roads = per meter coverage "10", texture size = 512x512
    wide roads = per meter coverage "15", texture size = 1024x1024
    -Terrain textures: Large area= per meter coverage "25", texture size = 1024x1024 or 2048x2048
    Medium area= per meter coverage "15", texture size = 1024x1024
    Small Area= per meter coverage "10", texture size = 512x512
    -Buildings and objects: Small mono coloured faces = per meter coverage "1", texture size = 64x64
    Medium mono coloured faces = per meter coverage "2", texture size = 128x128
    Big mono coloured faces = per meter coverage "3", texture size = 128x128
    Detailed walls = per meter coverage "2", texture size = 512x512

    -Bump and spec maps should be used only for very detailed objects, since it eats a lot of fps.
    -Simple face invisible walls should be used as collision targets instead of the actual objects
    -Shadows should be painted directly on your textures instead of objects and walls casting shadows
    -Alpha and chroma maps should be kept at a reasonable distance from the track
    -If not using different models for the same object, (lod in - lod out), 6 mipmaps are essential to keep the ride smooth
  16. Thankyou very much gstraz!
  17. Wouldn't this cause flickering when you come closer to the objekt? i mean, will the switching form one object to the other one be seamless?

    But first, thank you very much for your explanations about LOD's and MipMaps. Until today i had no knowledge about it. Your post made me understand what's going on there. It will help me with my little fps monster (hi poly modell with jpg textures :D )
  18. It will be seamless if you are careful choosing LODs.

    simple model : LODin = 601, LODout=2000
    complex model : LODin = 0, LODout=600

    Note the 1 meter separation! If you made them both 600, then they would appear at the same time and that can cause a brief flicker as the graphics engine tries to draw the overlapping polygons. Ah, but wouldn't you see a flash as one appears and the other disappears? Nope... with a 60 Hz monitor, you'd have to be moving very slowly (well under 1/30th meter per second) relative to the object to notice a flash.

    How do you choose the LODs for a model?

    Build the complex model. Drive away from it until you can't distinguish the details and measure the distance (doesn't have to be precise). That is your LODout for the complex model. Remember that some people have high-resolution monitors (mine is 2560x1600 and other people have triple screens), so if your monitor is not in that realm, add 10-25% to the distance you measured.

    LODout for the low resolution model should be when the image becomes indistinct as to color and size, like when its a dozen pixels (about the size of a lower case o), unless it is a very important landmark.

    Consider having intermediate models if the complex model is very complex and large.
  19. I came across a realisation on this subject. It seems as though the games low texture settings force the texture to use a lower mip map setting. So if someone has a slow pc and sets low tex settings, they will struggle when the texture has no other levels of mip maps.
  20. Kris Vickers

    Kris Vickers
    Hardware Staff

    Thank you for that Mianiak. I`ll bare that in mind before the final release of my track, as it would be nice if everybody could enjoy it, not just high-end pc users.