Week 9 Update

21 Aug 2017 chinnie

This week was a bit like a roller coaster for me. There were tons of progress done, a lot of design changes, but there were also tons of crashes, weird unexplained issues, and also that big Unity emergency patch. I lost track of how many builds I had to deploy to the phone each day to test performance and comfort, something around 10-15 probably.

Following the plan, I changed the bedroom design from a closed room into a gazebo-type, to give a more open space feeling. The bed and roof were modeled last week, and I worked on its UV and materials earlier in the week. For the wall panels, I found a Chinese wall screen design that reminded me of something I saw in my grandparent’s house.

Using the same design, I replaced all the room wall with this, and I was really pleased with how it look afterward.

As the next step, I replaced pet placeholder art with real 3D assets. I found three low-poly and really inexpensive asset packages from the Unity store and use them in the scene. The pet spawning script was tweaked to show only one pet at a time, at specific place based on user’s position (laying down, reclined or sitting up).  Once the pets spawned at the right locations, I changed the script to treat these pets as pooled objects, so I don’t need to keep instancing and destroying them at run time.

Afterward, I looked up some information to create day & night cycle. I tried following two different tutorials, and the last one seem to work really well. Since this has a lot to do with lighting, I baked lighting on every single updates. The effect was pretty nice, although it tend to be really dark at night time. To compensate, I added one spotlight from the ceiling, and surrounded player’s camera with light probe. This added a bit of ambient light so the scene was not totally dark during night time.

I also adjusted user camera’s height based on position, as a feedback from the user test during game jam. Unlike Rift or Vive where we can track headset position automatically, we need to fake this on mobile VR. During the previous play test, I only had one position for the camera, which was for the reclining option. For those who test it laying down, they felt like floating, and when sitting down, they felt like sinking into the bed. With this height adjustment, it feels more realistic. The camera is higher when we sit down, a bit lower when reclining, and very close to the bed when we lay down.

Things were nice and peachy at this time. Then, as I tried to add more 3D objects onto the scene, like planes with transparency, terrain, vegetation, things started to go wrong. Unity refused to bake any lighting, while spouting nonsense error like ‘cannot generate lighting file’ and that was it. My scene turned completely dark because of it, which made it hard to test. Then, every single build that got deployed onto the phone just crashed. I noticed that before Unity stubbornly saying no to baking, my light map increased from 2 maps to 27 different maps. That day I just walked away from my work PC and went to Seattle Unity Group meetup, where I met an artist friend who was familiar with Unity lighting. I described my problem to him, he asked a few questions.. and we all agree that I might need to just restarted the PC. We also learned about the security patch update in the middle of the meetup. Then I went home, applied the patch, got an error in the middle of patching, and then Unity spout baking error every single time. Fun times. I ended up staying up til 3 am reinstalling Unity, repatching, and just rolled back my project to the time when things were peachy. Hooray for github and version control!

On Friday, after the office hour, I started learning about optimization. I also pay more attention to the fps. My scene performance was really bad. It was around 25-30 fps on Tuesday, and by Friday it was around 12-25. To check for fps, I use Unity profiler, adb catlog, and this script attached to the camera. I wasn’t sure what to do at this point. Then Gabor posted a review from Lauren’s King Crab game, where he pointed out similar fps issue as mine. I followed his suggested setting, and the fps went up a little bit. I wasn’t able to do single-pass render, since my app just stuck at Unity logo every time I tried that.

On Friday night, I joined the OLP discord channel that Tyrus set up. We talked about optimization, and he mentioned batching and watching for draw calls. Through him, I learned about the Unity statistics option during run time on the editor. Thank you, Tyrus!  I started watching the line that says SetPass calls, combined with using Unity frame debugger  (under Window -> frame debugger). I noticed that all the interactable objects in the scene had very high number, something about rendering, I guess. Then I realized that those objects contain outline script. As I researched more, it seems outline effect usually cause performance issue, as shown in a few situations below.  I removed this effect, and my fps was back to around 25-30.

I spent Saturday learning how to modify Unity shader script and managed to create a few variation of mobile shader, convert existing standard materials into mobile mats. After doing this, I was able to add more objects into the scene. I also added a custom skybox, and had to modify the existing day/light script to control skybox exposure. Then call it a day.

Next week plan:
– work more on optimization
– add more object without crashing the app
– add a little bit interaction aside from the pet
– figure out a way for pets to focus on player’s camera for presence
– learn and submit a build to Oculus store.
– build freeze by end of week, due to PAX dev & PAX west.

See you next week!