Issue with floor and text

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
Posts: 10
Joined: Wed Aug 21, 2019 9:35 am
x 1

Issue with floor and text

Post by Wathiant » Mon Sep 09, 2019 9:25 am

I've got my movable texts to work (mostly), thanks to all the info in this thread: viewtopic.php?f=25&t=82872
The only things I can't seem to fix is that my text doesn't seem to have a transparent background. It just uses the normal background color.
And I haven't found where to disable the shadow casting from my text.

Additionally, the link to the zip on this page is broken. It says " Plugin disabled Plugin attach cannot be executed." (using FireFox), so I used the one from the mentioned thread instead.

The "on top" functionality also doesn't work properly for me, whether it's enabled or not... For some reason my floor is draw after the text.
The way the mOnTop is applied:

Code: Select all

	HlmsMacroblock macroblockOptions;
	macroblockOptions.mDepthCheck = !mOnTop;
	macroblockOptions.mDepthWrite = mOnTop;
When on top is enabled it doesn't check for depth (correct), but it does write its depth and thus can get overwritten by stuff that is in front of it and drawn later (which makes it not on top anymore). I would expect that it writes a depth 0 in this case, but that doesn't seem to be the case.
When on top is disabled it does do the depth check, but then never writes its own depth, causing it to be overwritten easily by anything that is drawn after (in my case my floor plane seems to be drawn later and so my text always gets obscured by the floor).

I don't need the on top functionality, so for me changing the code to

Code: Select all

	HlmsMacroblock macroblockOptions;
	macroblockOptions.mDepthCheck = true;
	macroblockOptions.mDepthWrite = true;
seems to work, but it might need some attention.

While typing this I just noticed that the transparent background issue seems to only apply to the floor as well, as it seems the background is transparent to other objects. I can't see a reason why my floor is doing these weird things though. Floor plane code:

Code: Select all

		auto const meshUid = QString("floorplane_%1_%2")
			.arg((int) (d->m_desiredSettings->m_floorSize))
			.arg((int) d->m_desiredSettings->m_tilesPerSide).toOgreString();
		auto const floorUid = d->m_floorUid.toOgreString();

		if (Ogre::v1::MeshManager::getSingleton().getByName(meshUid).isNull())
			// create floor plane if it did not exist
			Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
			Ogre::v1::MeshPtr planeMeshV1 = Ogre::v1::MeshManager::getSingleton().createPlane(
					d->m_desiredSettings->m_floorSize,		// width
					d->m_desiredSettings->m_floorSize,		// height
					1,				// xsegments
					1,				// ysegments
					true,			// normals
					1,				// numTexCoordSets
					d->m_desiredSettings->m_tilesPerSide / 2, // U Tile
					d->m_desiredSettings->m_tilesPerSide / 2, // V Tile
					Ogre::Vector3::UNIT_Z,	// This appears to a texture vector...
			Ogre::MeshPtr planeMesh = Ogre::MeshManager::getSingleton().createManual( meshUid + "_plane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
			planeMesh->importV1( planeMeshV1.get(), true, true, true );

		if (d->m_floorEntity)

		d->m_floorEntity = m_sceneManager->createEntity(meshUid);

		Ogre::Node* node = findChildNode(m_sceneManager->getRootSceneNode(), floorUid);
		if (!node)
			node = m_sceneManager->getRootSceneNode()->createChildSceneNode();
		auto snode = dynamic_cast<Ogre::SceneNode*>(node);
And the material it uses in floor.material:

Code: Select all

hlms floor pbs
	roughness	0.4
	fresnel		1.33

	detail_map0			floortile512.png
	diffuse_map			floortile512.png
	alpha_from_textures	false
As you can see in this image, the text has a blue background (my background/sky colour) where only the floor is shown and casts a shadow on the floor. The red triangle, the 2 white origin lines and the avatar are behaving as expected wrt text transparency.
0 x

User avatar
OGRE Team Member
OGRE Team Member
Posts: 4176
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 280

Re: Issue with floor and text

Post by dark_sylinc » Mon Sep 09, 2019 4:37 pm


By default we should sort transparent objects to render after opaque objects (i.e. transparents need to be rendered back to front) otherwise this happens.

Aditionally depth writes should be turned off for transparent objects.

How are you setting up your material/datablock (the one for the text)? Could you upload that bit of code? Sounds like something is going wrong with the material setup.

Additionally, the text should not be in a render queue lower than the floor (i.e. MovableObject::setRenderQueueGroup)
0 x

Posts: 10
Joined: Wed Aug 21, 2019 9:35 am
x 1

Re: Issue with floor and text

Post by Wathiant » Tue Sep 10, 2019 8:12 am

Thanks, that solved the weird transparency issue.
I was initializing the MovableText's inherited MovableObject like this: MovableObject(id, objectMemoryManager, sceneManager, 1)
but changing it to: MovableObject(id, objectMemoryManager, sceneManager, 254)
solves the transparency problem.
This is with depth writes and checks both still enabled by the way. I now understand what was going wrong, so thank you for educating me.

And the shadow thing was fairly trivial, I was just looking in the wrong place. This is an entity thing, not a DataBlock thing (which is where I was looking). MovableObject has the setCastShadows function.

Many thanks again :)
0 x

Post Reply