Opinions please on how to assess the lightness/darkness of objects in the camera view

Hello, I have a need to build a basic “light meter” in my BJS project and one of the inputs is to assess whether the camera is looking at a lot of dark colored objects, light colored objects, or any mixture in between. This a port of a Unity project, and in Unity I used a duplicate camera to write to a very low rez render texture, converted it to black and white, and read the pixels to calculate an average brightness.

Is this the same approach I should use in BJS, or is there a better way (like with a post process or something)? Just looking to get pointed in the right direction, thank you!

The approach could be the same, implementations may differ.
You may have a look at Image Filter - Babylon.js docs
And when reading pixels, read only every 10th pixel or so.

Thanks @labris, this certainly looks promising. Do you know if the ImageFilter class can be made available in a BJS playground (I’ve not yet been able to get it to work), or do I need to experiment with this in a local project?

Local project seems to be easier than to struggle with PG :slight_smile: