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.
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

light problem

Post 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);
datamagik
Posts: 26
Joined: Wed Feb 14, 2007 11:25 pm
Location: Bar Harbor, Maine USA

Post 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? :)
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

Last edited by omar shaaban on Sat Feb 24, 2007 3:11 pm, edited 1 time in total.
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

a black scene?
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

Virion wrote:a black scene?
NO,DID u see the picture
datamagik
Posts: 26
Joined: Wed Feb 14, 2007 11:25 pm
Location: Bar Harbor, Maine USA

Post 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 */
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post 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!
datamagik
Posts: 26
Joined: Wed Feb 14, 2007 11:25 pm
Location: Bar Harbor, Maine USA

Post 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! :)
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post 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")!
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post 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. :(
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post 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
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post 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.
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

Any help?
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Any model?
Image
jingquan
Posts: 222
Joined: Sun Aug 20, 2006 4:10 am
Contact:

Post 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?
Post Reply