News

Overload on the PS4!

Posted October 25, 2016 by Cathy Schneider

Recently, Matt has ventured into porting Overload to other platforms; namely the PS4.

Matt Toschlog, Programmer:

Lately I’ve been working on-and-off on the PlayStation 4 version of Overload.  It wasn’t too difficult to get it working, but there were a lot of interesting steps.

I started working on the PS4 version when we got our dev kit.  But I didn’t set up the dev kit right away — I started on the software.  I installed the Unity add-on for PS4 and tried to do a build.  There were a few PC-specific things — like Steam leaderboards — that had to removed for the PS4, but that wasn’t too bad.  There were also a bunch of places in the code where we included or excluded code based on whether we were doing a Unity build.  (Some source files are shared with our level editor, so only parts of those files are compiled for the game.)  The problem is that those parts used the symbol UNITY_STANDALONE, which is only set for the PC build.  So I had to change them to also check UNITY_PS4 and (looking ahead) UNITY_XBOXONE.

After that was done the code compiled and I was ready to test on the dev kit.  I unpacked the kit, got it all set up, and turned it on.  It worked fine, and all I need to do was activate it by downloading a file from Sony.  I downloaded the file and….it didn’t work.  The dev kit reported that the file was invalid.  A little digging turned up the problem — the serial number on the Sony web site didn’t match the machine I had.  So I had to file a ticket with Sony and wait for them to fix the serial number on their end.

Three days later I got the notification that the problem was fixed.  It was early evening on a Friday, but I didn’t want to wait until Monday to see the game running, so I activated the dev kit and fired up Overload.  And it worked!  There were clearly shader problems and there was no sound, but the game basically worked.  And the framerate was decent — 40-50 FPS with no optimization.  Here’s what it looked like:

sp_ps4test1

The most obvious problems here are that the lasers and explosion effects are solid pink, and that the robots are totally black.  But all the level geometry looks good.  The weapons and robots turned out to be easily fixed — they were using shaders generated by ShaderForge, and Luke just had to regenerate the shaders with PS4 support enabled.

I started looking into the sound problem, and was lucky enough to find a post on the Sony forums from someone who had a similar problem.  It turns out that some Unity audio settings that work fine on the PC don’t work on the PS4.  So I went through the settings one by one, resetting them until the sound started working.

Now the game looked like this:

sp_ps4test2

It might not be obvious at first glance, but you’ll see that there are no enemy weapon projectiles.  And though you can’t tell here, there are no shadows.

Shadows turned out to be pretty easy — they were turned off.  Because I hadn’t defined any Unity quality settings for the PS4, it was defaulting to the lowest quality PC setting.  So I created a quality setting for the PS4, and shadows came on just fine.

About this time someone on the team asked if the game was running in Base mode or Neo mode.  Good question!  Neo mode is for the PS4 Pro; everything runs faster so the framerate should be good.  Running in that mode could be trouble, because our framerate would be much lower in Base mode.  I quickly determined that we were running in Base mode, so I excitedly tried to set the dev kit to Neo mode.  After messing around with settings for a long while and emailing Jeff about ten times, Jeff finally asked  if I was doing a Neo build — “Cause if you run an executable that was built for base, it will run in base mode.”  Oh.  So I start looking into Unity and it turns out that I didn’t have the new version that supports Neo.  So after updating Unity I did a new build and it ran in Neo mode.  I added custom Base and Neo quality settings in Unity, and Unity automatically sets the correct level based on what mode the game is running in.

I also had to address problems with the controller.  The PS4 controller has never worked right with Overload (try using the dpad buttons in the menus) so I started looking into that.  It turns out that our default controls were set up using button numbers from an Xbox controller, and those numbers don’t match the buttons on the PS4 controller.  I pondered for a while on how to handle this, and then I discovered that Rewired (which we’re using for our controller input) has something called Templates, which map specific controllers to a generic set of gamepad controls.  I changed the input system to store controls configuration based on the template button and axis numbers, and now the PS4 controller works perfectly.  And since Rewired supports 72 different gamepads that share the template, almost any controller you use with Overload should work fine.  (Thanks to Augie Maddox, the creator of Rewired, for his patient help and providing me access to unofficial API calls that let me hack together the system the way I wanted it.)

Now all that was left was the broken shaders that were keeping the enemy projectiles (and some other things) from rendering correctly.  First I verified that it was a shader problem by changing the projectile glow to use a simpler material.  Sure enough, the blobs now showed up.  Digging through the PS4 docs, I found a list of differences between the PC shader code and the PS4 shader code.  So I opened one of the projectile glow shaders, made the changes, and it worked.   Since we have a lot of shaders, I decided the easiest thing would be to write  a program that scanned the project and found ones that needed to be fixed.  There were a lot, and I started fixing them by hand, one by one.  After fixing about eight, I realized that it was going to take forever.  So I updated my program to fix the problems it found, and ran it on the whole project.  It fixed 101 shaders, and the game now looks great.

The work that’s left now mostly involves supporting systems that are different on the PS4.  I’ll have to get PSN leaderboards working in place of the Steam leaderboards on the PC, and since we use the Windows file system for saving our config data I’ll have to update that.  The biggest chunk of work will be supporting all of the Sony requirements — using the right names for everything, making the menus follow guidelines, and so on.

I’ll be moving on to other things now; we’ll get to the rest of the PS4 issues later.  It’s been fun to get it working, and it’s great that I can now test on two totally different platforms.