Sunday, July 28, 2013

What the hell is DPI?

What the hell is DPI?

The reason I wrote this blog was due to a certain experience in the past.
The Team Leader didn't know what the hell DPI was.
And after realizing that he's just a noob trying to do something big, everyone quit.
Of course, the Project got cancelled and we worked for free for 2 weeks.

Anyhow, It stands for [Dots per Inch]


In Computer Graphic, 2D image size is measured in Pixel, AKA Dots.

How large is a Pixel? It has no actual size in real life space.
Vice Versa,
km,m,cm,mm, etc have no actual meaning to computer space.

Thus came DPI.

DPI is a measurement conversion of real measurement to computer space.
1DPI means there is a Pixel per real life numerical Inch.

For example,
Standard A4 paper's size is [210mm*297mm] or [8.27in*11.69in]

A common DPI for detailed illustration is 300DPI
8.27*300 = 2481
11.69*300 = 3507
Which means that A4 in 300DPI is equivalent to [2481px*3507px]

As long as this proportion is kept, it has pretty much the same meaning as
A3, A2... A0 ... A_NegInf


Thus, if the Project Leader told you to

[We need it big, so make it an A1 size], but didn't tell you the DPI.
[Make it 1024*1024, 600DPI to make it more detailed]

there's a good chance that your project will fail due lack of technical knowledge of the Project Leader.

Thursday, July 25, 2013

Unity Texture Setting Performance Test

In Conclusion, it's better to make a large file then compressed it down rather than making small file and make it TrueColor.

Tuesday, July 23, 2013

Programming Thought - Order and Execution

Let say that there's a Button and a GameObject Ball.

The GameDesigner wanted to Ball to move when the button was click.

The shortest method to do this would be


void OnClick()
 GameObject ball = GameObject.Find("ball");
 ball.Translate(new Vector3(1,0,0));

End of story, simple right?

However, this would pose problems in extended coding.

-- The Ball isn't doing thing by itself --

When the Project became larger, there might be input from other sources that caused the ball to move.
If someone, other than the coder, have to search through the things that caused the movement, the most obvious action for the searcher would be to look at the ball itself.
However, if the ball itself doesn't contain the code, it will be a real hassle to figure out where it originated.

To solve this, Codes need to be separated into [Order] and [Execution]

- The code that tell something else to do something, but does not do it itself.


Ball ball;

void Start()
 /*If the referenced object will never be change during runtime, it would be
wiser to cached them at the start. Otherwise, the program will have to find it
every loop, thus slow down the program*/
  ball = GameObject.Find("ball").GetComponent<Ball>();

void OnClick()
 //the button ordered the ball to move, but did not execute the movement.


-  The code that actually do something



Transform thisTransform;
Vector3 moveVector;

void Start()
 //Cached transform so that it will not have to be searched every Loop
  thisTransform = this.transform;
 moveVector = new Vector3(1,0,0);

//Called from Button.cs
public void Move()

In this case, the Ball itself is the one doing the execution.
It would also be a good idea to comment on where it was called from.