[Solved] Sometimes depth write only doesn't work

Problems building or running the engine, queries about how to use features etc.
Post Reply
Ray1184
Gnoblar
Posts: 15
Joined: Thu Jan 07, 2021 3:47 pm
x 5

[Solved] Sometimes depth write only doesn't work

Post by Ray1184 »

Ogre Version: 13.2.3
Operating System: Windows 10
Render System: OpenGL

Hello,
I'm asking here because of a strange behavior in depth write.
In my engine I use the depth only write on materials to simulate old 2.5D adventures, such alone in the dark trilogy, resident evil etc...
So, I use an entity with depth write only material, and I draw a background with the scene rendering.
I created this helper method:

Code: Select all

inline static void SetWriteDepthOnly(Ogre::Entity* entity)
        {
            auto material = entity->getSubEntity(0)->getMaterial();
            material->getTechnique(0)->getPass(0)->setColourWriteEnabled(false);
            material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(true);
        }
This simple system does its job most of the time, but, I don't know why, more or less 5% of the time (in any case very reraly), when I start my engine, depth write is not working, as if depth write flag was not be setted. If I close the window and start again, It works without any problem.
Could it be that I forgot something? Maybe there's a more stable and better solution for managing this?

Thanks a lot
Last edited by Ray1184 on Wed Feb 02, 2022 9:44 am, edited 1 time in total.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1995
Joined: Sun Mar 30, 2014 2:51 pm
x 1075
Contact:

Re: Sometimes depth write only doesn't work

Post by paroj »

is your app threaded? Do you use the RTSS?
Ray1184
Gnoblar
Posts: 15
Joined: Thu Jan 07, 2021 3:47 pm
x 5

Re: Sometimes depth write only doesn't work

Post by Ray1184 »

Hi, my app is single thread, and I'm not using RTSS, but standard material system
Ray1184
Gnoblar
Posts: 15
Joined: Thu Jan 07, 2021 3:47 pm
x 5

Re: Sometimes depth write only doesn't work

Post by Ray1184 »

UPDATE: I tried to play a bit with rendering bucket and maybe (I hope) it's solved.
Probabily sometimes these "depth only" entities are rendered after the standard entities and depth test fails for some reasons (I don't know why...)
Setting in depth entites a lower value then standard entities for rendering group, seems solving the problem.

In any case thanks for support!
Post Reply