[2.2] normal pbs reflection / help needed / gltf loader
Posted: Wed Oct 14, 2020 6:19 am
I there, i'm tring to port the Ybalrid gltf loader to 2.2.
https://github.com/Ybalrid/Ogre_glTF
You can see the progress here:
https://github.com/screwt/Ogre_glTF/tree/ogre_v2.2.4
But i'm stuck with the normal mapping.
I think i'm missing something with the scene, lghts or renderSystem init, thus reflection is messed up:

On the above capture, i removed all textures but the normal.
The scene is initialized here: https://github.com/screwt/Ogre_glTF/blo ... h/main.cpp
The model is there: https://github.com/screwt/Ogre_glTF/tre ... agedHelmet
Could you give me some advice?
-- EDIT --
Here is what happen with a sphere (debugPack.zip) and the "floor_bump.PNG" from Ogre Samples.

Loading code:
Scene init code:
-- EDIT --
Here is what i have with a fresh start from EmptyProject sample:

Also strange isn't it?
How i load the model:
https://github.com/Ybalrid/Ogre_glTF
You can see the progress here:
https://github.com/screwt/Ogre_glTF/tree/ogre_v2.2.4
But i'm stuck with the normal mapping.
I think i'm missing something with the scene, lghts or renderSystem init, thus reflection is messed up:

On the above capture, i removed all textures but the normal.
The scene is initialized here: https://github.com/screwt/Ogre_glTF/blo ... h/main.cpp
The model is there: https://github.com/screwt/Ogre_glTF/tre ... agedHelmet
Could you give me some advice?
-- EDIT --
Here is what happen with a sphere (debugPack.zip) and the "floor_bump.PNG" from Ogre Samples.

Loading code:
Code: Select all
camera->setNearClipDistance(0.001f);
camera->setFarClipDistance(100);
camera->setPosition(2.5f, 0.6f, 2.5f);
camera->lookAt({ 0, -0.1f, 0 });
camera->setAutoAspectRatio(true);
auto light = smgr->createLight();
smgr->getRootSceneNode()->createChildSceneNode()->attachObject(light);
light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(Ogre::Vector3 { -1, -1, -0.5f });
light->setPowerScale(5);
light = smgr->createLight();
smgr->getRootSceneNode()->createChildSceneNode()->attachObject(light);
light->setDiffuseColour(0.8f, 0.4f, 0.2f); //Warm
light->setSpecularColour(0.8f, 0.4f, 0.2f);
light->setPowerScale(20);
light->setType(Ogre::Light::LT_POINT);
light->getParentNode()->setPosition(0, -5, 0);
Ogre::Item* item = smgr->createItem(
"Sphere1000.mesh", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, Ogre::SCENE_DYNAMIC);
auto hlmsPbs = static_cast<Ogre::HlmsPbs*>(Ogre::Root::getSingleton().getHlmsManager()->getHlms(Ogre::HlmsTypes::HLMS_PBS));
Ogre::String datablockName = "RefractiveWall";
Ogre::HlmsPbsDatablock* datablock = static_cast<Ogre::HlmsPbsDatablock*>(
hlmsPbs->createDatablock(datablockName, datablockName, Ogre::HlmsMacroblock(), Ogre::HlmsBlendblock(), Ogre::HlmsParamVec()));
// Assign a normal map so the refractions are much more visually pleasing (and obvious)
datablock->setTexture(Ogre::PBSM_NORMAL, "floor_bump.PNG");
item->setDatablock(datablock);
Ogre::SceneNode* sphereNode = smgr->getRootSceneNode(Ogre::SCENE_DYNAMIC)->createChildSceneNode(Ogre::SCENE_DYNAMIC);
sphereNode->setPosition(1.5, 0, -0.2);
sphereNode->attachObject(item);
Scene init code:
Code: Select all
root->getRenderSystem()->setConfigOption("sRGB Gamma Conversion", "Yes");
Ogre::Window* window = root->initialise(true, "Gltf loader sample");
auto smgr = root->createSceneManager(Ogre::ST_GENERIC, 2);
smgr->showBoundingBoxes(true);
smgr->setDisplaySceneNodes(true);
auto camera = smgr->createCamera("cam");
//Setup rendering pipeline
auto compositor = root->getCompositorManager2();
const char workspaceName[] = "workspace0";
compositor->createBasicWorkspaceDef(workspaceName, Ogre::ColourValue { 0.2f, 0.3f, 0.4f });
auto workspace = compositor->addWorkspace(smgr, window->getTexture(), camera, workspaceName, true);
DeclareHlmsLibrary("../Data");
Here is what i have with a fresh start from EmptyProject sample:

Also strange isn't it?
How i load the model:
Code: Select all
mCameraController = new CameraController( mGraphicsSystem, false );
auto smgr = mGraphicsSystem->getSceneManager();
auto light = smgr->createLight();
smgr->getRootSceneNode()->createChildSceneNode()->attachObject(light);
light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(Ogre::Vector3{ -1, -1, -0.5f });
light->setPowerScale(5);
light = smgr->createLight();
smgr->getRootSceneNode()->createChildSceneNode()->attachObject(light);
light->setDiffuseColour(0.8f, 0.4f, 0.2f); //Warm
light->setSpecularColour(0.8f, 0.4f, 0.2f);
light->setPowerScale(20);
light->setType(Ogre::Light::LT_POINT);
light->getParentNode()->setPosition(0, -5, 0);
mSphere = smgr->createItem(
"Sphere1000.mesh", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, Ogre::SCENE_DYNAMIC);
auto hlmsPbs = static_cast<Ogre::HlmsPbs*>(Ogre::Root::getSingleton().getHlmsManager()->getHlms(Ogre::HlmsTypes::HLMS_PBS));
Ogre::String datablockName = "RefractiveWall";
Ogre::HlmsPbsDatablock* datablock = static_cast<Ogre::HlmsPbsDatablock*>(
hlmsPbs->createDatablock(datablockName, datablockName, Ogre::HlmsMacroblock(), Ogre::HlmsBlendblock(), Ogre::HlmsParamVec()));
// Assign a normal map so the refractions are much more visually pleasing (and obvious)
datablock->setTexture(Ogre::PBSM_NORMAL, "floor_bump.PNG");
mSphere->setDatablock(datablock);
Ogre::SceneNode* sphereNode = smgr->getRootSceneNode(Ogre::SCENE_DYNAMIC)->createChildSceneNode(Ogre::SCENE_DYNAMIC);
sphereNode->setPosition(1.5, 0, -0.2);
sphereNode->attachObject(mSphere);
/*
light->setType(Ogre::Light::LT_SPOTLIGHT);
light->setDirection(Ogre::Vector3 { 0, 0, -1 });
light->setPowerScale(5);
light->getParentNode()->setPosition(0, 0, 5);
*/
light = smgr->createLight();
smgr->getRootSceneNode()->createChildSceneNode()->attachObject(light);
light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(Ogre::Vector3{ +1, +1, +0.5f });
light->setPowerScale(5);