SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED Opendungeons

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED Opendungeons

Post by paul424 »

Ogre Version: :1 12 9 :
Operating System: :OpenSuse Leap 15.2:
Render System: :GLSL3Plus:
Hello, I try to implement the dynamic shadows into OpenDungeons game. however I get a tons of artifacts and incorrect shadows:


Here's example material file I do use

Code: Select all

// Claimed
// import RTSS/NormalMapping_MultiPass from "RTShaderSystem.material"


vertex_program myClaimedTileVertexShader glsl
{
  source ClaimedTile.vert
    default_params
    {
        param_named_auto projectionMatrix projection_matrix
        param_named_auto viewMatrix view_matrix
        param_named_auto worldMatrix world_matrix
                param_named_auto lightMatrix texture_worldviewproj_matrix 0
    }
  
}

fragment_program myClaimedTileFragmentShader glsl
{
  source ClaimedTile.frag
    default_params
    {
        param_named_auto ambientLightColour ambient_light_colour 0
        param_named_auto lightDiffuseColour light_diffuse_colour 0.0 
        param_named_auto lightSpecularColour light_specular_colour 0.0 
        param_named_auto lightPos light_position  0.0 0.0 0.0 0.0
        param_named_auto cameraPosition camera_position 0.0        
        param_named_auto diffuseSurface surface_diffuse_colour 0.0  
        param_named seatColor  float4 1.0 1.0 1.0 1.0 
    }
}


material Claimed //: RTSS/NormalMapping_MultiPass
{
    
    technique
    {

        pass 
        {
            diffuse 1.0 1.0 1.0 1.0  
            vertex_program_ref myClaimedTileVertexShader
            {
                
            }
            fragment_program_ref myClaimedTileFragmentShader
            { 
                param_named decalmap int 0
                param_named normalmap int 1
                param_named crossmap int 2
                                param_named shadowmap int 3
            }            
            
            
            // We use blending, so that we can see the underlying texture.
            texture_unit decalmap
            {
                texture Claimed.png
            }
        
            texture_unit normalmap
            {
                texture ClaimedNormal.png
            }
            texture_unit crossmap
            {
                texture ClaimedMask.png
            }
            texture_unit shadowmap
            {
                content_type shadow
                tex_address_mode clamp
                filtering bilinear              
                
            }            
        }

    }
}
Here' are the expert from the vertex and fragments shaders :

vertex:

Code: Select all

layout (location = 0) in vec4 aPos;
...

VertexPos = lightMatrix * aPos;

Code: Select all

    vec4 shadow = vec4(1.0, 1.0, 1.0,1.0);
    vec4 tmpVertexPos = VertexPos;
    
    /* compute shadowmap */
    if(tmpVertexPos.z > 0 ){
        tmpVertexPos /= tmpVertexPos.w;
        shadow = texture(shadowmap, tmpVertexPos.xy); 
    }

In RenderManager.cpp I put :

Code: Select all

    mSceneManager->setShadowTechnique(Ogre::ShadowTechnique::SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);
and to the building Tile meshes of Walls I apply setCastShadow(false), that's probably the shadows are being cast through walls in the first place....
What interest me the most is why the creatures cast rarely correct shadows and only in some particular position to light and camera ? ....
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Re: SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED Opendungeons

Post by paul424 »

UPDATE, here's what I have so far after changing the setShadowFarDistance(30) setShadowTextureSelfShadow(false);and some mending the shaders programs :


What to do to make the shadows not penetrate the walls, In the Video you can see the ChickenCoop's shadow penetrating the walls.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED Opendungeons

Post by paroj »

paul424 wrote: Sat Feb 20, 2021 2:35 pm What to do to make the shadows not penetrate the walls, In the Video you can see the ChickenCoop's shadow penetrating the walls.
- you must make the walls "casters" so they are treated as occludes from the light perspective
- if you want to have things to be both caster and receiver, you must use depth shadows
- it looks like you are using a point light for casting shadows. In Ogre1, this is approximated by "dynamic" spot lights, which has limitations. In your use-case you can just lift that point light a bit and turn it into a spotlight yourself. This will give you more control on how shadows are rendered.
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Re: SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED Opendungeons

Post by paul424 »

Thanks for the reply; however new problem arises :
With this, and shadow texture of size 2048x2048 ( no larger is possible, why is that , why larger doesn't work ?)

Code: Select all

        
        mHandLight->setSpotlightRange(Ogre::Degree(145),Ogre::Degree(145));
 
        Ogre::SceneNode dummyNode(NULL);
        Ogre::Camera shadowCam("ShadowCameraSetupCam", 0);
        shadowCam._notifyAttached(&dummyNode);
        shadowCam._notifyViewport(mViewport);
        mSceneManager->getShadowCameraSetup()->getShadowCamera(mSceneManager,  mViewport->getCamera(),mViewport, mHandLight, &shadowCam, 0);
I get very blurry shadows like those (but at least the shadows appear everywhere uniformly ) :
Image
How do I get something sharper, I tried diffreeeeeeeent settings and my brain hurts ...
Also the above code is taken from Demo Samples, can you explain what exactly the getShadowCamera does ?
Also what is the default ShadowCameraSetup for a SceneManager in Ogre1 ?
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Re: SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED Opendungeons

Post by paul424 »

For sure getShadowCamera returns the camera to use to rendering into shadowmap, question is :Is it possible to modfiy the settings of that shadow camera ? For example the Field of View ?
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED Opendungeons

Post by paroj »

yes, the FOV is basically what you set in setSpotlightRange
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Re: SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED Opendungeons

Post by paul424 »

Adding FSAA to 16 wtih setShadowTextureConfig helps a little, but I will repeat my question, why I cannot use shadow textures larger then 2048x2048 ?

This is an example 4096x4096 shadow texture :
Image

EDIT: After closer lookup this artifact occurs at every texture resolution, but at higher ones no creature cast shadows PLUS the artifact is especially visible ...
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Re: SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED Opendungeons

Post by paul424 »

One more thing, wehn using LiSPSMShadowCameraSetup, I get a square's outline : inside it every shadow is fine, outside the shadows gets distorted quickly. What is it ? Intuitivlely, I should make the area of the square larger .... , how ?
Image
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Re: SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED Opendungeons

Post by paul424 »

yes, the FOV is basically what you set in setSpotlightRange
Yes, but I mean to directly manipulate what's left from getShadowCamera like

Code: Select all

        Ogre::Camera* mShadowCam = RenderManager::getSingletonPtr()->getSceneManager()->createCamera("mShadowCam");
        mShadowCam->setFOVy(Ogre::Degree(90));        
        RenderManager::getSingletonPtr()->getSceneManager()->getShadowCameraSetup()->getShadowCamera(
        RenderManager::getSingletonPtr()->getSceneManager(),
        RenderManager::getSingletonPtr()->getViewport()->getCamera(), 
        RenderManager::getSingletonPtr()->getViewport(),
        RenderManager::getSingletonPtr()->mHandLight, mShadowCam, 0);
        
but it does not work that way, that is it doesn't set the FOVy to desired value, I still don't get it what getShadowCamera is for ...
Returns a LiSPSM shadow camera.

Remarks
Builds and returns a LiSPSM shadow camera. More information can be found on the webpage of the TU Wien: http://www.cg.tuwien.ac.at/research/vr/lispsm/
Post Reply