I can’t find so much on the web and I can’t understand its purpose. I have seen on Wikipedia that it is like… You put a texture, and the engine will enlarge it adding scaled copies of the image at half size. And ok.
But how they work? Does the enging resize the UV maps, shifting them on the mip maps? And what about the seams?
And the main question is… What is their purpose? I can imagine that they’re used for objects that are far away and that don’t need of HD textures, but since the textures are still loaded fully (I think) because the mip maps are created on it, what is the advantage? And are there other usages?
Last question, optional: I have read that they prevent those bad effects with black close lines on the surfaces when you see them almost in parallel. Why?
I don’t think you need to worry about the UV maps they should indeed be scaled according to the mip maps.
As I’ve understood there are two purposes of a mipmap:
It can be faster because the GPU don’t need to fetch as much data from the GPU memory to show a smaller mip map (less pixels to loop over).
It can look better at a distance because it will choose to show the texture of a resolution that’s close to the actual resolution it will be displayed in.
If you’re unsure about if to create mip maps, just test how your game looks with and without mip maps enabled.
UV maps are a 2d position relative to the texture’s bounds. The dimensions or aspect ratio of the texture have no affect on the UVs. A UV position of 0.5, 0.5 is the middle of the texture if it’s 2048x2048, or 4x4, or 1280x96.
As for mip maps, imagine you have a 256x256 texture with a lot of details in it. Now imaging it’s being displayed on screen at only 64x64 pixels. That’s 1/4th the original resolution. With out mip maps the GPU is basically going to render 1 out of every 16 pixels from the original texture as one on screen pixel covers an area of 4x4 pixels. This results in a lot of aliasing as many of the details from the original texture are simply missed. Mip maps handle this case by having a version of the texture that’s already 64x64 with each pixel color being an average of those 4x4 pixel areas from the original larger texture.
Here’s an example of a worst case scenario. This is a very high contrast brick texture.
And here’s a simulation of what that texture looks like scaled down to 64x64.
In real use it’ll rarely be this perfect, here’s what it looks like at 69x69 pixels.
You can see several of the small details are simply missing, or seem to fade in and out over the texture.
This is what the same scaled down image would look like with mip maps.
As you can see all the lines are still apparent, or at least they contribute somewhat to the image. Even if it’s not perfectly scaled down it still looks mostly right.
Hmm … not really. If anything mip maps will cause this problem more than prevent it. UV seams are kind of the Achilles heel of mip maps. However if you’re getting black lines it’s because you’re leaving the area of the texture the UVs don’t cover black. You should choose a color that’s closer to the average of the rest of the texture, or use something like XNormal’s photoshop filters to dilate the texture’s edges.
Also Mip map kicks in when image are seen as a grazing angle, and you can put arbitrary image in the mipmap level, which can lead to interesting effects or controlling the visual at far distance. For example mario sunshine on gamecube use some of those effect to make their ocean effect at no cost.
Oh, many thanks! Ok, bgolus you really opened my eyes about them.
Cool about seams, thanks.
About vertical black lines, maybe I have explained it wrongly, I was referring to this sentence:“The main purpose of this technique is to maintain texture definition on surfaces further from the camera and to avoid unslightly moiré patterns which can appear on surfaces, especially as they approach an angle parallel to the axis of the camera.” that I’ve found here Mipmapping - Valve Developer Community
neoshaman, can you give me a visual example of what you’re meaning about Mario Sunshine’s ocean? Just to understand it better.
That’s exactly what the 69x69 examples are actually showing. One has a strong moiré pattern, the other does not.
https://www.gamedev.net/forums/topic/614608-specular-highlights-on-water/#entry4881841
Mip maps are in their most basic sense just multiple textures the GPU automatically blends between over distance. There’s no technical reason they have to be of the same texture for each mip level. In the past it was really common for game engines to have a “mip map view” so you could visualize the resolution of the mip maps being used. These all worked by just coloring each mip level a different color.
Really many many many thanks, now I understood all (at least, at this basic level) and I couldn’t expected anything better than these so complete answers. Thanks again guys!