Adjusting ingame light by what the smartphone camera sees (maybe greyscale?)

Hey guys,
I’d like to create an AR game using my smartphone and I wondered if it is possible to adjust the lighting of the game depending on the real lighting (light source). So like the game fits into the real world a bit more.
I don’t know much about these things but I thought that it may be possible, to access the camera, grayscale the picture and looking for the area with area with the highest amount of white and therefore positioning a point light like this. And maybe it is possible to get the average color of the image to adjust the light intensity… does someone have an idea? Would it be possible without so much complex code?

Hi !

I don’t know how you can retrieve the output of the camera, but i’m sure that you can find it easilly on the web.

For the lighting, one solution can be to compute the average luminance (also check on web for formula) of the pixels of the camera and modulate your ambient light (global directionnal) according to that average.

Computing points light according to regions of the camera output which are brighter seams to be much more difficult. You must detect these zone, then compute a position in 3D of your point light to place them. I think that it won’t be precise and your lights will flick a lot (due to change of position).

Finally you would probably have to make some timing measure to see how much time does it take to get the output of the camera to see the frequency where you can evaluate your lighting (maybe doing it each frame will be expansive).

If something is not clear, or you want to discuss about anything with more details, feel free to ask !

Hope it helps :wink: