Lesson 4 - game fix

From Bo3b's School for Shaderhackers
Revision as of 03:07, 5 September 2014 by Bo3b admin (Talk | contribs)

Jump to: navigation, search

Summary

This lesson will show one way to go about fixing the entire game, getting it playable as quickly as possible.


Level of difficulty: Easy
Time required: 25 minutes

Video Walkthrough on YouTube
Video Walkthrough direct download link

Objective

Fix the entire game, all shaders that cause 3D glitches, making it playable.
Give each effect a constant, so each can be disabled or enabled.


Quiz

Save and upload two screen shots. This time, using the on/off key mechanism to show any scene with glitches, then all of them fixed.


Even with the tiny information that we have so far, we can still fix entire games!

Let's go through The Ball and fix every broken effect that we find. After we finish disabling all the broken effects, we will have a fully playable game in 3D.


There is a trade-off between fixing effects and simply disabling them. Naturally, we'd want to fix things instead of just disabling them, but fixing things is quite a lot harder and more time-consuming than simply disabling them.

There is an artistic balance to be struck between how much an effect is worth, compared to how bad it looks in 3D. This is simply a judgment call, and everyone will have a different opinion. In general, we try to lean toward fixing everything, but if you only have a little bit of time, it's far better to have a game that runs with effects disabled, than no game at all.

As we go through this Lesson, we'll get a chance to see how that balance plays out with different effects.


For this Lesson we are going to concentrate upon getting results quickly, not necessarily the best results. This technique also makes it easier to decide which effects to fix, and gives us a great working list of effects to be fixed when we have time.

Part of these Lessons is to present techniques that can lead to good working habits when fixing these games. It's very easy to try to go too fast and get lots of files open and get confused on what file affects which effect, especially if your experiments don't work. There are lots of different approaches to fixing effects, this will emphasize techniques that can save you time.



Before we get started disabling effects, let's take a quick look at another HelixMod feature that we are going to use extensively in the future. Our use here will be a simple version, but a good introduction.

In the HelixMod DX9Settings.ini file, we can add Constants, and we can then use those constants in any Pixel or Vertex Shader. They are provided by the tool as a convenience, and for any purpose that we wish. The constants can be used to make it easy to change the HUD depth for example, or specify how transparent to make it.

These constants can also be chosen based on a given key or mouse press, so that we can change effects in the shader, like changing viewpoints on key press, or changing convergence to zero when the right mouse is down.


For our example here, we'll make a simple on/off mechanism, where we can decide in each shader whether to show the original shader, or our disabled version. Then by a keypress, Numpad 0 by default, we can toggle it from broken to disabled.

There is no particular advantage to do this, other than it's interesting and makes a great demo, but it can make it easier to decide whether something needs to be fixed or if disabled is good enough.


  • Create an on/off mechanism using HelixMod constants
    1. Edit the DX9Settings.ini file and set DumpAll=false for speed.
    2. Look at the DX9Settings.ini that we'll now use, at Default_DX9Settings.ini
    3. Copy and paste that default .ini into our Ball DX9Settings.ini.
    4. Open the A977E84A.txt shader where we'll see how to use the constants we just made.
    5. In the def section, add new constant as:
      //def c220, Const1, Const2, Const3, Const4
      def c200, 0, 1, 0.0625, 0 // x=0 for comparison to Const1
    6. At the bottom, change our mov oC0 code to be the if statement:
      // if Const1 = 0 turn effect off, else leave it on
      mov r30.x, c220.x
      if_eq r30.x, c200.x
      mov oC0.xyzw, c200.wwww
      endif
    7. Run The Ball and see if it works.



As a first pass, let's find and mark all the broken shaders. We'll still look for them one at a time, so we can easily keep track of what we need to do and to avoid getting confused.

In a later Lesson, we'll come back to these disabled shaders in order to actually fix them. Having them all in the same spot, with good comments will make it easy for us to find effects, and decide which are worth more time to actually fix. In a very real sense, this is a working ToDo list, but without us having to write a bunch of notes.


  • Creating a complete list of shaders.
    1. Since we want quick results, we can turn effects off with UI instead of fixing or disabling them.
    2. First pass in game, finding broken shaders.
    3. Relaunch at different saves to shorten active search list.
    4. Mark every shader that needs fixing. Comment each one in the Dumps folder.



With all the broken shaders saved in the ..\Dumps\SingleShaders\ folder, we can now go through and disable each of them. We'll use our on/off mechanism so that we can decide how much of an impact disabling each effect has.


  • Editing shaders to disable effects
    1. Fix full game. All shaders gone.
    2. Most are no big loss, but what about lava?
    3. Fix lava by killing one layer instead.



That's all there is to disabling effects in a game, and hopefully you see how quickly and easily you can fix an entire game. It can be improved, but isn't it already far better than when we started?

Time for the Quiz, for you to demonstrate that you successfully disabled some effects, using the on/off constants mechanism.


  • Save and upload before and after 3D snapshots
    1. Find a good spot in the game where something was fixed.
    2. Set the fixes to off, and snapshot the broken image with Alt-F1.
    3. Set the fixes to on, and snapshot the new and improved image with Alt-F1.
    4. Upload your two snapshots, using the Special:Upload link.
    5. Navigate to your personal wiki page from the upper right.
    6. Edit your personal page, and add == Lesson 3 == and any comments you'd like.
    7. Add Before: and your before filename reference as: [[File:before filename|700px]]
    8. Add After: and your after filename reference as: [[File:after filename|700px]]
    9. Check your page with Preview to be sure you like it.
    10. When you are satisfied, click Save Page.



Did you successfully disable every annoying effect? Did you just fix a complete game? Incredible!


If you have any questions or suggestions, please use the Discussion tab, and start a new topic.