Light brightness inverted in game

Rak'kar

25-01-2007 22:10:29

The shading / brightness of the light is dark where it should be light, and light where it should be dark, in game.

I exported using all default settings, using the provided loader. This is with the latest version.

Max Setup (light towards top of cone):


Max Ogre Rendering (OK):


Game Rendering (BAD: light towards bottom of cone):

Rak'kar

25-01-2007 22:12:31

Here is the scene:


<oe_scene>
<sceneManager type="1" />
<bkgcolor r="0.486275" g="0.964706" b="0.588235" />
<lightColor r="0.494118" g="0.572549" b="0.909804" />
<shadowTechnique type="0" tex_size="512" tex_count="1">
<color r="0" g="0" b="0" />
</shadowTechnique>
<entities>
<entity name="Cone01" hidden="false" filename="Cone01.mesh" CastShadows="yes" ReceiveShadows="yes">
<position x="-6.51245" y="0" z="-40.5856" />
<rotation x="0" y="0" z="-0" w="-1" />
<scale x="1" y="1" z="1" />
</entity>
</entities>
<lights>
<light name="Direct01" type="directional" on="true" CastShadows="no" hotspot="43" falloff="45" intensity="1">
<position x="-41.2676" y="105.93" z="4.63035e-006" />
<rotation x="-0.247098" y="0.383527" z="-0.107281" w="-0.883368" />
<scale x="1" y="1" z="1" />
<color r="1" g="1" b="1" />
<specular r="1" g="1" b="1" />
<target name="Direct01.Target">
<position x="11.1516" y="-12.2822" z="-48.9886" />
<rotation x="-0.707107" y="0" z="-0" w="-0.707107" />
<scale x="1" y="1" z="1" />
</target>
</light>
</lights>
<cameras>
<camera name="Camera01" FOV="0.785398">
<position x="-69.2309" y="126.496" z="5.5293e-006" />
<rotation x="-0.237941" y="0.473999" z="-0.144905" w="-0.835291" />
<scale x="1" y="1" z="1" />
<target name="Camera01.Target">
<position x="0.299532" y="0.892716" z="-38.6769" />
<rotation x="-0.707107" y="0" z="-0" w="-0.707107" />
<scale x="1" y="1" z="1" />
</target>
</camera>
</cameras>
</oe_scene>

Lioric

26-01-2007 01:15:11

What Ogre Engine are you using in your application?

What are the displayed results if you load this scene in the oScene Loader Demo?

Are you using the event/post-process system or doing any scene modification after the scene is loaded?

Rak'kar

26-01-2007 02:02:59

What Ogre Engine are you using in your application?

The one immediately before the current one, which is 1.2.5. I'm testing 1.2.5 now.

What are the displayed results if you load this scene in the oScene Loader Demo?

I didn't try it directly, but I copied what you provided in the demo to my own app, using my own framework.

Are you using the event/post-process system or doing any scene modification after the scene is loaded?

I'm using essentially the same code as your demo. See below:

// Callback handler to post-process created objects
class oSceneCallback : public OSMSceneCallbacks {
public:

// We override the OnCreate method for cameras (See IXMLSceneCallbacks class)
void OnCameraCreate(Ogre::Camera* pCamera, TiXmlElement* pCameraDesc) {

// If a camera of name "FirstCamera" is loaded, it will be set as the default current
if(pCamera->getName() == "FirstCamera")
Ogre::Root::getSingleton().getAutoCreatedWindow()->getViewport(0)->setCamera(pCamera);
}

};

class OFusionApp : public App3D, public InputEventListener
{
public:
OFusionApp()
{
quit=false;
}

~OFusionApp()
{

}

void OnAppShutdown( void )
{
App3D::OnAppShutdown();
}

void Render(AppTime curTimeMS)
{
App3D::Render(curTimeMS);
}

bool ShouldQuit(void) const {return quit || window->isClosed();}

void Update(AppTime curTimeMS, AppTime elapsedTimeMS)
{
#ifndef WIN32
Ogre::PlatformManager::getSingleton().messagePump (window);
#endif

// Update all subsystems
App3D::Update(curTimeMS, elapsedTimeMS);

// You can read the keyboard state through polling rather than events if you wish. It is equally efficient.
// I could have put this in OnKeyPress too - it's just here for illustration
if (inputManager->keyboardState.JustPressed(OIS::KC_ESCAPE))
quit=true;

Ogre::Quaternion rotation(Ogre::Radian((float)elapsedTimeMS/1000.0f), Ogre::Vector3::UNIT_Z);
Ogre::Matrix4 rotationMat(rotation);
// oFusion attaches the camera to a scene node, and does not set the position directly
// camera->getParentNode()->setPosition(rotationMat * camera->getParentNode()->getPosition());
}

// This is a poorly named virtual function from ExampleApplication. Just put startup code here
void PostConfigure(const char *defaultResourceConfigurationPath)
{
App3D::PostConfigure(defaultResourceConfigurationPath, false);

// Pass input events to this class. This is optional and is something I wrote. If you don't want to do that, just
// write your own. You can poll using ceGuiManager->keyboardState and guiManager.mouseState
inputManager->SetInputEventListener(this);

// Here is the code that will load the scene file
// A fixed filename "scene.osm" is implemented for this demo

// Create the scene loader
OSMScene oScene;

// Create an oE_Loader Callback object to post-process created objects
oSceneCallback oe_Callback;

// Initializes with the scene to be loaded and the callback if required
oScene.initialise("oFusionTest.osm", &oe_Callback);

// create and setup the scene in the root node
oScene.createScene();

// Use the scene manager from oFusion
sceneManager = oScene.getSceneManager();

// Get the list of cameras loaded with the scene
OSMScene::CameraList camList = oScene.getCameraList();

if(!camList.empty()) {

// If loaded with the scene, set the first camera as the default camera
camera = camList[0];

// A viewport has been created and assigned to the first camera automatically
// (The TSM needs it to initialize the terrain world geometry)
}
else {

// Create a default camera in case no cameras were saved in the scene

camera = sceneManager->createCamera("PlayerCam");
// Position it at 500 in Z direction
camera->setPosition(Ogre::Vector3(0,0,500));
// Look back along -Z
camera->lookAt(Ogre::Vector3(0,0,-300));
camera->setNearClipDistance(5);

// If a viewport was not automatically created, (no cameras saved in the scene)
// create a default viewport, entire window
// Viewport* vp = window->addViewport(camera);
// vp->setBackgroundColour(ColourValue(0,0,0));

// Alter the camera aspect ratio to match the viewport
// camera->setAspectRatio(
// Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}

App3D::InitSceneManager(sceneManager);
App3D::InitCamera(camera);
App3D::InitViewport(camera->getViewport());
}

protected:
virtual char * GetWindowTitle(void) const {return "oFusionApp";}
bool quit;
};


This is my framework code. In the case of this demo, I just use the scene manager you return to me.


void App3D::InitSceneManager(Ogre::SceneManager *sm)
{
if (sm)
sceneManager=sm;
else
sceneManager = root->createSceneManager(Ogre::ST_GENERIC, defaultSceneManagerName);

FXManager::StartUp(sceneManager);
ceGuiManager->Startup(window, sceneManager);
}
void App3D::InitCamera(Ogre::Camera *cam)
{
RakAssert(sceneManager);

if (cam)
camera=cam;
else
camera = sceneManager->createCamera(defaultCameraName);

}
void App3D::InitViewport(Ogre::Viewport *vp)
{
// Create one viewport, entire window
if (vp==0)
{
if (viewport==0)
{
viewport = window->addViewport(camera);
viewport->setBackgroundColour(Ogre::ColourValue(0,0,0));
}
}
else
viewport=vp;

// Alter the camera aspect ratio to match the viewport
camera->setAspectRatio(
(float)viewport->getActualWidth() / (float)viewport->getActualHeight());

CEGUI::URect rect;
rect.d_min.d_x.d_scale=0.0f;
rect.d_min.d_x.d_offset=0.0f;
rect.d_min.d_y.d_scale=0.0f;
rect.d_min.d_y.d_offset=0.0f;
rect.d_max.d_x.d_scale=0.0f;
rect.d_max.d_x.d_offset=viewport->getActualWidth();
rect.d_max.d_y.d_scale=0.0f;
rect.d_max.d_y.d_offset=viewport->getActualHeight();
debugText->Setup(true, rect);
}

Chris Thornton

26-01-2007 02:26:12

I've been having the same problems, It only seems to happen when you use a target direct light, it appears that the target and light swap positions. If you make your light into a free direct it should go away, but it would be nice for a fix.

Rak'kar

26-01-2007 02:37:22

All lights point +z by default. I added this:


const char *pszName = pLightElem->Attribute("name");

Light *pLight = mSceneMgr->createLight(pszName);
if(pLight==0) continue;

pLight->setDirection(Vector3::NEGATIVE_UNIT_Z);


To fix the problem.