How to Retrieve Lighting Information?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
R@z
Posts: 1
Joined: Wed Nov 07, 2012 2:35 pm

How to Retrieve Lighting Information?

Post by R@z »

Hi,

I'm currently working on a project where I aim to implement an illumination based 'visibility' factor similar to games like Thief.
Ideally I'd like to sample the luminance of a single point(i.e. vertex) or face and feed the return value into a variable for use on determining visibility.

Unfortunately I have only limited programming experience, nor am I too familiar with Irrlicht's ins and outs, and as a result have not been succesfull.
My own efforts have gotten me as far as to printf the getLuminance value of a S3DVertex, but the resulting data seems to be static, and returns either 0 or gibberish well exceeding the 0-255 value range, depending on which of my various attempts I run. Additionally I have not been able to find any method of accessing the color values of individual faces (the operators available seem to be geared to various nonrelated mathematical calculations), hence why I have limited myself to individual vertices.

Lurking on the forums has also yielded no results so now I turn to you directly:

TD/DR Is there a (preferably easy to implement) method for obtaining lighting information from a single face/vertex?

Thank you for your time,

R@z
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Re: How to Retrieve Lighting Information?

Post by Lonesome Ducky »

A simple but robust way of doing it for static lighting would be with the use of lightmaps. Find the triangle that contains the point you want to sample, find where that point would be on the lightmap texture, and there's the color of the light there. The only real difficulty with this solution comes from actually finding the texture coordinates, but I can share some code to do that if you're interested.

If you want dynamic lighting, you would have to manually calculate the contribution of light and shadow to each face. This is quite a bit more complicated, but much more flexible
Post Reply