2012
05.16

Hi,

After having a look at my hard drive i have found the code of some old projects that was never posted. Mobu 2 Max was just a proof of concept to elimintate intermediary files in a pipeline, by making different softwares communicate to each other directly. Here Python acts like a hub, it connects to 3DS Max via COM and to Motion Builder via TCP. It’s a 2 way communication so both softwares can send and receive data to and from each other.

Here is the link to the project page for more info and the source code.

2012
05.16

Hi guys,

So after 8 months… it seems like i was settled down again and ready to finish the Kinect 2 Max project. Unfortunately after looking at the code I really have no idea anymore of how to finish it. So instead of trashing it away (there is a lot of ours invested in it), I have decided to give away the source code. If you want to mess up, or you are just curious to see how it works, you are welcome to download it and play with it. Who knows, you might be able to even finish it! :)

If i manage to finish the few thing that is missing, I will post the updated code, meanwhile… enjoy!

I have posted some information about the project and the source code here.

2011
10.19
In Tech

What’s Gamma?

In monitors, the relation between the input voltage and its output luminosity is nonlinear. It usually follows a curve with a power of 2.2 (pow(x,2.2)). That curve is commonly known as Gamma.

The Gamma curve power varies across display devices but is usually averaged to 2.2.

When you send a value of 0.5 to your monitor to be displayed,  it is displayed with a luminosity of 0.218.
So in order to compensate that and display the image preceptually linear we need to apply Gamma correction.

For a monitor with a Gamma of 2.2, the inverse curve 1/2.2 should be applied in order to display an image correctly.

20111020-233355.jpg


Size matters!

Gamma correction was not originally designed to “fix the error of monitors”.

Human eye in normal conditions is more sensitive to darkness than it is to brightness.
In order to display a range of colors that would appear linear to the human eye, we would require much more information in dark intensities than in bright. Applying a Gamma curve of approximately 2.2 can effectively represent a perceptually linear range of colors in 8 bits.
If we wanted to create a real linear range of colors we would need a higher amount of data to make it appear linear to the human eye.
Therefore there is a difference between what’s technically linear and perceptually linear.

Original Ramp

Linear enconded in 5 bits

Gamma encoded in 5 bits


It just happened by coincidence that the Gamma of  monitors is very close to the inverse of the perception of intensity of human eye.


Input, file, output…

Digital cameras usually don’t apply Gamma correction, the file format is instead the responsible for that.
JPEG file format applies Gamma correction when storing images. RAW file format saves the image linearly with a Gamma of 1.0. MPEG files are Gamma encoded to optimize storage and playback bandwidth.

That’s why when you display a RAW image in a computer it looks dark. The image is saved in linear space and the graphics card is applying a pow(x, 2.2) curve.

So in order to see in your monitor the same that you were seeing when taking the picture, images need to be Gamma encoded and Gamma decoded using the same curve.

So let’s see an ideal case: You take a picture with your camera, the picture is Gamma enconded to pow(x, 1/2.2), you open the picture in your PC, the graphics card Gamma decodes the image  using pow(x, 2.2), the image is displayed in your monitor.


How does that affect Game developers ?

Gamma affect Game developers in 2 specific steps: shader calculations and image display.

In modern game engines, textures are read and modified and written through shaders.

The maths behind shaders are done assuming linear inputs, therefore if we input Gamma corrected textures the maths will be wrong.
It could seam at first sight that this is just subtle detail but, trust me, the results of using a correct Gamma pipeline are very noticeable.


Image from GPU Gems 3

On the other hand we need to Gamma correct the image before displaying it on the screen. The problem here is that the Gamma of the many display devices out there is different. So the only thing we can do is assume a Gamma of 2.2 if you are on Xbox360, PS3 or PC. And add options in-game to let the user fine tune the Gamma for their own monitor or TV.

How do we provide the shaders with Linear Space textures?

We have seen that in order to convert a Gamma corrected image, back to Linear Space, we need to apply the inverse Gamma curve.
So the first thing we need to have is a consistent Gamma across all our textures.

In order to accomplish that you will need all your artist’s monitors to be calibrated so that they all display Gamma equally. So first thing, go and buy a monitor calibration device.
Set all your monitors to sRGB to make sure that you are applying a standard and well known Gamma.
Use a sRGB Profile in Photoshop, so your textures will be saved with Gamma embedded information.
Then adjust your textures freely so they look good in Photoshop.
Take into account this when painting textures: Unreal Texturing Guidelines.
After that you will have consistently authored textures in sRGB Gamma Space.

Now the engine can have some consistent information to work with when converting textures back to Linear Space.

Take into account that virtually generated images are already in Linear Space, i.e: Normal Maps, Light Maps, etc. So they don’t need to be Gamma corrected, and can be input directly to the Shaders.

Once the textures are passed to the shaders in Linear Space, all mathematical operations such as Lighting, Alpha Blending, etc. can be done properly.
The engine before displaying the final image to the screen will apply Gamma Correction to the entire frame.

Further reading:
Gamma  Correction – Wikipedia
GPU Gems 3 – Chapter 3
John Hable – Linear Space Lighting (Naughty Dog)
Gamma Correction in Unreal Engine

2011
10.18
In Tech

Recomended reading!

Nvidia GPU Programming Guide
CG Tutorial
GPU Gems
GPU Gems 2
GPU Gems 3

Enjoy!

2011
09.14
In Misc

Creating applications is challenging and fun. But what about creating your own hardware to interact with them?
If you want to get into electronics, but it sounds like rocket science to you. Sparkle Labs has released its Discover Electronics Kit version 2.
The Sparkle Labs Education site has a bunch of interesting information and great video tutorials that will help you understand the basics, current, resistors, capacitors, etc.

2011
08.17

Nice talk from Jason Fried at Ted.com about interrupting employees and breaking their creativity flow.

How many times have you reached the end of the day and you have asked yourself: “what did I do today?”.
Creating the right atmosphere that allow employees to work without interruptions ain’t easy.

“M&Ms Managers and Meetings, those are the real problems today…” Jason says.

In my opinion, it’s not just limited to that, software crashes, server hangs, also break your flow. This is specially important when you are trying to collect metrics data. Hey, let’s find how many times our editor crashes and how long it takes for it to load.

Loading time * Number of Crashes = Time Lost * Average Employees Salary = MONEY LOST.

Well… As my brother Oliver Henares says, “Life is not in an Excel file”. Add to that formula the fact that when your editor crashes your employee is breaking his/her creative flow, and it could take him/her hours to reach back that climax. That has an impact on the quality of the product which is not easy to represent in numbers.

Explaining something that can’t be shown in numbers, to people who think in numbers, isn’t an easy task. But it’s a philosophy that must be applied up to certain degree, to any creative development environment if you want to add that extra shiny touch to the final product.

2011
08.16

I have read this extremely interesting article, via RobG3D blog. It’s amazing how sometimes, there are situations that you have been seeing during years but, you just haven’t taken a step back to think about the words to describe them and therefore analyze them and look for a solution. When you see them broken-down, clearly written, it all seems so obvious , it all makes sense.

2011
08.01
In Art

Having fun with ZBrush and trying to get some skills back during the downtime between projects.


2011
04.22

I have improved the framerate quite a lot since last time. It is almost ready to be used for production. At the moment I am grabbing the positions of the joints, next step is to grab the rotations and apply the tracking data to a skinned character. Stay tuned!

2011
04.11

Realtime motion capture with kinect and 3DSMax.
I created a dll which wraps some of the functionality of OpenNI and can be loaded and used from Maxscript.
Please note that the huge lag in the video is due to the slow laptop I am using, also capturing the screen at the same time doesn’t help.