Difference between revisions of "Lesson 2 - disable effect"

From Bo3b's School for Shaderhackers
Jump to: navigation, search
(Created page with "==== Summary ==== This lesson demonstrates how to make our very first fix, by disabling any specific effect in a game. Level of difficulty: Easy<br> Time required: 15 minute...")
 
Line 20: Line 20:
  
 
----
 
----
 +
Since our HelixMod+TheBall environment is already set up and ready to use, let's dive in and fix our very first, game breaking, 3D bug.
  
:* Shader hunting a specific effect
+
You probably noted when running the game before, that the bloom effect on the ball light is seriously broken, and is so annoying that it makes the game unplayable.  It also changes depth when you adjust separation or convergence, so it's not really possible to find a sweet spot that is playable. 
:* Saving the shader, then moving it into ShaderOverride
+
:* Editing shader to disable effect
+
:* Reload shader to see changes dynamically
+
  
: Quiz: Save and upload before and after 3D snapshots
+
Since bloom is a low-value effect, let's disable it altogether. We won't miss it.
 +
 
 +
 
 +
Let's start by hunting down the exact shader file for that effect.
 +
 
 +
 
 +
* Shader hunting a specific effect
 +
*# Run The Ball, in 3D with HelixMod installed.
 +
*# Step backwards one shader with '''Numpad 1''' and '''Numpad 4''' to see that we have the short list of shaders to search.
 +
*# Step forward in the Pixel Shaders using '''Numpad 2''', and cycle all the way through at least once.
 +
*# With some idea of what all happens, step through and find the specific bloom effect.
 +
*# With that effect selected and disabled, use '''Numpad 3''' to save it into the ''Dumps'' folder.
 +
*# Quit the game.
 +
 
 +
<br>
 +
 
 +
----
 +
With our target shader saved, we need to move it into a new folder, the ShaderOverride folder so that HelixMod will use our fix at game launch.
 +
 
 +
 
 +
* Finding the shader, then moving it into ''ShaderOverride''
 +
*# Navigate to The Ball's game directory with our shortcut.
 +
*# Continue into ''Dumps\SingleShaders\PixelShader''
 +
*# Find your target Pixel Shader, usually the most recent item.
 +
*# Select and Copy the shader text file.
 +
*# Navigate back to the ''The Ball\Binaries\Win32'' game directory.
 +
*# Create a new folder there, named '''ShaderOverride'''
 +
*# Open that folder, and create a new folder there named '''PixelShaders'''
 +
*# Open that folder, and Paste your copied Pixel Shader.
 +
*# Edit the file name, so that HelixMod can load it. Remove everything except the CRC number at the end.
 +
*# Make sure the CRC is 8 hex digits long, some need a leading zero.
 +
 
 +
<br>
 +
 
 +
----
 +
Now we are ready to actually make the change to the ASM text.
 +
 
 +
A pixel shader is responsible for deciding what color a particular output screen pixel is supposed to be.  If we set the color to transparent, then we make it invisible.
 +
 
 +
That's the idea behind this fix, we want to make the oC0.rgba register all zeroes.  The last parameter on that list 'a' is the alpha channel, and responsible for how transparent it is.  Zero will make it 100% transparent.
 +
 
 +
 
 +
With that in mind, let's edit the source file.
 +
 
 +
* Editing shader to disable effect
 +
*# Open the shader file with the fixed name in ''ShaderOverride\PixelShaders\''
 +
*# In your text editor, scroll through the shader until you get to the bottom.
 +
*# Find the second to last line, right before the comment that says "// approximately ...".
 +
*# Type in the instruction mov oC0, c1.xxxx
 +
 
 +
<br>
 +
 
 +
----
 +
 
 +
* Reload shader to see changes dynamically
 +
*#
 +
*#
 +
*#
 +
*#
 +
 
 +
<br>
 +
 
 +
----
 +
 
 +
* Save and upload before and after 3D snapshots
 +
*#
 +
*#
 +
*#
 +
*#
 +
 
 +
<br>
 +
 
 +
----
 +
Did you successfully disable that annoying effect?  Congratulations!  You can now justifiably call yourself a Shaderhacker!
 +
 
 +
Disabling effects can salvage a game from being completely unplayable, so don't discount the power of this simple technique.
 +
 
 +
 
 +
If you have any questions or suggestions, please use the [[Talk:Lesson_2_-_disable_effect|Discussion]] tab, and start a new topic.
 +
<br>
 +
<br>

Revision as of 02:12, 20 August 2014

Summary

This lesson demonstrates how to make our very first fix, by disabling any specific effect in a game.

Level of difficulty: Easy
Time required: 15 minutes

Video Walkthrough on YouTube
Video Walkthrough direct download link

Objective

Using the HelixMod debugger we'll find a specific broken shader that makes the game unplayable.
We'll patch that shader using the text editor to disable the effect.

Quiz

Save and upload two screen shots. From the same view angle, show the before image, then show the fixed image.


Since our HelixMod+TheBall environment is already set up and ready to use, let's dive in and fix our very first, game breaking, 3D bug.

You probably noted when running the game before, that the bloom effect on the ball light is seriously broken, and is so annoying that it makes the game unplayable. It also changes depth when you adjust separation or convergence, so it's not really possible to find a sweet spot that is playable.

Since bloom is a low-value effect, let's disable it altogether. We won't miss it.


Let's start by hunting down the exact shader file for that effect.


  • Shader hunting a specific effect
    1. Run The Ball, in 3D with HelixMod installed.
    2. Step backwards one shader with Numpad 1 and Numpad 4 to see that we have the short list of shaders to search.
    3. Step forward in the Pixel Shaders using Numpad 2, and cycle all the way through at least once.
    4. With some idea of what all happens, step through and find the specific bloom effect.
    5. With that effect selected and disabled, use Numpad 3 to save it into the Dumps folder.
    6. Quit the game.



With our target shader saved, we need to move it into a new folder, the ShaderOverride folder so that HelixMod will use our fix at game launch.


  • Finding the shader, then moving it into ShaderOverride
    1. Navigate to The Ball's game directory with our shortcut.
    2. Continue into Dumps\SingleShaders\PixelShader
    3. Find your target Pixel Shader, usually the most recent item.
    4. Select and Copy the shader text file.
    5. Navigate back to the The Ball\Binaries\Win32 game directory.
    6. Create a new folder there, named ShaderOverride
    7. Open that folder, and create a new folder there named PixelShaders
    8. Open that folder, and Paste your copied Pixel Shader.
    9. Edit the file name, so that HelixMod can load it. Remove everything except the CRC number at the end.
    10. Make sure the CRC is 8 hex digits long, some need a leading zero.



Now we are ready to actually make the change to the ASM text.

A pixel shader is responsible for deciding what color a particular output screen pixel is supposed to be. If we set the color to transparent, then we make it invisible.

That's the idea behind this fix, we want to make the oC0.rgba register all zeroes. The last parameter on that list 'a' is the alpha channel, and responsible for how transparent it is. Zero will make it 100% transparent.


With that in mind, let's edit the source file.

  • Editing shader to disable effect
    1. Open the shader file with the fixed name in ShaderOverride\PixelShaders\
    2. In your text editor, scroll through the shader until you get to the bottom.
    3. Find the second to last line, right before the comment that says "// approximately ...".
    4. Type in the instruction mov oC0, c1.xxxx



  • Reload shader to see changes dynamically



  • Save and upload before and after 3D snapshots



Did you successfully disable that annoying effect? Congratulations! You can now justifiably call yourself a Shaderhacker!

Disabling effects can salvage a game from being completely unplayable, so don't discount the power of this simple technique.


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