Run Time error with shadow enabled

Problems building or running the engine, queries about how to use features etc.
Post Reply
dcavallini
Gnoblar
Posts: 17
Joined: Fri Jul 16, 2021 10:04 am
x 2

Run Time error with shadow enabled

Post by dcavallini »

Ogre Version: :Version 13.3.4 (Tsathoggua) :
Operating System: :windows:
Render System: : GL 3+ ,D3D11:

If I use two side render state enabled

Code: Select all

renderState->setParameter("two_sided", "true"))

and i set scnMgr->setShadowTechnique(ShadowTechnique::SHADOWTYPE_STENCIL_ADDITIVE);
I obtain runtime error if use opengl render system and shadow only a side if use D3D11.
The image below is obtained with D3D11.
With technique SHADOWTYPE_TEXTURE_ADDITIVE no shadow appear.
Any Suggest?

Image

paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: Run Time error with shadow enabled

Post by paroj »

that parameter controls lighting computations. When it comes to shadows, you are likely looking for "cull_hardware none" https://ogrecave.github.io/ogre/api/lat ... otoc_md139

also, posting the actual error message would help.

rpgplayerrobin
Gnoll
Posts: 619
Joined: Wed Mar 18, 2009 3:03 am
x 353

Re: Run Time error with shadow enabled

Post by rpgplayerrobin »

Only a couple of suggestions:

  • I would avoid stencil shadows as far as possible, as they are impossible to control correctly.
    If you want something like leaves or a bush to cast shadows, they will follow the edges of the mesh and not the actual pixels rendered (if they were rendered with alpha rejection or alpha blending for example).
    That means it will render very ugly shadows on more advanced scenes.
    It is also very hard/impossible to do soft shadows on stencil shadows.

Texture shadows are the new thing after stencil shadows. They are much easier to control and can be used in shaders, which means you can do much more special features.
For my game for example, I use depth-shadows with soft shadows and cloud shadows because it can so easily be used in a shader.

You can somehow use the RTSS to auto generate shaders to cast depth-shadows (like I use), though I am not sure how since I only use my own-written shaders.

  • Using a single plane or just one side of something (like a cloth with physics on or anything like that) is actually quite bad.
    That is because the normal will only be correct on one side, and not the other, which means that lighting of the object will be incorrect on one side.
    In my game I solve this by never having one-sided cloth/planes that can be seen from both sides, instead I duplicate the mesh in my 3D modelling tool, invert the normals, and then combine it into one object.
    Then I can just use normal culling (which means you never specify any cull_hardware in the material) and each side will hide itself when it is away from view, which means only one side will be visible at a time, but now with correct lighting instead.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: Run Time error with shadow enabled

Post by paroj »

rpgplayerrobin wrote: Thu May 12, 2022 1:23 am

That is because the normal will only be correct on one side, and not the other, which means that lighting of the object will be incorrect on one side.

more recent Ogre, has a solution for that: https://www.ogre3d.org/2021/10/09/ogre- ... -roundup-8

However, as said, this is only relevant for lighting, not for shadow casting.

dcavallini
Gnoblar
Posts: 17
Joined: Fri Jul 16, 2021 10:04 am
x 2

Re: Run Time error with shadow enabled

Post by dcavallini »

Thank you for the suggests.
I tried to simplify my problem.

Code: Select all

  scnMgr->setShadowTechnique(ShadowTechnique::SHADOWTYPE_TEXTURE_ADDITIVE);
    Entity* ogreEntity3 = scnMgr->createEntity("ogrehead.mesh");
    SceneNode* ogreNode3 = scnMgr->getRootSceneNode()->createChildSceneNode();
    ogreNode3->setPosition(0, 104, 0);
    ogreNode3->attachObject(ogreEntity3);
    Plane plane(Vector3::UNIT_Y, 0);
    MeshManager::getSingleton().createPlane(
        "ground", RGN_DEFAULT,
        plane,
        1500, 1500, 20, 20,
        true,
        1, 5, 5,
        Vector3::UNIT_Z);
    Entity* groundEntity = scnMgr->createEntity("ground");
    scnMgr->getRootSceneNode()->createChildSceneNode()->attachObject(groundEntity);
    groundEntity->setCastShadows(true);
    Light* dirLight = scnMgr->createLight(Light::LT_DIRECTIONAL);
    SceneNode* dirLightNode = scnMgr->getRootSceneNode()->createChildSceneNode();
    dirLightNode->attachObject(dirLight);
    dirLightNode->setDirection(-1, -1, 0);
    dirLightNode->setPosition(Vector3(200, 200, 0)):

with shadow Techique "SHADOWTYPE_TEXTURE_ADDITIVE" or SHADOWTYPE_TEXTURE_MODULATIVE shadows aren't displayed
if I set groundEntity->setCastShadows(false) shadows are displayed correctly

Edit 1
if I set

Code: Select all

scnMgr->setShadowTextureSelfShadow(true);

shadow texture appear but entity (head ogre) go in shadow.What am I missing?

TEXTURE_MODULATIVE:
Image
STENCIL_MODULATIVE:
Image

dcavallini
Gnoblar
Posts: 17
Joined: Fri Jul 16, 2021 10:04 am
x 2

Re: Run Time error with shadow enabled

Post by dcavallini »

In SampleBrowser (Category:Lighting, Sample:Shadows) I tried to setCastShadows(true) in plane entity and the shadows disappear with tecnique texture.
I deduce if the entity casts shadows then it cannot receive with this technique.

paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: Run Time error with shadow enabled

Post by paroj »

Post Reply