Jump to content

Get light level in certain position?


joshcamas
 Share

Recommended Posts

Hey guys!

 

Is it possible to get the light level in a certain area/position? I'm needing this for my stealth-based game!

 

I'm also thinking of making it so in the dark people's pupils dialate, and in the light they shrink. Just for fun! xD

 

Thanks!

Link to comment
Share on other sites

Hey,

 

Light is computed through vertex and fragment shaders, so the actual information is not really accessible outside of that.

 

Depending on how your scene is set up and the type of your active lights, you can probably find out if a point is illuminated by casting a ray from this point to the active(s) light source(s), and see if that ray intersects something. If the ray does not collide with anything, then you can modulate the light level by distance for example.

Link to comment
Share on other sites

I guess you are talking about spotlight or pointlight ? (as directional and hemispheric lights have infinite range, so constant intensity : http://babylondoc.azurewebsites.net/page.php?p=22071 )

 

Maybe you can simulate the local light intensity according to the distance of your mesh from the light origin (and/or the light decay if any) if nothing intersects the raylight between the mesh and the light origin.

 

[EDIT] ooops, this duplicates Jahow's post, sorry.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...