Lightning - no falloff?

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
suliman
Posts: 379
Joined: Sat Sep 23, 2006 2:06 pm

Lightning - no falloff?

Post by suliman »

Hi

I have an outside environment (aircraft game) and use this light:

Code: Select all

float sunHight=4000;
ISceneNode * light= gfx.smgr->addLightSceneNode(0, vect3d(0,sunHight,0),SColorf(0.2,0.2,0.22),6000.0f);
Problem is it has no falloff = i travel in the light for a while until i reach the end of the radius and then it just gets black. Shouldnt the light fade out when getting closer to the end of the radius? Can falloff be controlled?

I plan to have two "suns" that travel with the camera and shines on all objects from two directions (with one being less strong); does this make sense?
I also set some smgr->setAmbientLight() for some general lightning of the scene, but that seems to not be enough.

Thanks for your input.
Erik
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Re: Lightning - no falloff?

Post by chronologicaldot »

irrlicht renders lights as 3D boxes, 'cause it's fast and cheap. As such, there is no "falloff".
Off the top of my head, I can think of one of two ways you could do it (there's probably more, but I leave that to you):
1) Using a shader (probably the best thing) that keeps track of the distance from the light and lights everything accordingly.
2) Creating a scene node animator that follows the player's aircraft and causes the sunlight to a) become lighter and have a smaller radius when the player is nearer to the sun and b) become darker and have a larger radius when the player is farther from the sun. That's the cheap way, though I can't say it's fast either. idk. I haven't tried either method.
brainsaw (I think) has an aircraft game, so you might ask him about what he chose.
http://irrlicht.sourceforge.net/forum/v ... =6&t=49163
Edit: I just realized his game is for browsers. Still, he may have used a similar rendering model as irrlicht. O_o
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Lightning - no falloff?

Post by mongoose7 »

The lights do fall off. But your distances are soooo large. I think the turning black is because you reach the far plane. But you can set the attenuation yourself using the light's interface. But maybe try scaling you scene down (to a hundredth) first to see the effect.
suliman
Posts: 379
Joined: Sat Sep 23, 2006 2:06 pm

Re: Lightning - no falloff?

Post by suliman »

How do i set attenuation "using the light's interface"?
And why would scaling the scene work? Cant i just increase the far plane?

Thanks for your help guys
E
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Lightning - no falloff?

Post by mongoose7 »

Look in SLight.h.

Yes, move the far plane.
Post Reply