[Solved] [2.1] Multiple point lights problem Topic is solved

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
User avatar
Dark_Mark
Gnoblar
Posts: 15
Joined: Mon Jun 13, 2016 3:51 pm
Location: Poland, Europe
x 1

[Solved] [2.1] Multiple point lights problem

Post by Dark_Mark »

Hi. I made a copy of the Sample_ShadowMapDebugging project to learn OGRE 2.1 by example. So far I only made some very minor changes to it, like replacing existing cubes with a different mesh and removing debug overlay elements. However, some strange problem occurs ever since I changed the type of all lights to LT_POINT, like this:

Code: Select all

Ogre::Light *light = sceneManager->createLight();
Ogre::SceneNode *lightNode = rootNode->createChildSceneNode();
lightNode->attachObject( light );
light->setPowerScale(Ogre::Math::PI);
light->setType( Ogre::Light::LT_POINT );
light->setAttenuationBasedOnRadius(10.0f, 0.01f);
mLightNodes[0] = lightNode;

light = sceneManager->createLight();
lightNode = rootNode->createChildSceneNode();
lightNode->attachObject( light );
light->setDiffuseColour( 0.8f, 0.4f, 0.2f ); //Warm
light->setSpecularColour( 0.8f, 0.4f, 0.2f );
light->setPowerScale( Ogre::Math::PI );
light->setType( Ogre::Light::LT_POINT);
lightNode->setPosition( -10.0f, 10.0f, 10.0f );
light->setAttenuationBasedOnRadius( 10.0f, 0.01f );
mLightNodes[1] = lightNode;

light = sceneManager->createLight();
lightNode = rootNode->createChildSceneNode();
lightNode->attachObject( light );
light->setDiffuseColour( 0.2f, 0.4f, 0.8f ); //Cold
light->setSpecularColour( 0.2f, 0.4f, 0.8f );
light->setPowerScale( Ogre::Math::PI );
light->setType( Ogre::Light::LT_POINT);
lightNode->setPosition( 10.0f, 10.0f, -10.0f );
light->setAttenuationBasedOnRadius( 10.0f, 0.01f );
mLightNodes[2] = lightNode;
For some reason, the scene cannot be lit by more than two point lights at once. The first light (white) is always active, but the other two exclude each other: either the orange one works or the blue one works, depending on whichever is closer to the camera:
Image Image

Question is, how can I make OGRE display more than two point lights at once? Do I have to do something with compositor, turn on Forward3D or is it some kind of bug? Also, I don't really need multiple shadows, just one would be perfect.
Last edited by Dark_Mark on Tue May 01, 2018 10:15 pm, edited 1 time in total.
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: [2.1] Multiple point lights problem

Post by xrgo »

Dark_Mark wrote: Mon Apr 30, 2018 10:50 pm turn on Forward3D
that's it!.. non shadowcasting lights goes through forward+ (3D/Clustered) to be rendered, and since you might have just one shadow map for pointlight in your compositor ogre switches to the closest one (I think) to use the shadow map, and thats the one being rendered. enable forward+ and you will see both lights but the shadow will continue toggling unless you add another shadow map in the compositor shadow node
User avatar
Dark_Mark
Gnoblar
Posts: 15
Joined: Mon Jun 13, 2016 3:51 pm
Location: Poland, Europe
x 1

Re: [2.1] Multiple point lights problem

Post by Dark_Mark »

Well wasn't that easy after all. I turned on Forward3D like this:

Code: Select all

sceneManager->setForward3D(true, 4, 4, 5, 96, 3, 400);
And then disabled shadow casting for all lights but one:

Code: Select all

Ogre::Light *light = sceneManager->createLight();
Ogre::SceneNode *lightNode = rootNode->createChildSceneNode();
lightNode->attachObject( light );
light->setPowerScale(Ogre::Math::PI);
light->setType( Ogre::Light::LT_POINT );
light->setAttenuationBasedOnRadius(10.0f, 0.01f);
light->setCastShadows(false);
mLightNodes[0] = lightNode;

light = sceneManager->createLight();
lightNode = rootNode->createChildSceneNode();
lightNode->attachObject( light );
light->setDiffuseColour( 0.8f, 0.4f, 0.2f ); //Warm
light->setSpecularColour( 0.8f, 0.4f, 0.2f );
light->setPowerScale( Ogre::Math::PI );
light->setType( Ogre::Light::LT_POINT);
lightNode->setPosition( -10.0f, 10.0f, 10.0f );
light->setAttenuationBasedOnRadius( 10.0f, 0.01f );
mLightNodes[1] = lightNode;

light = sceneManager->createLight();
lightNode = rootNode->createChildSceneNode();
lightNode->attachObject( light );
light->setDiffuseColour( 0.2f, 0.4f, 0.8f ); //Cold
light->setSpecularColour( 0.2f, 0.4f, 0.8f );
light->setPowerScale( Ogre::Math::PI );
light->setType( Ogre::Light::LT_POINT);
lightNode->setPosition( 10.0f, 10.0f, -10.0f );
light->setAttenuationBasedOnRadius( 10.0f, 0.01f );
light->setCastShadows(false);
mLightNodes[2] = lightNode;
And now the lights seem to be working fine:
Image

Thanks for the help! Are there any lighting limitations I should know about, such as maximum number of lights or performance issues with Forward3D?
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: [2.1] Multiple point lights problem

Post by al2950 »

FYI I would use setForwardClustered as it is faster. These algorithms are good all rounders and work on most setups. However there is a fairly fixed performance hit ( ie does not matter how many lights or scene complexity) per scene pass. This performance hit (which is a CPU hit) can be reduced by changing some of the settings of the forward* grid.
User avatar
Dark_Mark
Gnoblar
Posts: 15
Joined: Mon Jun 13, 2016 3:51 pm
Location: Poland, Europe
x 1

Re: [2.1] Multiple point lights problem

Post by Dark_Mark »

al2950 wrote: Tue May 01, 2018 10:40 amFYI I would use setForwardClustered as it is faster.
Thanks, I had no idea that this method existed.
Post Reply