Friday, March 27, 2015

Material Woes

There was more work to be done with cycling through colors this week. Non-technical people can just skip the following paragraph...

First, I modified the update function in our cycling script to prevent renderer.materials from being called with each update. Second, I had to make sure to destroy materials when they weren't needed anymore. Daniel Sanders, a member of my group, discovered that if you don't dispose of materials properly it can cause memory leaking. This really brings me back to the days when I first started learning C++. :D

I was focusing on another course I'm taking (Algorithms) so the above is all I worked on for Ritmo this week. But I did get a chance to start playing a new game. I know it's been out for a while now, but I bought Rayman Legends. Doesn't it look amazing?


This was my first time playing a game in the Rayman series, but it had such excellent reviews I thought I'd give it a try. I fell in the love with the gorgeous art design right away. It's one of the best looking platformers I've seen. Then I quickly got sucked into the addicting gameplay. I love having to free all of your friends and collect enough trinkets to get all of the trophies on each level. They did a great job gradually making levels increase in difficulty. I expect a lot of fun hours will be spent finishing the game.

In short, it's a fantastic. If you haven't played it I highly recommend it.

Ooooook!

Friday, March 20, 2015

Optimization Prime

Ritmo has been having some performance issues. To find the source(s) of the problem we ran Unity's profiler to see where things could be optimized. One section that needed work was the color cycling scripts I worked on.

To fix them, I had to do the following:

  • Make a copy of all the materials that change colors and replace the materials with their copies for their corresponding objects (at runtime). This is necessary because there are only two ways to modify a material's color. The first way is to call renderer.material, but this makes a copy of the material each time it is called (for each object). The second way is to just change the color of the material at runtime and all objects that use the material change color as well. The problem there is that the change is persistent. In other words, it changes the meta file for the material in the Unity editor (which is bad news when you're working with a repository). Instead we created a copy of each material and modified that instead.
  • Reduce the number of prefabs used per platform. Each platform is a multiple of three in length and was made up of 3x1 pieces. That's a lot of pieces for 255x1 platform. Instead I modified all of the platform prefabs to be made up of only three pieces (left, stretched center, and right). This prevented too many update calls from being made.


It was tedious and time consuming work, but now the game is running at more optimus optimal speed.




I had to sneak that picture into a post. I loved transformers as a kid. Happy gaming!