This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

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?

in Engine by (48 points)

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.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.