Showing posts from February, 2012

Unity3d: Forward Rendering Path Details

Titanium iOS/Android cross platform memo

As possible as you can choose non-dependent interface on specific platform. Be careful the include *.js path. Localization file at the string.xml file. When you find some item name displayed have problem, you need to check the file first.

JavaScript language advanced Tips & Tricks

Java script singleton:

var Setting =(function(){
    var instantiated;
    function init (){
        // all singleton code goes here
        return {

            setUserID:function( id ) {
                userID = id;

            getUserID:function() {
                return userID;

    return {
        getInstance :function(){
            if (!instantiated){
                instantiated = init();
            return instantiated;

Write data to file in Titanium

var configDir = Titanium.Filesystem.getFile( Titanium.Filesystem.applicationDataDirectory, "dirPath" );

    if ( configDir.exists() ) {

var config = Titanium.Filesystem.getFile( configDir.resolve(), "fileName" );

    if ( config.write( writeSettingToConfig( userID ) ) == false )
        // handle write error
        var error;
    config = null;
    configDir = null;


Shadow map PCF vs. Variance filter

PCF(Percentage closer filer): Because texture precision is not enough to confirm lossless. Therefore, we can reference the neighbor pattern. I use four corner texel( left-top, right-top, left-bottom, right-bottom) and the current texel.
                           float2 texCoord;
                           float4 p;
                           texCoord.x = shadowPos.x + 1/shadowMapSize;
                           texCoord.y = shadowPos.y - 1/shadowMapSize;
                           p.x = tex( sm, texCoord );  // left-top

                           texCoord.xy = shadowPos.xy + 1/shadowMapSize;
                           p.y = tex( sm, texCoord );  // right-top

                           texCoord.xy = shadowPos.xy - 1/shadowMapSize;
                           p.z = tex( sm, texCoord );  // left-bottom

                           texCoord.x = shadowPos.x + 1/shadowMapSize;
                           texCoord.y = shadowPos.y - 1/shadowMapSize;
                           p.w = tex( sm, t…

iOS vs. Android GPU architecture

iOS outperform Android for OpenGL apps on the exact same hardware. iOS offers a fast path for OpenGL apps. ( there are no intermediate buffers on iOS, but on Android whose surfaceflinger system will creates an additional copy of the entire screen which need to be copied over the main bus every time you swap buffers)

Get friends checkin from FQL

fql?q=SELECT coords, tagged_uids, page_id, author_uid FROM checkin WHERE author_uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

We can test the result from  Graph API Explorer

Create Facebook app id