Operating System: Linux
Render System: OpenGL3+
I'm trying to do 2D rendering with the Unlit HLMS and an orthographic camera. I got it mostly working, but for some reason the alpha blending is not working between two meshes. I have a blendblock with "blendblock.setBlendType(Ogre::SBT_TRANSPARENT_ALPHA);" set on both the mesh with the wood texture and the cursor mesh, and I'm sure the cursor texture does include an alpha channel, but it looks like this:
But the cursor mesh correctly blends with image content drawn in an earlier compositor workspace (the text with blue background in the top left):
This is basically my code (the entire code is on github: https://github.com/hhyyrylainen/Leviath ... et.cpp#L31):
Code: Select all
Ogre::HlmsManager* hlmsManager = Ogre::Root::getSingleton().getHlmsManager();
Ogre::HlmsTextureManager* hlmsTextureManager = hlmsManager->getTextureManager();
Ogre::HlmsUnlit* hlmsUnlit =
static_cast<Ogre::HlmsUnlit*>(hlmsManager->getHlms(Ogre::HLMS_UNLIT));
const auto datablockName = GetNameForDatablock();
Ogre::HlmsBlendblock blendblock;
blendblock.setBlendType(Ogre::SBT_TRANSPARENT_ALPHA);
// blendblock.mSourceBlendFactor = Ogre::SBF_ONE;
// blendblock.mDestBlendFactor = Ogre::SBF_ONE_MINUS_SOURCE_ALPHA;
// blendblock.mSourceBlendFactor = Ogre::SBF_SOURCE_ALPHA;
// blendblock.mDestBlendFactor = Ogre::SBF_ONE_MINUS_SOURCE_ALPHA;
Ogre::HlmsUnlitDatablock* datablock =
static_cast<Ogre::HlmsUnlitDatablock*>(hlmsUnlit->createDatablock(datablockName,
datablockName, Ogre::HlmsMacroblock(), blendblock, Ogre::HlmsParamVec()));
Ogre::HlmsTextureManager::TextureLocation texLocation =
hlmsTextureManager->createOrRetrieveTexture(
ImageName, Ogre::HlmsTextureManager::TEXTURE_TYPE_DIFFUSE);
datablock->setTexture(0, texLocation.xIdx, texLocation.texture);
Width = texLocation.texture->getWidth();
Height = texLocation.texture->getHeight();
QuadMesh = GeometryHelpers::CreateWidgetGeometry(
"image_widget_" + std::to_string(ID) + "_mesh", Width, Height);
QuadItem = ContainedIn->GetScene()->createItem(QuadMesh, Ogre::SCENE_DYNAMIC);
QuadItem->setDatablock(datablock);
Node = ContainedIn->GetParentForWidgets()->createChildSceneNode(Ogre::SCENE_DYNAMIC);
Node->attachObject(QuadItem);
Does anyone know what I'm doing wrong?