Avoiding Long Compile Times

Long compile times are a real chore when it comes to testing things. It is especially cumbersome when all you are doing is making small edits resulting in 2 seconds worth of editing, and 2 minutes waiting for compiling.


One place where this is particularly the case is shader debugging. This is the actual problem that prompted me to find such a solution. Being a Unity project for mobile devices, Napkin Western must be tested on its target platform, from time to time. In this particular instance, my nifty hand-crafted shader specifically took issue with the mobile device for no apparent reason. Since compiling for the platform takes a fair amount of time, and all I needed to do was make minor changes to find the issue, I had to come up with another solution.


The solution? Make 6 different versions of the shader; yes, 6. Each version had one thing to test within its code. That way I could independently verify each of 6 different components to see if any of them were the cause of the problem without having to compile the game 6 times. Then I loaded in some spheres and gave each one a different version of the shader.


So, what ended up being the problem with my awesome custom toon/cel shader? Oddly enough, nothing you would expect. It ended up being the fact that I tried to condense my code by using a ternary instead of an expanded if/else statement. I never caught this because it worked fine during the standard visual tests yet, for some odd reason, when testing on the various available Android devices, it resulted in an all black shader effectively always evaluating the ternary to false.

Show Comments