Page 1 of 2

light problem

Posted: Fri Feb 23, 2007 6:37 pm
by omar shaaban
i have a light problem simply when i add light i found on my mesh a grey shaded even if i made the light far or near it just gets brighter but there is a small grey shaded exists but when i make lightning false for my mesh it goes!?
thanks.

Code: Select all

ISceneNode * light = smgr->addLightSceneNode(0, core::vector3df(0.f,400.f,0.f),
		video::SColorf(1.f, 1.f, 1.f,0.f), 600.f);

Posted: Sat Feb 24, 2007 7:32 am
by datamagik
What color is the object you're illuminating? Do you have a screenshot you can link to to help us visualize what you're getting? :)

Posted: Sat Feb 24, 2007 1:01 pm
by omar shaaban

Posted: Sat Feb 24, 2007 2:18 pm
by Virion
a black scene?

Posted: Sat Feb 24, 2007 3:04 pm
by omar shaaban
Virion wrote:a black scene?
NO,DID u see the picture

Posted: Sat Feb 24, 2007 7:19 pm
by datamagik
Ok I saw the picture so now I can see what you mean by "grey". You are referring to the lighter color when the object is set to "lighted".

Looking in the engine source the flag EMF_LIGHTING is defined in the header SMaterial.h as a flag used when dynamic lighting is present. What is your light source?

Without knowing more about what your code is doing I'd look at the value you have set for material shininess. See this excerpt from SMaterial.h

Code: Select all

		//! Value affecting the size of specular highlights. A value of 20 is common.

		/** If set to 0, no specular highlights are being used.

		To activate, simply set the shininess of a material to a value other than 0:

		Using scene nodes:

		\code

		sceneNode->getMaterial(0).Shininess = 20.0f;

		\endcode



		You can also change the color of the highlights using

		\code

		sceneNode->getMaterial(0).SpecularColor.set(255,255,255,255);

		\endcode



		The specular color of the dynamic lights (SLight::SpecularColor) will influence

		the the highlight color too, but they are set to a useful value by default when

		creating the light scene node. Here is a simple example on how

		to use specular highlights:

		\code

		// load and display mesh

		scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(

		smgr->getMesh("data/faerie.md2"));

		node->setMaterialTexture(0, driver->getTexture("data/Faerie2.pcx")); // set diffuse texture

		node->setMaterialFlag(video::EMF_LIGHTING, true); // enable dynamic lighting

		node->getMaterial(0).Shininess = 20.0f; // set size of specular highlights



		// add white light

		scene::ILightSceneNode* light = smgr->addLightSceneNode(0,

		    core::vector3df(5,5,5), video::SColorf(1.0f, 1.0f, 1.0f));

		\endcode */

Posted: Sun Feb 25, 2007 4:21 am
by omar shaaban
:) oh thanks it worked when i wrote

Code: Select all

	e[j]->getMaterial(0).Shininess = 0.0f;
but i have 2 questions
1-i saw in all irrlicht tutorials that he doesn't define the material shininess?
2-it worked even when i assigned the material shininess to 0?
and i really thank u datamagik!

Posted: Sun Feb 25, 2007 4:33 am
by datamagik
As for the default value of material shininess I'd have to search the engine code. Obviously non-zero since that changed the behavior you observed.

Shininess is the quality of reflecting light. Look at a real life black object that's shiny (maybe a black car). Try to look at it objectively and imaging different parts of the surface as if they were rendered to pixels. Many of that object's pixels will not be black, some will be grey (or if it's real world lighting source is a bright stream of sunlight) or even white.

From you pictures it looked like that was what the engine was rendering, that or it was depicting your object as emitting light. Again, guessing here.

Glad you fixed your problem! :)

Posted: Sun Feb 25, 2007 4:46 am
by omar shaaban
well as in the picture i have just added a light scene node ("but i didnt know i have to set shiness")!

Posted: Mon Feb 26, 2007 7:43 pm
by omar shaaban
my question is why i must have to adjust shinnies to 0 i saw in irrlicht tutorials they didn't!? any help plz. :(

Posted: Mon Feb 26, 2007 8:24 pm
by bitplane
materials are set by the mesh loader, which format are you using and what program did you export it from?
it could be a bug in your exporter, the loader, or it could be you're using it wrong. if it is a bug, posting your mesh will help

Posted: Wed Feb 28, 2007 7:41 pm
by omar shaaban
well i am using 3d studio max7 and i exported in with different meshes in different formats(.x and .3ds) but still have to assign shininess.

Posted: Fri Mar 02, 2007 7:19 pm
by omar shaaban
Any help?

Posted: Fri Mar 02, 2007 7:24 pm
by Spintz
Any model?

Posted: Fri Mar 09, 2007 7:17 am
by jingquan
datamagik wrote:Ok I saw the picture so now I can see what you mean by "grey". You are referring to the lighter color when the object is set to "lighted".

Looking in the engine source the flag EMF_LIGHTING is defined in the header SMaterial.h as a flag used when dynamic lighting is present. What is your light source?

Without knowing more about what your code is doing I'd look at the value you have set for material shininess. See this excerpt from SMaterial.h

Code: Select all

		//! Value affecting the size of specular highlights. A value of 20 is common.

		/** If set to 0, no specular highlights are being used.

		To activate, simply set the shininess of a material to a value other than 0:

		Using scene nodes:

		\code

		sceneNode->getMaterial(0).Shininess = 20.0f;

		\endcode



		You can also change the color of the highlights using

		\code

		sceneNode->getMaterial(0).SpecularColor.set(255,255,255,255);

		\endcode



		The specular color of the dynamic lights (SLight::SpecularColor) will influence

		the the highlight color too, but they are set to a useful value by default when

		creating the light scene node. Here is a simple example on how

		to use specular highlights:

		\code

		// load and display mesh

		scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(

		smgr->getMesh("data/faerie.md2"));

		node->setMaterialTexture(0, driver->getTexture("data/Faerie2.pcx")); // set diffuse texture

		node->setMaterialFlag(video::EMF_LIGHTING, true); // enable dynamic lighting

		node->getMaterial(0).Shininess = 20.0f; // set size of specular highlights



		// add white light

		scene::ILightSceneNode* light = smgr->addLightSceneNode(0,

		    core::vector3df(5,5,5), video::SColorf(1.0f, 1.0f, 1.0f));

		\endcode */
I tried this in .NET

Code: Select all

mapnode.GetMaterial(0).Shininess = 0
but it's isn't working.

I got a expression is a value and therefore cannot be the target of an assignment.

Any help?