I was working with 0.14.X till now and didn't have a prolem, recently I upgraded to 0.15 and everything went well. However since then my lights refuse to illuminate the scene. I've tried everything I could to see where the trouble lies, but without anything going wrong it's hard to pin-point. By that I mean, technically the lights get created fine, they get placed perfectly, and if I attach them to the camera, they even move around with me. However I see no "light" in my scene. Not even the AmbientLight. All I see are dark "meshes" which block the sky-box image if I look from behind them. So I know the meshes are being created too. And with the recent physics addition I can even "collide" with the meshes. So I know that they're there. Thus the only thing that are at fault here are the lights. This lead me to believe that maybe my Ogre Code was corrupted. But upon running the "lights" demo/sample I was proven wrong -- as the lighs there work perfectly.
I mean when I upgraded I didn't even change anything, except for the whole deal with Radian, Degrees and AttachLight (which I had to change to AttachObject(LightPtr);).
Anyone encounter anything like this? or know what it could be?
Please help me out. I've tried doing various thing to see if at the very least I can get even a spec of light somehow in the scene.. but alas.. all efforts died in vain.
Lights and DotScene
-
Xinc
- Halfling
- Posts: 52
- Joined: Sat May 08, 2004 12:55 pm
- Location: Toronto, Canada
Lights and DotScene
- Xinc
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
Did you upgrade your meshes at the same time? If so, did you reorganise their vertex buffers using the automatic option? You don't necessarily have to upgrade your meshes (although I highly recommend it), but maybe if you did but reorganised the buffers incorrectly you might have lost the normal data.
Otherwise, the only other change to lighting was to include lights where they would have been culled early before (finding visible lights now includes the bounding sphere of the object as well as the light radius). However, the fact that ambient light is not showing up suggests that it's not that.
Have you tried other materials? Perhaps your material is at fault (there were some changes to transparent material handling in 0.15 which mean that incorrect materials that used to render ok may not do so anymore)
Otherwise, the only other change to lighting was to include lights where they would have been culled early before (finding visible lights now includes the bounding sphere of the object as well as the light radius). However, the fact that ambient light is not showing up suggests that it's not that.
Have you tried other materials? Perhaps your material is at fault (there were some changes to transparent material handling in 0.15 which mean that incorrect materials that used to render ok may not do so anymore)
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
-
bisco
- OGRE Contributor

- Posts: 235
- Joined: Wed Nov 03, 2004 5:01 pm
- Location: London, United Kingdom
Hi Xinc, I had exactly the same problem (except that my ambient light was working) and just got it solved.
As sinbad suggested there is an error in how the lights are searched. In the SceneOctreeRenderable class you have to correct the getLights function so that the lights are searched using the bounding radius. This means you have to calculate the bounding radius too and use it into the function when you look for lights. I'll post here my code
First I added mBoundingRadius to SceneOctreeRenderable members:
then added a part to setupBoundingBox in the same class, where I calculate the bounding radius:
Then finally changed the getLights function in the same class:
And make sure that if you're exporting vertex diffuse colours they're not black.
Hope it works for you too
As sinbad suggested there is an error in how the lights are searched. In the SceneOctreeRenderable class you have to correct the getLights function so that the lights are searched using the bounding radius. This means you have to calculate the bounding radius too and use it into the function when you look for lights. I'll post here my code
First I added mBoundingRadius to SceneOctreeRenderable members:
Code: Select all
protected:
void SetupBoundingBox( unsigned int *IndexArray );
AxisAlignedBox mBounds;
Vector3 mCenter;
Vector3 mScale;
Real mBoundingRadius;
int mSize;
int mWorldSize;
String mName;
String mType;
int MaterialIndex;
Material *mMaterial;
bool mInit;Code: Select all
void SceneOctreeRenderable::SetupBoundingBox( unsigned int *IndexArray )
{
// Bounding Box Vars
int Min[3], Max[3];
Min[0]=Min[1]=Min[2] = 1000000 ;
Max[0]=Max[1]=Max[2] = -1000000 ;
// Grab a pointer to the vertex shadow buffer
VertexDeclaration* decl = mVertData->vertexDeclaration;
VertexBufferBinding* bind = mVertData->vertexBufferBinding;
HardwareVertexBufferSharedPtr vbuf;
vbuf = bind->getBuffer(POSITION_BINDING);
Real* pPos = static_cast<Real*>(vbuf->lock(HardwareBuffer::HBL_READ_ONLY));
for( int index=0; index<numIndices; index++ )
{
for( int CurAxis=0; CurAxis<3; CurAxis++ )
{
// Update the Bounding Box //
if( pPos[ (IndexArray[ index ]*3)+CurAxis ] < Min[CurAxis] )
Min[CurAxis] = pPos[ (IndexArray[ index ]*3)+CurAxis ];
if( pPos[ (IndexArray[ index ]*3)+CurAxis ] > Max[CurAxis] )
Max[CurAxis] = pPos[ (IndexArray[ index ]*3)+CurAxis ];
}
}
vbuf->unlock();
// Set the bounding box //
mBounds.setExtents( Min[0] , Min[1] , Min[2] , Max[0] , Max[1] , Max[2] );
mCenter = Vector3( (Max[0]+Min[0])/2 , (Max[1]+Min[1])/2 , (Max[2]+Min[2])/2 );
Real tempX,tempY,tempZ;
// max (xMax,|xMin|)
if (abs(Min[0]) > abs(Max[0]))
tempX = abs(Min[0]);
else
tempX = abs(Max[0]);
// max (yMax,|yMin|)
if (abs(Min[1]) > abs(Max[1]))
tempY = abs(Min[1]);
else
tempY = abs(Max[1]);
// max (zMax,|zMin|)
if (abs(Min[2]) > abs(Max[2]))
tempZ = abs(Min[2]);
else
tempZ = abs(Max[2]);
// sqrt[ max(xMax,|xMin|)^2 + max(yMax,|yMin|)^2 + max(zMax,|zMin|)^2 ]
mBoundingRadius = sqrt(tempX*tempX + tempY*tempY + tempZ*tempZ);
mInit = true;
}
Code: Select all
const LightList& SceneOctreeRenderable::getLights(void) const
{
if ((SceneNode*)mParentNode)
return ((SceneNode*)mParentNode)->findLights(this->getBoundingRadius());
else
return mParentNode->getLights();
}
Hope it works for you too
-
ashleyder
- Gnoblar
- Posts: 2
- Joined: Wed Nov 10, 2004 9:06 am
Xinc, have you perchance found a fix to the problem because I'm having the same problem (including no ambient light). I tried your fix bisco, but that didn't help at all. Nor did upgrading the mesh help.
Part of the problem seems to be that the dotscene loader does not load any dynamic nodes currently, and this means no lights are loaded from the .scene file. I coded support for this, but the .scene geometry still is unlit.
Ps. I should also mention that fog *does* light the .scene geometry.
Part of the problem seems to be that the dotscene loader does not load any dynamic nodes currently, and this means no lights are loaded from the .scene file. I coded support for this, but the .scene geometry still is unlit.
Ps. I should also mention that fog *does* light the .scene geometry.
-
Xinc
- Halfling
- Posts: 52
- Joined: Sat May 08, 2004 12:55 pm
- Location: Toronto, Canada
Thanks bisco, but some how my lights started working automatically after I did a little house-cleaning in the code.
@ashleyder: This problem was pretty random, but this is how I experimented it out.
First of all, I made sure that the .scene contained proper light colours and position.
e.g.
Then once you make sure your lights have those values, move in on the code.
In ParseDotScene function, go to the point where the light nodes are parsed from XML.
Mine Looks like this right now:
*TempVec is from a little up, where the position of the node is determined.
Now in LoadLight, this is what it looks like:
This is how the it started to work. I didn't make a log of this problem do I'm not aware of how exactly I solved it, so there might be a few things I forgot about to include in this post.
@ashleyder: This problem was pretty random, but this is how I experimented it out.
First of all, I made sure that the .scene contained proper light colours and position.
e.g.
Code: Select all
<node name="Omni01" id="195">
<position x="45.7218" y="18.064" z="169.824" />
<light name="Omni01" id="195" type="point" visible="1" shadow="1">
<colour_diffuse r="0.5100" g="0.2100" b="0.100" />
</light>
</node>
<node name="Omni02" id="199">
<position x="-1.56545e-005" y="391.741" z="358.133" />
<light name="Omni02" id="199" type="point" visible="1" shadow="1">
<colour_diffuse r="0.100" g="0.100" b="0.100" />
</light>
</node>
</nodes>
In ParseDotScene function, go to the point where the light nodes are parsed from XML.
Mine Looks like this right now:
Code: Select all
XMLLight = XMLNode->FirstChildElement( "light" );
if( XMLLight ){
Ogre::Light *lightRef = LoadLight( XMLLight, mSceneMgr );
lightRef->setPosition(TempVec);
if (atoi(XMLLight->Attribute("visible")) == 1)
lightRef->setVisible(true);
else
lightRef->setVisible(false);
NewNode->attachObject( lightRef );
}
Now in LoadLight, this is what it looks like:
Code: Select all
Light* CLevelLoader::LoadLight( TiXmlElement *XMLLight, Ogre::DotSceneManager *mSceneMgr )
{
Light* l = mSceneMgr->createLight(XMLLight->Attribute("name"));
l->setType(GetLightType(XMLLight->Attribute("type")));
ColourValue Diffuse, Specular;
TiXmlElement *XMLDiffuse, *XMLSpecular;
XMLDiffuse = XMLLight->FirstChildElement("colour_diffuse");
if( XMLDiffuse ){
Diffuse.r = Ogre::StringConverter::parseReal( XMLDiffuse->Attribute("r") );
Diffuse.g = Ogre::StringConverter::parseReal( XMLDiffuse->Attribute("g") );
Diffuse.b = Ogre::StringConverter::parseReal( XMLDiffuse->Attribute("b") );
Diffuse.a = 1;
}
XMLSpecular = XMLLight->FirstChildElement("colour_specular");
if( XMLSpecular ){
Specular.r = Ogre::StringConverter::parseReal( XMLSpecular->Attribute("r") );
Specular.g = Ogre::StringConverter::parseReal( XMLSpecular->Attribute("g") );
Specular.b = Ogre::StringConverter::parseReal( XMLSpecular->Attribute("b") );
Specular.a = 1;
}
if (atoi(XMLLight->Attribute("shadow")) == 1)
l->setCastShadows(true);
else
l->setCastShadows(false);
XMLAtten = XMLLight->FirstChildElement("Attenuation");
l->setDiffuseColour(Diffuse);
l->setSpecularColour(Specular);
// For Test purposes
l->setAttenuation(
8000,
1,
0.0005,
0
);
return l;
}
This is how the it started to work. I didn't make a log of this problem do I'm not aware of how exactly I solved it, so there might be a few things I forgot about to include in this post.
- Xinc
-
ashleyder
- Gnoblar
- Posts: 2
- Joined: Wed Nov 10, 2004 9:06 am
Thanks for the code, but unfortunately that's actually pretty much the same thing I did except that I added it to DotScene Plugin's SceneMain class. However even though the lights get loaded successfully, they're still not lighting the static geometry. Do you have any other thoughts as to what you might have changed?
-
Tommy
- Gnoblar
- Posts: 15
- Joined: Sun Jan 23, 2005 5:48 pm
- Location: Germany
Hi,ashleyder wrote:Thanks for the code, but unfortunately that's actually pretty much the same thing I did except that I added it to DotScene Plugin's SceneMain class. However even though the lights get loaded successfully, they're still not lighting the static geometry. Do you have any other thoughts as to what you might have changed?
first of all I want to thank all of you for your great work on Ogre! I'm part of a team that's developing a 3D adventure that plays in city and for that the DotSceneManager suits perfectly. However, I also have the problem that my static geometry doesn't get lit. I'm using Ogre 0.15.2 and the MilkshapeExporter as well as the SceneConverterSample to create the octree data. For debugging reasons I added a light and a human model by code:
Code: Select all
Light *pl = mDotSceneMgr->createLight("pointlight1");
pl->setType(Light::LT_POINT);
pl->setPosition(10.0, 6.0, 10.0);
Entity* ePlayer = mDotSceneMgr->createEntity("player", "Modelle/mann.mesh");
mPlayer = mDotSceneMgr->getRootSceneNode()->createChildSceneNode();
mPlayer->attachObject(ePlayer);
[img]deleted[/img]
I have absolutely no idea what goes wrong here, so if anyone of you has an idea I would be very glad if he could help me.
-
Tommy
- Gnoblar
- Posts: 15
- Joined: Sun Jan 23, 2005 5:48 pm
- Location: Germany
Edit: Thanks sinbad!
Last edited by Tommy on Mon Jan 24, 2005 5:43 pm, edited 2 times in total.
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67