Directional light problem

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
Grz-
Posts: 62
Joined: Wed Dec 26, 2007 1:06 pm

Directional light problem

Post by Grz- »

Hello,

i added a directional light to 'simulate' the sun but it look like the lighting on my planet orbiting the sun come from a totally different position:

Image

Image

As you see in the last screenshot it seem it don't come from the sun in the background but from another light source (there is only one light tho).

Here is a better shot:

Image

The light is added like that:

Code: Select all

                sun = smgr->addLightSceneNode(0, core::vector3df(0.0f,0.0f,0.0f),
                                                        video::SColor(0,200, 200, 200), 5000.0f);
                sun->setLightType(video::ELT_DIRECTIONAL);
                sun->enableCastShadow(true);
I create a sphere mesh using this code:

Code: Select all

                planetMesh = smgr->addSphereMesh("Sphere", 1.0f, 64, 64);
                planetMesh->setHardwareMappingHint(scene::EHM_STATIC);
Then add it using:

Code: Select all

planet = smgr->addAnimatedMeshSceneNode(planetMesh, orbitNode, -1, core::vector3df(0, 0, 0),
                                                                core::vector3df(0, 0, 0), core::vector3df(2000, 2000, 2000);

                    for(unsigned int i=0;i<planet->getMaterialCount();i++)
                    {
                        video::SMaterial &matPlanet = planet->getMaterial(i);
                        matPlanet.AmbientColor  = video::SColor(255,255,255,255);
                        matPlanet.DiffuseColor  = video::SColor(255,0,0,0);
                        matPlanet.EmissiveColor = video::SColor(255,1,1,1);
                        matPlanet.SpecularColor = video::SColor(128,66,66,66);
                        matPlanet.MaterialTypeParam = 0.0035f;
                        matPlanet.Shininess = 14.0f;
                        matPlanet.Lighting = true;
                        matPlanet.NormalizeNormals = true;
                    }
Also tried point light with a big radius and the sphere lighting doesnt appear.
macron12388
Posts: 126
Joined: Wed Sep 29, 2010 8:23 pm

Post by macron12388 »

Why would you use a directional light for that? The way the planets are being lighted makes sense for a directional light. Since the Sun is a sphere, emanating light from a point in the center of a sphere, not in only one direction. I think it would make more sense to use a point light.

EDIT: Oh, sorry I didn't read the last bit about you already trying a point light. What arguments do you pass when creating the point light lightscenenode?
Grz-
Posts: 62
Joined: Wed Dec 26, 2007 1:06 pm

Post by Grz- »

Same as here except with a much larger radius (and change to point light type of course).
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Where do you think that you set the directional light's direction? Moreover, having the sun in the scene does not make sense if you want to go for a directional light. At least not if all those objects are on the same level. Directional light means that the light emitter is infinitely far away.
Anyway, set the rotation of the light node as you need. This will turn the directional light's direction.
Grz-
Posts: 62
Joined: Wed Dec 26, 2007 1:06 pm

Post by Grz- »

I knew about the directional vs spot light thing, i used it there because someone mentionned in the forum that it can lead to better performances comparated to other types of lights, what i wanted to do is to switch between spot and directional depending of the scene setup.

Thank, i will try to set the light node rotation anyway, i thought there was a setDirection/target method but thinking at it setRotation make sens... :oops:
Post Reply