Jump to content
  • Advertisement

Recommended Posts

*** Beginner question ***

To my current understanding of mipmapping, If you have a 512x512 texture downsized to 256x256, then only 1 pixel can be rendered on the downsized version for every 4 pixels on the full sized texture.

If the nearest neighbour method is used, then the colour of each pixel on the downsized version will be determined by which pixel has its centre closest to the relevant texture coordinate, as demonstrated below:
MSytCqo2ohfYRuI40dEor1PjCnDjTkMhVKRk1EYwfnVx1ckLVNGTd5ePXtSWm3uwsFCp4zAmLv6ZFrfaLL86Wgh75mcozinKpuSNIU0SYGtcgRD2ZMoxQ5EwJubC2Kq1FNUTjxHqqQo

Whereas if the linear method is used, then the colour of each pixel on the downsized version will be determined by a weighted average of the four full size pixels:
fLQ7-Ma1weglg9TxwGQKyS4OUMzXstMTpDOj3dj5cvOJbLa5EO09SnVfqs2eO4xKhf0gRiB7Oveamd_Fv--iX8I-uVVFdG8lxgmKm8CCnprSiO4tg-opdo4T6yU1K0VDlQC14OllRz4
But if mipmapping is not used, then how is the colour of each pixel determined?

Share this post


Link to post
Share on other sites
Advertisement

Sorry if I misunderstand your question. Texture sampling modes are irrespective of mipmapping, so point vs linear sampling functions as you described.

Share this post


Link to post
Share on other sites

As @Steve_Segreto said, they way sampling works is mostly the same whether mip-mapping is used or not. "Mostly", because with mip-maps we get an additional axis for interpolation. When computing the optimal mip-level for a given fragment, the value can be some floating-point number. Thus, we want to interpolate between the two mip-levels closest to that optimal level. E.g. your optimal level is 4.6 then use levels 4 and 5.

And just to make it clear why exactly we use mip-mapping: Imagine a surface patch very far away from your camera so that it covers exactly one pixel. Now, this surface might have a texture that is 512x512 pixels big applied to it. Thus, all of that texture information must fit into that one pixel, which is obviously not possible with nearest-neighbor or bilinear filtering. This is why we get ugly shimmering when moving the camera, because with e.g. bilinear filtering differnt 2x2 neighborhoods are choosen frame by frame, resulting in differnt colors. You would have to average all 512x512 pixels for the correct result. And that is exactly what we do with mip-mapping, we prefilter some sizes of that texture so that we can just use e.g. bilinear filtering since we can now choose the correct size of the texture. In this case the GPU would choose the smallest mip-level which is 1x1 pixel and is basically the whole image averaged into one pixel.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!