Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RenderOrder is in different scale in Reverse Z #514

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion ogre2/src/Ogre2Material.cc
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,22 @@ void Ogre2Material::SetRenderOrder(const float _renderOrder)
this->renderOrder = _renderOrder;
Ogre::HlmsMacroblock macroblock(
*this->ogreDatablock->getMacroblock());
macroblock.mDepthBiasConstant = _renderOrder;

Ogre::Root *root = Ogre2RenderEngine::Instance()->OgreRoot();
Ogre::RenderSystem *renderSystem = root->getRenderSystem();

if (renderSystem->isReverseDepth())
{
// Reverse depth needs 100x scale AND ends up being superior
// See https://github.com/ignitionrobotics/ign-rendering/
// issues/427#issuecomment-991800352
// and see https://www.youtube.com/watch?v=s2XdH3fYUac
macroblock.mDepthBiasConstant = _renderOrder * 100.0f;
}
else
{
macroblock.mDepthBiasConstant = _renderOrder;
}
this->ogreDatablock->setMacroblock(macroblock);
}

Expand Down