Getting the light level of a point

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By genfy
:warning: Old Version Published before Godot 3 was released.

I’m currently trying to create a stealth game in Godot 3D, I’m wondering how I could measure the light level of the position that the player currently resides in.

I’m really quite inexperianced with the way lighting works in godot, so could you help me out?

Light is rendered on the graphic card, on a 2D rectangle that fills the screen. Getting the light level requires to download some data from it in a format that is fit for your usage, and is not a practical way in your case.

Some ideas:

One naive way could be to have a camera render a tiny portion of the position your character stands, excluding the character (to prevent shadow from interfering) and get pixels from its rendered texture. But I feel this is going to have flaws, and could be tedious to setup right.

I would advise you find a simpler and faster way.
In 2D, what I would do is have a lightmap grid, so I can get lighting values fast and easy. In 3D this can be achieved too, but maybe not as easily.

Or, I would use the physics engine and perform raycasts from nearby light sources to the point I am querying, so i know how many lights can “see” that point, and so I know roughly how much light it has.

All this also depends on why you need this information, how much precision you actually need, and how you want to use it.

Zylann | 2016-09-18 23:01