Detect Light Level at Point? (Stealth AI)

I was working on a game with some stealth elements when I came across this problem. I want the player to be harder for the NPC guards to see when the player was in the shadows or a dark area. I couldn’t find any method to detect light level or shadows. The closest method I found was getGeometriesInLightRadius, but that seemed to be for rendering. Thanks in advance.

The simple answer:
Create a ray pointing from your point to the light source. See if it intersects anything.

@pspeed said: The simple answer: Create a ray pointing from your point to the light source. See if it intersects anything.

OK, so there’s no way to get a light value of any kind? There are going to be many light sources in the scene. I could create a ray to each of them, but it seems much more efficient to read a light value.

@undo15 said: OK, so there's no way to get a light value of any kind? There are going to be many light sources in the scene. I could create a ray to each of them, but it seems much more efficient to read a light value.

Well, first of all the information is not available. Second, even if the lighting value could be extracted from the rendered image then you’d still only get the pixels that actually showed up on screen. This is a far fewer number than would actually be in the world.

Edit: and note if your scene has more than a handful of lights in any given area then you are already going to run into performance issues.

1 Like