Яндекс

Saturday, October 11, 2014

Mip-mapping emulation.

Year ago I explained why it is so difficult to implement N64 mip-mapping. The problem is divided on two parts:

  • calculate per-pixel Level Of Details (LOD)
  • use calculated LOD to select texture mip levels and blend them with each other using LOD fraction.

The first task was completed year ago. I wrote pixel shader program, which calculated LOD and LOD_fraction. However, the plugin’s texture management subsystem did not support load and use of mip-mapped textures. Everything was designed to work with no more than two tiles. Thus, my LOD could be used only to blend the two most detailed levels of mip-map texture. This is perfectly enough for Peach-Bowser portrait transition in Super Mario 64, and absolutely unsuitable for textures with number of mip-map levels above two. Users, who have access to weekly betas, may notice how bad ground texture looks in Golden Eye for example with LOD emulation on.

Complete mip-mapping emulation became my task N1 for next week. It was necessary to implement load of N64 mip-mapped textures and write a pixel shader which fetch texels from right mip level. The task was done within one day, but it was not easy. The first-shot implementation worked so bad that I started to doubt that the task is possible. Long debugging started. I found several bugs in my LOD calculation shader, few ones in my texture loading code. Thus, step by step I approached to the goal. When at midnight I squeezed the last bug I could not believe my eyes: the tested game (it was Perfect Dark) is totally transfigured. The smooth change of textures level details looks charming. The difference between high and low detail levels brings feeling of distance to the picture. It looks like a different game. The result I can be proud of.

I’ll make a comparison video later. Now just one example, Perfect Dark.


The metal floor looks the same near and far without mip-mapping, because the most detailed texture level is always used.


Map-mapping makes it look different: details vanish with distance.



The floor details are at maximum only when you look at your foot.

5 comments:

  1. This is a great update. I had played some perfect Dark on Mupen on Mac, major graphical issues, but this is looking tons better. It might actually run fine now and look great. I was using the Glide plugin at that time (1yr ago). This PC only still and not being proted?

    ReplyDelete
  2. http://gliden64.blogspot.ru/2014/07/android-port.html

    ReplyDelete
  3. Dunno, i think i prefer the above, detailed picture. The second one seems to lose too much detail. I get that in distance it should look less detailed, but the effect seems exaggerated in the picture as in distance it looks like there is no texture at all, just a solid color instead. Also, i notice that all textures look blurrier, including the ones that are somewhat near.

    I don't know how the real N64 displays them though.

    ReplyDelete
  4. LOD calculation is optional. If you don't like it, you may turn it off.

    All original N64 textures are not very detailed. N64 has only 4kb of texture memory. Up to 7 tiles can be loaded to that 4kb in case of mip-maping. The size of most detailed tile is 64x32, the next is 32x16, the smallest one is 1x1 that is just a color. When 64x32 is blended with 32x16 you see blurring, at the distance you see just a color. This is how it works. May be texture artists will make high-res mip-mapped textures for this game.

    ReplyDelete
  5. This is already looking very promising. Can't wait fro the official release as I expect this to be even better than Glide64 which already has done good things for it's time. If it wasn't for that plugin, I would still be forced to play games on the actual console which I rather not do these days since the graphics are much better on the PC. Perfect Dark (an old favorite from the summer 2001) already looks wonderful.

    ReplyDelete