This post was supposed to be a bigger post (Yes I am an expert in advertising my posts), explaining how I went on and did the amazing thing of fitting my AR object into the real world without having it “pop out” too much. My thought was that when an object is rendered into the real world, we need to account real world camera problems (in reverse) like the white balance.
Finding the color temperature
The color temperature expresses what kind of light color comes from a light source. A warm light lets a scene appear in orange tones. A cold or very bright light dyes the scene in blueish colors. Calculating the correct color temperature and making a correct white balance is a very complex thing. There are some algorithms online but doing this calculation from an RGB value is not ideal. Just imagine a picture of a very blue car. Just because the pixels are blue, does not mean that the light is warm or cold. Sure, in a sunset the blue would be desaturated but it also just could be the car paint that is older on a cloudy day.
I did the one thing a good developer would do in this situation: Just don’t do it, try something else first. My initial thought was not “I have to be able to do an automated white balance”. I wanted to know if a white balance would help setting an object into the world at all. So I made myself a little interface so that I was able to change the lighting of my scene by clicking on a sun, cloud, candle or lightbulb icon. Just like a camera interface.
You can see the result above. The left lion has a pure white light shining at it and the left one has an adjusted one to the room I was in. It does not seem to be any big different if the light of my unity scene is set to white, yellowish or blueish. The object just looks different, but not more or less fitting. What seems to be more important is the overall brightness and a shadow that lets the object stay on something.
All in all this testcase did not confirm my expectation but that is not a bad thing at all. I now know that we can play around with different lighting and just have to keep an eye on the brightness.
Below you can see an image of the objects in a darker environment. They definitely should have been darker to fit in.