Wednesday, March 23, 2011

Thursday, March 17, 2011

GPCv4 Day 1 & 2 - Game Mechanics + Studio Logo/Splash Screen...


Was having dinner while writing this post... So, right now I'm working on a game for the latest challenge, and the theme of the month is "Burden" and "Sunshine". 

I don't really have any idea for the first 2 days, other than I wanted to make another puzzle game... This time, I'm planning to make a REAL puzzle game, unlike my previous entry which was originally meant to be a platformer, but ended up being an optical-illusion-puzzle-platformer genre instead. 

I did a lot of brain storming, came up with quite a few ideas, and then ended up with the current one which I find would be easier for me to work on in this 7 days of game development. The story is like this: 
"One day the sun suddenly stop working, and the whole world went dark... for a pretty long time. And then decades later, our hero appears, with a stone which he thinks can help save the sun... and he must go to the center of the dark forest through a series of challenges with the help of the stone... in order to reach a machine over there which can harvest the power of the stone and save the sun...". And the stone in this context is something like Sun stone... except that it's not for evolving a Pokemon. The player can use the stone to create a ray of (sun) light and move objects with it, and solve puzzles (if there's really any puzzles at the end)... XD

Anyway, I spent the next 12 to 15 hours coding the game mechanics in Unity3d, and here's what I came up with:

Music by George&Jonathan...

The video shows some of the stuff the player (you) are capable of in the game. When you aim and shoot, a ray will be casted by the Sun stone you're holding, and you'll be able to mystically move the blocks. The scripts is still a little buggy, though no errors, but it's considered complete for now. I'll be working on the level design next...


A while ago, I kinda gave my own room-studio a name, and it's called "SuperOrganic168", don't ask me how I got the name (it's a pretty long story), and "deepth" was the first game I released under the studio name.

I spent some dinner time today doing a logo-splash screen thing (without the logo yet, still working on it)... Here are the without-logo version (will upload with-logo vers. if I manage to finish the logo by the time the challenge is over, or I'll just put it in game):

The one with the word "meat" was actually for adding some sense of humour into it (and it sounds the same as the Katakana too), and I kinda thinks that the splash screen looks good already without a proper logo... haha As for the orange theme, orange is my favorite colour...:D

Monday, March 7, 2011

Unity3d + C#: Reducing draw calls and gaining some performances with CombineChildren.cs and Texture2D.PackTexture

I realize a lot of Unity tutorial out there focus more on the gameplay issue and less in the graphical issue, probably due to the fact that they want to guide/teach you into creating a better game with more kickass functions... Well, in this post, I'm doing a note on ways to reduce draw calls in order for better performance in lower-end PCs. 

Usually a game with high draw calls means it has a ton of meshes in its scene with different textures, materials and shaders, and the PC will have to loads them up and render one after another causing it to gets laggy, unless you have a high-end PC like mine... You can read a more detail explanation in this article at Unity Answers by RobotDuck.

So, a way to reduce this is, as the article explained, by creating a large texture atlas, which is made up of all the textures of the meshes in your scene, and then assign the texture atlas back to the meshes, and then position them to their corresponding textures on the atlas according to their designated UV coordinates. I'm kinda bad at explaining stuff... so I'll just show you this:

This is an example of a texture atlas (taken from the link above), where by you have all the textures of the 3d objects in your scene and then assign the texture to them according to their corresponding UV coordinates...

So let's say you had already created all the textures for your game project and was too lazy to create the texture atlas for time's sake, cuz it can get pretty messy assuming you have like 100 different textures and you would like to have say... 6 different shaders for all of them. Instead of opening up your Photoshop to make those 6 texture atlases (for different shaders), you can pack those textures up into atlas straight way using scripts... 

I found one well-written script, written by "phantom" from the Unity forum which uses the Unity built in functions called Texture2D.PackTexture() to create a texture atlas. I've sorta tested it out, tweaked it a little, and exported it as a unity package... you can download it from here (for Unity vers. 3.x): TexturePacker.unitypackage

And now let me guide you through on how you can use the script... 

Import all the assets into your project folder. Some of the script inside the package, especially CombineChildren and MeshCombineUtility originated from Unity's own Standard Assets. 

Go to the Assets/Scenes folder and open up the "TexAtlasTest" scene, and you'll see 4 cubes inside the scene. Don't touch anything yet, but go to the Game window, and select stats...

The stats window should show a Draw Calls of 4, which make sense, consider we have 4 cubes in the scene with different textures and materials, but uses the same shaders, thus there's a chance here we could combine their textures together and use the same material and texture atlas for all the meshes in the scene. 

Next, in the Hierarchy, you should see a gameObject named "Objs" which contains all the blocks in the scene. When you select it, there should be two scripts attached to it: CombineChildren.cs and TexturePacker.cs 

What this CombineChildren.cs script does is, it combine all the meshes of the children of the gameObject (which was using the script) into one big mesh. And then TexturePacker.cs will combine all the textures of the children to create one huge texture atlas, which would then be auto-UV to all the meshes inside the scene. 

There's two parameters over at the inspector which you could toy around with: 
"Shader Type": the name (in string) of the shader you want to use, and 
"Texture Size": the size of the texture atlas you want to create... it's 1024 x 1024 by default...
As for the "Packed Texture" variable, just leave it alone... It's actually for storing the texture atlas created when you click "play"... so it'll remain empty for now, and then a new texture will appear during play mode...

Those were the two important scripts to make the draw calls reduction possible... Now if you could just click "Play", and look at stats again:

Now we have for the scene, ONE draw calls. (Yeah! :D) 

More explanation about the script used is inside the TexturePacker.cs script itself (those comments in green-colored font)... 

* Important thing to be noted about the scripts when using them is that... these scripts will only turn their children into one huge meshes and one huge texture atlas... Thus, always make sure that you have an empty game object that stores all the meshes which uses the same shaders that you wanna combine into, before using them.

* In the process of packing texture using PackTextures() functions, you may face a problem of getting an error like: "Texture atlas needs textures to have Readable flag set." Don't worry, it's not a bug or anything, you can solve it by going to your texture's folder, click on the textures you're doing the packing on, and in the inspector, look for "texture type" and select "Advanced". Doing so will bring out a number of new parameters. Look for the one called "Read/Write Enabled", check it (for all textures used), and the problem's solved.

What's happening here is that if the "Read/Write Enabled" is not enabled, the texture is never stored in ram, but only vram, as such you cannot use it for packing as the cpu can't access it.

Reference (some cool articles you could also check out):

Sunday, March 6, 2011

Download any Unity3d version...

I'm trying to clean up some bookmarks of mine on Chrome, so I thought I post something up on those things which I bookmarked on (one by one) which might be important for me in the future... :D

Well, anyway, for this post, it's about how to download any Unity3d version from the main site, the link is as follow:, where by "N.N.N" is equal to the version of Unity3d which you wanted to download... such as "3.1.0", "3.0.0", "2.6.1", etc. 

Useful for when you want to open up your old Unity projects but you don't want to ruin/destroy it by upgrading it to the latest version, cuz mine tends to do like that. Like my previous Alice in Wonderland parody game, it's not functioning properly (character move slower, some scripts not working, laggy issue, lighting problem, etc) after I upgraded it to version 3.0... but good thing I saved a copy of it... 

Thanks whoever it is that inform me about the address... forgot who he is, some random Unity3d developer on Twitter...

Started to feel like my blog post was a bit dull... I'll add more images in my future post... regardless of how unrelated it is to the context...

Saturday, March 5, 2011

A Mark Zuckerberg method?

So I'm currently working freelance for a third party game development company (who wants to be first party) on an MMO game prototype... which was also a more local version of a ripoff of the Japanese game AiSpace. And I started having ideas to create an MMO of my own, somehow a little similar to what my client wants me to do, but better, and with more unique contents...

It wasn't until a few days ago when I saw a news somewhere about the Winklevoss twins wanting to get in another lawsuit-battle with Mark ("Zuckerberg" was too hard to type, I'll just go with "Mark") of Facebook (which I'm not gonna go into the details) and the news reminded me of the Facebook story in The Social Network... where Mark sorta "steal" the Winklevoss twins' "idea".

And it gets me wondering, would I be a thief (or a more appropriate title such as: "idea stealing scumbag") for doing the same thing like what Mark did. I'm not saying that the fault's on Mark, I mean he does work very hard on Facebook, and seriously the Winklevoss twins has no right to just come in and claim money on something they did not contribute in, what a bunch of ass... Anyway, my situation now is kinda like what's inside The Social Network:  there's these guys (3rd party dev, no idea on how to code), who wants me to help them write an MMO game, and I kinda plan to slip out and develop another MMO of my own, get successful (just exaggerating XD), and then get sued for a "multi-million dollar idea". <-- (I laughed so hard at the last line)

Well, I'm probably just thinking too much. I'll continue working on their MMO, finish it, and start working on one of my own... And I might not even get to as great as Mark though... I mean, c'mon, there's like a million online games out there (some are great), and how could a beginner like me compete with them... lol... I guess we'll find out... probably next year~ :D

Thursday, March 3, 2011

Work, work, work, and 5 games in total...

As of February 21st 2011, I started working at TeratoTech as an intern for a game programmer position for 3 months; and FYP (Final Year Project) right after that. So currently I've been not-so-formally "assigned" to an Unity3d development section of the company, well apparently there's only like 5 Unity3d developers over here, in which 3 of them includes me and my two other pals who also came here to intern; and two projects for us to handle, in which I'm again, not-so-formally "assigned" to as the lead programmer of those projects... XD

Then, to make my life more exciting, I'm planning two join two more challenges this month (March): EGP and GPC. Not sure if I'm gonna join all of them, but I'm definitely joining one of them, and if both had the same theme at the same time, then I guess I could submit it for both the challenge. haha

Lastly, for the fifth game which I'll be working on (as described above, I'm ady having about 3-4 game projects running in March), will be an online MMO prototype. Not the World of Warcraft type (that's crazy!), but more like Second Life, without the world creation part. It's actually a ripoff of a Japan online game called AiSpace (according to my client). I'm only gonna be working on the scripting part, while the rest (graphics and audio) will be handle by the client's company. Btw, I'm given 6 months to develop this MMO's prototype, not a month, so I still have some time left for other projects too... :) 

Well, in conclusion, though most the games I mentioned that I'd made above will probably take up my entire March period, I still have plans to make my first "big thing" as an indie game developer. I already have the basic concept and some minor advance concept for the "big thing", and I'll develop it as soon as I'm free from all these. And I kinda promise my client that I'd work with them on another two iPad games after the MMO thing, but they're gonna have to get another guy, cuz this guy (me) has a dream (game) he wanna to achieve (make)~