Friday, November 22, 2013

[Unity] Mobile Test Setup


After 2 years without using Unity, got to grab some memory back :)

Android
1. Install Android SDK
2. use Android SDK Manager to install platform files & USB Driver (platform 19 seems not working, I used 17 instead)
3. enable "Unknown Sources" on Android to allow non-GooglePlay apps installation
4. install any file manager for the device (I used the one from rhythm software)
5. build .apk in Unity and copy it into the device
6. use file manager, navigating to where the apk is.  Install, Done!

iOS
On Unity side, just go to the player settings, make sure the bundle ID matches the one in provisioning profile, target iOS version should be set by default to the oldest.

http://www.brianjcoleman.com/tutorial-provision-your-app-to-run-on-a-device/

I found this tutorial written by Brian Coleman quite helpful. The only few things it doesn't mention is you might need to set up the deployment target in Xcode and make device "use for development".


Thursday, November 21, 2013

[Note] Rendering Equation




Differential Solid Angle:
Since light is measured as energy per unit surface area, when we talk about incoming light, we actually mean the amount of light from a small region instead of a beam with single direction.

Differential solid angle is used here for this purpose.
(radius equals to 1 so it's ignored)
it can be treated as a tiny flat region on the unit hemisphere of the object surface element , and because it's tiny and flat, we can assume this region is uniformly illuminated.

The region where the lights come from doesn't have to be on the hemisphere, it can be from some other surface area in the scene. In this case, the differential solid angle formula needs to be changed a bit:

 

 

BRDF:
BRDF is used to describe how much light is reflected. It's defined as a ratio of reflected light in direction Wo to the amount of light hitting the surface element from direction Wi.

if incoming light is from a region on the hemisphere:

dw is the differential solid angle, and remember it's a tiny area that is uniformly illuminated, so we multiply it by Li to get the total amount of light from that region. And because we need to know the amount of light hitting the object surface element, we have to project light from that region onto the surface element. That's where the cosine comes from.

From this BRDF formula, we can get a basic reflection equation:
Lo = BRDF * Li * cos(theta) * dw

if incoming light is from other surface in the scene which mostly is the case, we need to replace the differential solid angle with the one just mentioned above:

 
 

here we get G (geometry factor) =  

so reflection equation becomes Lo = BRDF * Li * G * V * dA
V here stands for visibility between 2 surface points.

OK, all the formulas above are based on one area of light in and one light out. However, in reality, there should be countless lights from every direction contributing to the final reflected light in the direction of an observer. So no doubt, integral !!

 

fr function inside integral is BRDF


Rendering Equation:
Finally time to get the rendering equation!! Basically, we just need to grab the reflection equation above, and add emitted radiance in it because the surface element itself may also be an emitter: