Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Question about lights and lighting

Author
Message
Sam ONella
11
Years of Service
User Offline
Joined: 8th Jul 2014
Location:
Posted: 8th Jul 2014 22:11
I'm a bit new to DB, so bear with me.

I was working on a project when I noticed something strange. Despite the fact that two objects were equal distance from an omni light, one was shaded significantly darker than the other. To isolate my issue, I threw together a controlled environment just for this bug(?). I positioned a sphere at the same location as the light. (sorry for sloppy camera controls, I was too lazy to get math involved in this.)



Any insight as to why this is would be very much appreciated.

...
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jul 2014 02:32
Have you forgotten about the default light 0?



Powered by Free Banners
Sam ONella
11
Years of Service
User Offline
Joined: 8th Jul 2014
Location:
Posted: 9th Jul 2014 03:08
Where is the ambient light located, exactly? if anywhere?

...
Sam ONella
11
Years of Service
User Offline
Joined: 8th Jul 2014
Location:
Posted: 9th Jul 2014 03:09
where is the ambient light located, if anywhere?

...
WickedX
17
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 9th Jul 2014 12:22 Edited at: 9th Jul 2014 12:22
Ambient light shines from everywhere and in every direction. Light 0 is set as a directional light. A directional light shines from everywhere but in only one direction. This demo should help.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jul 2014 12:56
There are two default lights, an ambient light which lights every point in the scene uniformly regardless of position or orientation, and light 0 which is a directional light. Your demo therefore had three lights: the ambient light, the default directional light 0 and your point light 1. Simply hide light 0 and you'll see the effect of your light (plus ambient light of course).

There's one further issue you need to bear in mind with DBPro point lights - the lighting is calculated per vertex and the result is interpolated over the relevant polygons. This can give unexpected results with low poly plains, boxes, etc. For example, if you create a plain using



and then light it using a point light as follows:



you will find that the plain is completely unlit even though the centre of the plain is only 10 units away from the point light.

What's happened is that all the vertices of the plain, which are located at the four corners, are beyond the light's range and so get a light value of zero. This is what then gets interpolated over the whole object - the central point of the plain, for example, will simply be lit by the average of the two diagonally opposite corner points and the average of two zeroes is zero.

There at least two solutions, one is to use high poly plains instead of default plains (IanM's Matrix1 plugins have a function for this) which will reduce this effect to some extent, a second solution is to use a shader to give you true per pixel lighting.

I use the second but it does require you to know about shaders - or at least how to use them.

A further problem with default point lights is that it isn't obvious how they are attenuated with distance - for example you can't make a light brighter just by increasing the range. In a shader you can get exactly the attenuation effect you want.

The following demo illustrates the difference between the default low poly plains and the high poly ones provided by the Matrix1 commands:



Hope this helps.



Powered by Free Banners

Login to post a reply

Server time is: 2026-07-06 04:30:25
Your offset time is: 2026-07-06 04:30:25