Hi, I've been playing with Normal mapped Shaders on a mesh terrain. I decided to try using Static geometry groups.
The static geometry loaded just fine, but on flying around the scene I realised that the normal map lighting, bump and shinyness was no longer adjusting dynamicly to the camera position and instead just looked baked in place.
Is this normal, meaning that Static geometry can not be used with shaders that have certain shader effect materials applied? In my instance the material looks very bright and the shiny specular parts are static when you fly around the scene.
Static geometry + Normal map shaders = Static lighting
-
Evak
- Orc Shaman
- Posts: 707
- Joined: Sun Apr 02, 2006 7:51 pm
- Location: Sacramento, CA
- x 1
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
It shouldn't do - however I just realised there is a bug here - StaticGeometry doesn't change the VES_TANGENT entries when you re-orient an object when you bake it into the static geometry. This would cause the normal mapping to be off. However it would not be static.
Depends on how your normal map shader has been written of course.
Depends on how your normal map shader has been written of course.
-
Evak
- Orc Shaman
- Posts: 707
- Joined: Sun Apr 02, 2006 7:51 pm
- Location: Sacramento, CA
- x 1
Hmm, I'm an artist so I'm not too good with the technical stuff behind this.
I can try and illustrate exactly whats happening in either a video comparrison or sample app that will let you load a couple of scenes, one with and one without static geometry. Would be nice to get to the bottom of the problem
I can try and illustrate exactly whats happening in either a video comparrison or sample app that will let you load a couple of scenes, one with and one without static geometry. Would be nice to get to the bottom of the problem
-
Evak
- Orc Shaman
- Posts: 707
- Joined: Sun Apr 02, 2006 7:51 pm
- Location: Sacramento, CA
- x 1
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
Definitely not a bug in Ogre as far as I can tell.
Test code:
This creates a series of Ogre HEADs with normal mapping and specular in a static geometry, and directly above them puts a standard entity for comparison. Camera and light move. Screenshots show they look identical, they both light dynamically as expected. There's no orientation being introduced here so the bug I fixed with tangents isn't an issue.

Sorry, I haven't had time to look at your stuff specifically, it's faster for me to test pure Ogre to eliminate 3rd-party issues. This suggests that there's a problem elsewhere, perhaps in the shaders you're using.
Test code:
Code: Select all
// Set ambient light
mSceneMgr->setAmbientLight(ColourValue(0, 0, 0));
// Create a point light
Light* l = mSceneMgr->createLight("MainLight");
l->setDiffuseColour(1.0, 0.7, 0.0);
l->setSpecularColour(ColourValue::White);
SceneNode* animNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Animation* anim = mSceneMgr->createAnimation("an1", 20);
anim->setInterpolationMode(Animation::IM_SPLINE);
NodeAnimationTrack* track = anim->createNodeTrack(1, animNode);
TransformKeyFrame* kf = track->createNodeKeyFrame(0);
kf->setTranslate(Vector3(2300, 600, 2300));
kf = track->createNodeKeyFrame(5);
kf->setTranslate(Vector3(-2300, 600, 2300));
kf = track->createNodeKeyFrame(10);
kf->setTranslate(Vector3(-2300, 600, -2300));
kf = track->createNodeKeyFrame(15);
kf->setTranslate(Vector3(2300, 600, -2300));
kf = track->createNodeKeyFrame(20);
kf->setTranslate(Vector3(2300, 600, 2300));
animNode->attachObject(l);
AnimationState* animState = mSceneMgr->createAnimationState("an1");
animState->setEnabled(true);
mAnimStateList.push_back(animState);
Plane plane;
plane.normal = Vector3::UNIT_Y;
plane.d = 0;
MeshManager::getSingleton().createPlane("Myplane",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
4500,4500,10,10,true,1,5,5,Vector3::UNIT_Z);
Entity* pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" );
pPlaneEnt->setMaterialName("Examples/GrassFloor");
pPlaneEnt->setCastShadows(false);
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt);
Vector3 min(-2000,30,-2000);
Vector3 max(2000,30,2000);
MeshPtr msh = MeshManager::getSingleton().load("ogrehead.mesh", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
msh->buildTangentVectors();
Entity* e = mSceneMgr->createEntity("1", "ogrehead.mesh");
e->setMaterialName("Examples/BumpMapping/MultiLightSpecular");
StaticGeometry* s = mSceneMgr->createStaticGeometry("bing");
s->setCastShadows(true);
s->setRegionDimensions(Vector3(500,500,500));
for (int i = 0; i < 10; ++i)
{
Vector3 pos;
pos.x = Math::RangeRandom(min.x, max.x);
pos.y = Math::RangeRandom(min.y, max.y);
pos.z = Math::RangeRandom(min.z, max.z);
s->addEntity(e, pos);
Entity* e2 = e->clone("clone" + StringConverter::toString(i));
mSceneMgr->getRootSceneNode()->createChildSceneNode(pos+Vector3(0,60,0))->attachObject(e2);
}
s->build();

Sorry, I haven't had time to look at your stuff specifically, it's faster for me to test pure Ogre to eliminate 3rd-party issues. This suggests that there's a problem elsewhere, perhaps in the shaders you're using.
-
Evak
- Orc Shaman
- Posts: 707
- Joined: Sun Apr 02, 2006 7:51 pm
- Location: Sacramento, CA
- x 1
hmm, interesting. I'm not sure why the shaders would work with a regular mesh but not a static one. Maybe its a Ofusion mesh problem?
http://www.kineticrealities.com/shinyprob.avi
The above link is a side by side video, the difference can be quite subtle but if you look at the specular highlights you can see that they do not adapt to the camera position in the capture on the right. So it looks almost static.
The Static geometry is the capture on the right hand side of the screen
http://www.kineticrealities.com/shinyprob.avi
The above link is a side by side video, the difference can be quite subtle but if you look at the specular highlights you can see that they do not adapt to the camera position in the capture on the right. So it looks almost static.
The Static geometry is the capture on the right hand side of the screen
Last edited by Evak on Thu Aug 09, 2007 11:53 pm, edited 1 time in total.
-
Evak
- Orc Shaman
- Posts: 707
- Joined: Sun Apr 02, 2006 7:51 pm
- Location: Sacramento, CA
- x 1
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
I've had a quick look, and your shaders are rather inefficient because they're passing camera position and light position in world space then inverse transforming it, instead of using the object space positions in the first place (camera_position_object_space / light_position_object_space). I tweaked that and it seemed to work.
-
Evak
- Orc Shaman
- Posts: 707
- Joined: Sun Apr 02, 2006 7:51 pm
- Location: Sacramento, CA
- x 1
hmm, ok. I Don't really know anything about shaders, I just selected tangent space and exported the .fx file. This was because the the shader profiler showed showed tangent space using less instructions being used on my GPU than the world space version. Was only one instruction less.
I'll get one of our coders to convert a world space version, unfortunately no one in our team knows much about shaders, but one of our coders figured out a step by step method to convert an FX file my shader tool creates for me.
Thanks for checking it out and hopefully showing your post to our coder will put us on the right track
UPDATE:
One of our coders worked it out from Sinbads comments in his last post
I'll get one of our coders to convert a world space version, unfortunately no one in our team knows much about shaders, but one of our coders figured out a step by step method to convert an FX file my shader tool creates for me.
Thanks for checking it out and hopefully showing your post to our coder will put us on the right track
UPDATE:
One of our coders worked it out from Sinbads comments in his last post
