Jump to content

Pupil dilation relative to screen illumination

Recommended Posts

I have a Unity application that needs to record pupil dilation as an indicator of user stress levels. For this to be meaningful, it needs to be normalized relative to scene luminosity. I don't see any obvious way to measure overall luminosity short of adding up all the pixel values and dividing by the number of pixels. Is there system parameter that provides this value or an API call that does that calculates it?

Link to comment
Share on other sites

@traclabsar There is no system parameter or API that does this but it's possible to implement yourself. Here is a suggested solution: " The usual solution to this problem is to render the scene to a low res (like 4x4 or 8x8) texture/render target. Then you have the CPU loop over all the pixels in that texture and compute the average brightness."

Source: https://answers.unity.com/questions/640447/detect-brightnessdarkness-of-a-scene.html

Note: For performance reasons you probably don't want to measure all of the pixel values, it should suffice to render a low res texture.

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...