[1.10] Making work Basic Tutorial 2

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
BohdanKornienko
Halfling
Posts: 43
Joined: Sat Nov 01, 2014 10:26 pm

[1.10] Making work Basic Tutorial 2

Post by BohdanKornienko »

I am using ApplicationContext as a base class and replacing setup method with content of the Basic Tutorial 2 (http://www.ogre3d.org/tikiwiki/tiki-ind ... =Tutorials)

There is a line with setting light techniques:

Code: Select all

scnMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
So when I use it I am getting black screen.

Using SHADOWTYPE_STENCIL_MODULATIVE (which has more or less ok results) creates on the back of the ninja some weird artifacts.

Would appreciate for any help and additional links for materials where I can get better understanding what is going on and how should I do these things (with lighting) in 1.10 version.

For reference I am giving setup() method content:

Code: Select all

// do not forget to call the base first
    OgreBites::ApplicationContext::setup();

    // get a pointer to the already created root
    Ogre::Root* root = getRoot();
    Ogre::SceneManager* scnMgr = root->createSceneManager(Ogre::ST_GENERIC);

    // register our scene with the RTSS
    Ogre::RTShader::ShaderGenerator* shadergen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
    shadergen->addSceneManager(scnMgr);

    // -- tutorial section start --
    Ogre::SceneNode* camNode = scnMgr->getRootSceneNode()->createChildSceneNode();

    Ogre::Camera* cam = scnMgr->createCamera("myCam");
    cam->setNearClipDistance(5); // specific to this sample
    camNode->attachObject(cam);//
    camNode->setPosition(200, 300, 300);
    camNode->lookAt(Ogre::Vector3(0, 0, 0), Ogre::Node::TransformSpace::TS_WORLD);

    Ogre::Viewport* vp = mWindow->addViewport(cam);
    vp->setBackgroundColour(Ogre::ColourValue(0, 0, 0));
    cam->setAspectRatio(
      Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())
    );

    Ogre::Entity* ninjaEntity = scnMgr->createEntity("ninja.mesh");
    ninjaEntity->setCastShadows(true);

    scnMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ninjaEntity);

    Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);

    Ogre::MeshManager::getSingleton().createPlane(
            "ground",
            Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
            plane,
            1500, 1500, 20, 20,
            true,
            1, 5, 5,
            Ogre::Vector3::UNIT_Z);

    Ogre::Entity* groundEntity = scnMgr->createEntity("ground");
    scnMgr->getRootSceneNode()->createChildSceneNode()->attachObject(groundEntity);
    groundEntity->setCastShadows(false);
    groundEntity->setMaterialName("Examples/Rockwall");

    scnMgr->setAmbientLight(Ogre::ColourValue(0, 0, 0));

    // TODO: this thing does not work for some reason:
//    scnMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
    // this one works but not as expected
    scnMgr->setShadowTechnique(Ogre::ShadowTechnique::SHADOWTYPE_STENCIL_MODULATIVE);

    Ogre::Light* spotLight = scnMgr->createLight("SpotLight");

    spotLight->setDiffuseColour(0, 0, 1.0);
    spotLight->setSpecularColour(0, 0, 1.0);

    spotLight->setType(Ogre::Light::LT_SPOTLIGHT);

    spotLight->setDirection(-1, -1, 0);
    spotLight->setPosition(Ogre::Vector3(200, 200, 0));

    spotLight->setSpotlightRange(Ogre::Degree(35), Ogre::Degree(50));


    Ogre::Light* directionalLight = scnMgr->createLight("DirectionalLight");
    directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);

    directionalLight->setDiffuseColour(Ogre::ColourValue(.4, 0, 0));
    directionalLight->setSpecularColour(Ogre::ColourValue(.4, 0, 0));

    directionalLight->setDirection(Ogre::Vector3(0, -1, 1));

    Ogre::Light* pointLight = scnMgr->createLight("PointLight");
    pointLight->setType(Ogre::Light::LT_POINT);

    pointLight->setDiffuseColour(.3, .3, .3);
    pointLight->setSpecularColour(.3, .3, .3);

    pointLight->setPosition(Ogre::Vector3(0, 150, 250));
Attachments
Expected render
Expected render
Actual render
Actual render
paroj
OGRE Team Member
OGRE Team Member
Posts: 1995
Joined: Sun Mar 30, 2014 2:51 pm
x 1075
Contact:

Re: [1.10] Making work Basic Tutorial 2

Post by paroj »

User avatar
BohdanKornienko
Halfling
Posts: 43
Joined: Sat Nov 01, 2014 10:26 pm

Re: [1.10] Making work Basic Tutorial 2

Post by BohdanKornienko »

paroj wrote:are you using GL3+? https://github.com/OGRECave/ogre/issues/343
I do.
So It is not functional on GL3+ now, right?

Does it mean that it is better to use pure GL version for tutorials now?

P.S. Well. At least I can confirm that it is not functional. There are other techniques which also did not work (do not remember names), I can provide those names if needed.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1995
Joined: Sun Mar 30, 2014 2:51 pm
x 1075
Contact:

Re: [1.10] Making work Basic Tutorial 2

Post by paroj »

Does it mean that it is better to use pure GL version for tutorials now?
no, it is better to update the tutorials s.t. they work with any rendersystem. So use SHADOWTYPE_STENCIL_MODULATIVE instead (and change the text accordingly).

Especially since there is not ETA when *_ADDITIVE shadowing will be fixed.
User avatar
BohdanKornienko
Halfling
Posts: 43
Joined: Sat Nov 01, 2014 10:26 pm

Re: [1.10] Making work Basic Tutorial 2

Post by BohdanKornienko »

Got this!
Thank you.
Post Reply