Tuesday, September 09, 2014

Getting Started with Game Programming Using Unity

I have been starting out with Game Deveopment recently, specifically using Unity Game Engine. It’s been an interesting experience so far but also an overwhelming one. There are a lot of aspect in game development that trying to ship something quickly requires you to have a good focus in both the learning and working process. Below is the list of starting guidelines that I find could save you a lot of time but at the same time give you most benefit :

  • Use tutorials and videos as  your main learning tools. Unlike what I experienced with learning many development platform before, manual and documentation of Unity (version 4.5 as of this writing) does not give you much foundation to start being productive. Instead, their tutorials, videos and samples on the site are the most useful ones to get you started and learning the concept and practices. You can refer more to manual and documentation later on when you have more context and the relevance of it’s contents
  • Read this two books : "Game Coding Complete” and “Game Engine Architecture”. It will give you valuable shortcut to game programming world that could probably take you months or even years figuring it our yourself from various sources.  Surprisingly, it gives you more insights and contexts on why Unity do things the way it does compare to Unity-specific books. Also as an added bonus you get also the concepts of game development and engine in general too, not just Unity
There are a lot of other materials to advance further, of course, but so far I find the two above is what I wish someone had told me when I got started before wasting too much time to build something by reading the manuals or reading Unity-specific books :)

Friday, June 06, 2014

HEVC support on Android

HEVC is the new video coding standard which even on the Desktop it is still basically under development. So, having a support for it on mobile device at this moment is even more interesting.

For library , it seems there is two major hevc decoding support currently, that is openhevc (part of libav library) and libde265. Both seems to be usable, at least for low resolution samples. However, their use require you to integrate them to media framework or pipeline like gstreamer.

If you want to just have quick look of hevc playing, right now you can just try Vitamio SDK. It already support hevc through its use of ffmpeg underneath it. It also mimic the API of Media part of Android SDK so it will be straightforward to use compare to using third party media pipeline like gstreamer as mentioned above.

Thursday, June 05, 2014

Conversion and Playing of HEVC on Desktop and Web

HEVC (H.265)  is the new emerging video coding standard. It is made as a success for the widely used H.264. It's implementation and adoption progress is quite fast. It probably because the 4k display has been out for someitme and the video streaming is  currently booming, both of which are being handled nicely by HEVC.

At the moment of this writing you can actually able to convert material to HEVC and playing it. The implementations are mostly still in beta stage and some are not avaiable through the more common publicized channel, but it's quite usable from my tests so far. The quality is quite good too in term of visual quality and compression ratio. So, you can already play around with the technology at this stage.

Conversion :  x265 and Handbrake Nightly Build


x265 project probably is the most used HEVC converter right now. It has progressed quite far, below is the quote from the author on one of the forum :
x265 development is going well.  x265 is often able to exceed the HM reference encoder in quality, with performance that is orders of magnitude faster.  The x265 HEVC encoder is easily able to encode with quality / compression efficiency that far exceeds the best H.264 encoder available, x264.  We've just passed the 0.7 milestone.  Although we have more algorithmic improvement and performance optimization on the development roadmap ahead, x265 is quite usable today, and it includes many advanced features.

So, it is quite a safe bet to choose x265 project for HEVC encoding purpose. However, using it directly means using CLI which is cumbersome and would require manual demuxing and remuxing, so it’s better to use proper video conversion application.

There is no official release version of full-featured video converter that uses x265 yet. However, Handbrake-nightly-build already integrate x265 whitin. The developer said that they won’t be  releasing it until HEVC standard more widely used which probably will still a while. So, you just have to use the nightly-build if you want to have access to HEVC conversion on Handbrake for sometime ahead.

Unfortunately, currently it only exist on Windows version of Handbrake. So, no support for other platform for now.





Now, about the playing.

VLC Nightly Build and Playing on Browser


The latest release version of VLC (2.1.4) can not play HEVC output in container (muxed) yet.  It will complain when you try to play the file you encoded with Handbrake above.  However, hevc playing support is currently progress and can be tested on VLC-nightly-build version (2.2.x). It works well playing output from Handbrake when tested.

Also, the good thing about VLC is that it has browser plugin support for Mozilla and Activex(IE) so it can be used to play HEVC content on the browser. It currently only support Windows though but the plan is to have it on other platforms when 2.2.x finally released. This would be interesting since it means you can now start streaming HEVC stream to wide range of targets.

Another alternative for the web/browser support for HEVC is DivX Web Player whichs seems to be free although not open source.




Monday, April 14, 2014

Better way of combining path in C#

You could do string operation to construct path as below :

string path = path1 + "\\" + path2;

However, more portable and cleaner way would be to use Path.Combine as below :

Path.Combine(path1, path2);

The above avoid you to make manually ensuring the correctness of path separators.

Monday, March 24, 2014

Choosing Logging Library for .Net : NLog

When it comes to logging, printing it out yourself to console or file probably the most straightforward way. However, if you want to get more structured in your log, with level and flexible on/of switching you'll need a more dedicated logging library. However, like any library, choosing the sweet spot where you get the feature you want but with the least complexity and learning curve can be challenging.

As for logging, when I research around the two that pop up most is log4net and NLog. The choise is pretty simple though, log4net is good but pretty outdated now while NLog is quite active, well-supported has rich feature. So, the choice goes to NLog.

Quick Usage :

After you link the library (using NuGet or manually). Declare the logger in your class :

private static Logger logger = LogManager.GetCurrentClassLogger();

and call at the place that needed it :

logger.Debug("log message");

You can add a lot of additional details to your log with its predefined variables. You can consult the manual to see what is available. Also, since you declare logger on each class, it can automatically  print in which class and the point where the log is called. It is quite useful for debugging.

Monday, March 10, 2014

Lesson about delegation from OpenCL

Using OpenCL and the complexities / benefits that comes with it reminds me of an issue of trade-off in delegation. You can always do things the simple straightforward, serial way but there is a limit of how much and how fast it can finish the tasks. We can scale things better by utilizing more external agents and manage it. However using additional agents means delegating tasks to those agents and manage the overhead and unpredictability that comes with it. This is why the code to achieve the same thing using OpenCL can be quite complex since you need to manage the data and logic that comes to and from those computing units and get them to work together properly.

It's not just cost that is increased though, the risk is also higher. When you delegate, you add another factor with its own set of quirkiness to your system. Each agent you add, you add another risk of it fail in some way and effect the overall system. In OpenCL, certain GPU might not behave as it should, your calculation might fail in certain configuration. So, you will need to add more activities to manage the risk. How it can be anticipated, localized and how the system can cope gracefully when it happen.

So, since delegation is not free it is important that the scale of the problem would need to justify the use of delegation.  You can add more things, method, people to your system, but when it does not fit your scale, it will become a burden since your output, what you get, is lower than what you need to expense. In term of OpenCL, the low complexity or low number of calculation probably not worth the trouble. For example, even when you ding the formula is complex and can be paralellize but if your expected data to be processd is not much, it probably better to just code it the traditional way.

Delegation can be costly and risky, but if you need your solution to scale better, the return can be very much worth it.

Friday, February 28, 2014

Translating Traditional Program Logic to OpenCL

If you just started to look at OpenCL and see the example of the code, it can be quite confusing on how it got that way from its traditional program logic counterpart. Take a look at an example of comparison below taken from PDF Overview on OpenCL site :

You can see that the calculation is intact but you can't seem to find where the for loop counterpart is.

It is because, the logic has been separated between host (your main program) and kernel (that will be sent to device). So, you need to look at both of them to get the whole picture. There is some data partitioning done that you can take a look at the code at the host. Together with the batch processing happen in kernel code you can start to see the implied loop there.






Due to its parallelism and batch processing nature, the logic in OpenCL can look more declarative and more separated compare to traditional one. So, the logic that you expect to find will probably be implied somewhere in host and kernel code. This could help if you try to read the existing code.

Thursday, February 27, 2014

Getting Started with OpenCL

I started working with OpenCL recently on the project at work. It's quite exhausting to learn initially since OpenCL has quite steep learning curve. However, once you have started to picked up some of the core concept, it could be quite interesting. Also, you will add another valuable tool to your programming arsenal, especially in the aspect of performance and speedup. You will start to be able to exploit not just CPU but also any other computing device that exist on the system like GPU quite conveniently.

Here's summary and pointers of how to get started with it from what I note so far.

Overview

You can get an initial overview from the surces below :

 As for its Wikipedia Page, I don't find it really informative at the moment, at least if you want to get an overview of what OpenCL is and its relevance.

As usual, google search and some blog entries would not hurt too. However, it's better not to take too much time researching things online since I think your time is better spend reading the book below.

Book : OpenCL in Action

There is not many technical book that you can enjoy reading cover to cover. This one is one of them. It's better you read from beginning to end serially. It build up from chapter to chapter. Also, it does not cross reference things too much between materials which could be annoying on some technical books. The materials coverage is very good, from the history, introduction to advanced topics.

If you have some questions on your mind from reading other sources previously, there is a good chance that you will start to piece things together when reading this book. It gives a good foundation for understanding why OpenCL is the way it is. OpenCL syntax and functions will still be quite overwhelming even after you finished with the book but knowing the concept behind will make it much more manageable.

I find the highlights of the book is its use of analogies that helps a lot in explaining the abstract concept and architecture of OpenCL.

Revisit Specification and Reference Card

If you have skimmed the specification and reference card above, it's time to revisit it again. You will now find it much more clearer now and they are starting to be more useful. It will also add more details from what is covered on the book. Personally, I really like the layout on reference card which help in getting a good high level picture of different parts of OpenCL with it's colorful boxes and groupings.

At this point, you can start to work on your specific issues and continue learning from there. As usual, after the initial learning, the actual work is where we will learn most. This is especially true in complex technology like OpenCL.

Thursday, February 20, 2014

Migrating to Android from iPhone

My iPhone4 got the "people can't hear me" problem. I've exhausted all the possible trick to solve it that does not require opening up the hardware. There is little-used s3-mini laying around so I decided to try to migrate to it and see what happen.

I expected some limitations when moving to Android from iOS since I have been accumulating many apps and it has quite integrated to my daily workflow. However, after sometime, I can say that the migration is quite seamless. Most of my usage can be transferred to Android plus some more Android-specific goodies (I think widget is cool). More about this below.

The Apps

At this point, almost all the well-known apps have both iOS and Android version. So, for apps like Evernote, Springpad, Pocket, Feedly etc. I don't have any problem at all. There is slight differences here and there but for my personal usage there is nothing significant that I find missing.

For less well-known apps I usually can find the comparable counterpart. I have to say though, the apps on iOS feels more "elegant" somehow. However, if you care mostly for the function, it's quite negligible since Android now has large number of well-written apps.

Surprising Finding on Navigation Apps Department

I have Garmin Indonesia on my iPhone and it is sad to see that there is none of it on Google Play Store. I have searched for the alternatives on several occasion with no luck until I stumble upon Polnav EasyDriving app. It's quite "hidden" from my previous search, probably because it's google playstore page uses non-latin characters mostly.

Surprisingly, it works really well. I used Indonesian map from navigasi.net (which is a really great crowdsourced map, BTW) and it is loaded very nicely. The navigation screen is clear, fluidly updated and give me several notification when getting close to turn to make sure I don't get past it. Really cool!. And what is even more surprising is that is free which is quite unusual for offline gps navigation app nowadays.

The search for address is really good but somehow there is no POI-based search that I can find. This is quite unfortunate and hopefully it will be there on future versions. Aside from that, I have no complain for it.

What is Missing

One thing that I miss quite a lot is a good freeplane-compatible mindmapping app. There is iThoughts in iOS but none that comparable to it on Android. Fortunately, I have been "flattening" my data recently and many has been migrated as Evernote or Springpad data. Some of it are still on freeplane format though and for those I still have iThougts on iPad. So it's not really a critical issue actually but it will be nice if I can still accessing my mindmaps on the smartphone too.

My iPhone4 is not going to retire soon though, I still have it laying around and use the apps on it occasionally. It basically now function more as and iPod than an iPhone. For example, I still use Garmin on it although I already have Polnav on Android as mentioned above. It is still useful to use GPS on separate device on some circumstances.

So far I quite enjoy the migration and I can't say it's better or worse. It just different, I guess.

Tuesday, February 04, 2014

Import Existing Repository to Bitbucket using TortoiseGit

When you want to import an existing local Git repository to bitbucket you can follow this official guide. However, one of the section involving steps with git command line as below :


I am used to using TortoiseGit on Windows and rely on it for all my Git command needs. So, I find it unpleasant to go to the shell to just do all the above. It feels like a leaky abstraction happening. I am sure there is more convenient way to do it using TortoiseGit instead. So, below  are the above steps done using TortoiseGit :
  • Right click on the folder->TortoiseGit -> Settings
  • Git->Remote and enter remote origin value as pictured below
 
  •  Right click on the folder->TortoiseGit ->Push
It looks more wordy but it is actually more pleasant to do in GUI-based environment.