Яндекс

Monday, November 21, 2016

New Public Release. Part II

Today we will continue to learn new features of upcoming Public Release

Now we will compare

Emulation panel




As you may notice, new version has more reach set of options.

Emulate mip-mapping


That important and hard to emulate feature is available since the first Public Release. Several issues with mip-mapping were found and fixed since that, so now it works even better.

Emulate noise


It was good before, so no major changes there.

Emulate fog


Do not worry, fog emulation is still there. However, it is not optional anymore. Now it is part of one very important feature, which works silently under the bonnet of GLideN64 engine and has no user handle. This feature has a long story, worth to tell it to interested emu fans:

Long time ago I told you a story about my fight with N64 color combiner, and how I successfully defeated that problem using magical beans shaders. Similar long story happened with N64 blending. N64 color blending is pretty much similar to OpenGL one. It also mixes input color with color in frame buffer using some blending factors. However, there are differences. If N64 combiner uses 2 cycle mode, blender has 2 cycles too. It is not the main problem though. The main problem is that blender can use two constant colors in blending equations, namely fog and blend colors. Fog color usually used to apply fog. However, it is not prohibited to use it for other purposes. Thus, it is possible to mix output from color combiner with constant colors, thus turning blender to additional stage of color combiner! Surely, many games use that possibility. I could not emulate such combine modes with Standard OpenGL blending. I would be glad to use magical shaders again, but unfortunately blending is a part of so-called OpenGL fixed functionality. It is prohibited to read value from frame buffer, blend it and write back using shaders. In other words, no blending with shaders!

There are GL extensions, which promise to allow shader based blending if some conditions met. Use of them could lead to incompatible hardly working solution. I disliked it. Standard OpenGL blender failed in each case where N64 blender used to combine colors. To fix it, I added special code in fragment shader, which performed necessary additional manipulation with color combiner output color. In fact, these were bunch of ugly hacks. That bunch had tendency to grow. When I met yet another problem, which required special support in code I said enough! I studied all details of N64 blender again and invented general solution to this problem. I wrote special shader program, which uses the same inputs and equations as in N64 blender and which does all mixing and blending except the final one: blending with buffer color. That final mix performed by standard GL blender, with no extensions. Result was wonderful. No more ugly hacks. Several long lasted issues instantly disappear (see #481 for example). Fog emulation is now part of the blender, and thus always enabled. The only drawback is additional load on graphics card, which is noticeable on some old mobile GPU. Thus, I left option to use fast inaccurate legacy blending, but this option is not available for desktop build. You may read more about new blending emulation in thread #970.

Enable Hardware lighting


This option enables per-pixel lighting calculation known as Phong shading. I already wrote about it. It not changed since that time.

Enable shaders storage


This is new feature added by request from users of mobile version. Plugin uses shaders to emulate N64 color and alpha combine equations, as described here. When game uses new combiner, new shader program created. Shader programs compiled and linked on the fly. GLideN64 generates quite large and complex shadres. Shaders compilation on mobile devices can cause stuttering in gameplay. OpenGL allows to get binary representation of linked shader program. That binary data can be stored in a stream (file) and then restored later. When shaders storage option is enabled, plugin saves all shaders in a file. When user starts that game again, plugin loads all previously compiled shaders from that file and further gameplay goes smooth. Of course, if you will met new combiner, corresponding shader will be created on the fly and saved in the storage on exit.

Note: binary representation of shader program depends on GPU and drivers version. Do not try to copy your shader storage to other device: it either will not work or will work improperly.


Use custom per-game settings


The meaning of that option remains the same, but content of custom settings file changed almost completely due to major changes in frame buffer emulation.

2D fixes


Original N64 2D graphics looks good in original resolution, but when you use hi-res output various glitches appear. So, the best way to get perfect 2D is to use original resolution. Set original scale factor to 1 and enjoy. If you playing 3D game, it will look poor in original low resolution. So if you want to get nice hi-res picture, and minimize glitches in 2D, pay attention on the following options.

Fix black lines between texrects


Enabling that option may help to remove black lines between adjacent textured rectangles. The problem and solution described in issue #450. If you see black lines between polygons, try "smart" option. Did not help? Try "force". Still not working? Sorry, there are games with broken 2D even in native resolution, see issue  #936. We are working on it.

Example of black lines removal.

Render 2D in native resolution


This option enabled multi-pass rendering of 2D elements. The problem and solution described in this article  and in thread #800.  This feature greatly improves 2D in many games, but currently it is not the silver bullet to kill all 2D issues.

Standard rendering VS render 2D in native resolution

Next: Frame buffer emulation



No comments:

Post a Comment