Basic outdoor lighting

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

Basic outdoor lighting

Post by suliman »

Hi
Im doing a aircraft game. So far i have no lighting at all which of course looks like crap:

http://postimg.org/image/7z95e1vv3/

So what could be a good and simple solution for me? Im new to this, but i would like something like a global "sun" light that hopefully gives a little more life to the objects. The units can move around obviously so how would this work with shadows etc?

Completely unlit everything looks pretty bad. The alternative is to tone down the lightness of all textures but im hoping i can manage something a little more sophisticated:)

Thanks for your help
Erik
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: Basic outdoor lighting

Post by REDDemon »

well the most simple solution is to use as sun a directional yellow light and as ambient color a light blue (atmosphere color).. You could improve a lot by replacing the ambient light with a lightened version of the skybox but that requires some shader knowledge. it is worth learning shaders by the way. Remember also to use brighter textures if they look bad or dark after light application (use a white cube as reference, so you know how bright will be the brightest color)
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
suliman
Posts: 379
Joined: Sat Sep 23, 2006 2:06 pm

Re: Basic outdoor lighting

Post by suliman »

1. I do this for the sun:

Code: Select all

ISceneNode * light= gfx.smgr->addLightSceneNode(0, vect3d(2100,500,1900),SColor(100,180,180,255),8000000.0f);
But changing the color changes nothing. The lit side of the nodes are just white. How do i control intensity? And about radius (i just set it very high now as seen above). Is the source still just a point and radius just how far the light is projected? (this is what it seems like to me)

2. I set up each node as this:

Code: Select all

    o->node->setMaterialFlag(video::EMF_LIGHTING,true);
    o->node->setMaterialFlag(EMF_FOG_ENABLE, true); 
    int matCount=o->node->getMaterialCount();
    for(int i=0;i<matCount;i++)
        o->node->getMaterial(i).AmbientColor.set(255,255,0,0); 
But the unlit side (away from the sun) is still just black. Any idea?

Thanks a lot!
Erik
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Basic outdoor lighting

Post by hendu »

Did not set the scene's ambient light value perhaps? smgr->setAmbientLight
suliman
Posts: 379
Joined: Sat Sep 23, 2006 2:06 pm

Re: Basic outdoor lighting

Post by suliman »

Cool now i get some effect!
But the ambientcolor of the nodes, doesnt it matter? Or is it blended with the color from the "global" scene ambient color?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Basic outdoor lighting

Post by hendu »

It's multiplied with the ambient light.
suliman
Posts: 379
Joined: Sat Sep 23, 2006 2:06 pm

Re: Basic outdoor lighting

Post by suliman »

Cool.
Is it correct that SColor is ARGB but SColorf is RGBA?
So the order is different? Isnt this a bit confusing?

Also, the "sun" intensity seems to be the same no matter what i set:

SColor(255,0,0,35)
and
SColor(255,0,0,255)

makes the nodes the exact blue color. And alpha seems to not matter either...
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Basic outdoor lighting

Post by hendu »

I agree the mixed color ordering is bad. Lighting colors all ignore alpha.

If you need more control than the fixed function pipeline gives, you need to write shaders.
suliman
Posts: 379
Joined: Sat Sep 23, 2006 2:06 pm

Re: Basic outdoor lighting

Post by suliman »

Ok i understand shaders offers more flexibility but light intensity doesnt exist at all in the base engine? Seems strange. So only light or no light? (no way to scale HOW much light there is?)

When i set the ambient light
smgr->setAmbientLight(SColorf(0.3,0.3,0.3,1));

there is a different if i use smaller or bigger numbers (if i keep them balanced such as above its still neutral/white light but i can scale the intensity of the ambient light).
But this doesnt seem to apply to the ligth node (sun) that i place. Should it be like this? Ambient has intensity but light sources has not? I dont want full light (extremely light) for all objects.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Basic outdoor lighting

Post by hendu »

No, the fixed function pipeline has a specific light intensity curve based on distance.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Basic outdoor lighting

Post by Mel »

Keep in mind also that to get the correct lighting you need to normalize the normals (if they aren't already ;))

To get a good outdoors lighting i would create a directional light, but the directional lights have also a falloff, which comes from the center of the light (its position) and fades with the distance, so you could also attach a directional light to your camera so the visible objects are always lit, and rotate the light to get the proper direction.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Post Reply