Manual Object Line List Depth Bias

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
Nickak2003
Goblin
Posts: 272
Joined: Thu Jun 10, 2004 4:19 am
x 26

Manual Object Line List Depth Bias

Post by Nickak2003 »

I have created a minimap for my game, and I am trying to overlay a line-list to describe the viewport. I'm using manual object to do this, and If I create a TRIANGLE LIST QUAD, with a depth bias of 1.0, while my minimap is also a TRIANGLE LIST QUAD with a depth bias of 0.5, it works and there is an opaque quad where the viewport should be. However, if I change it into a linelist, then the depth bias does not seem to work and I cannot see an overlay on the minimap. Both materials are unlit.

To describe the problem, here is a video:

Nickak2003
Goblin
Posts: 272
Joined: Thu Jun 10, 2004 4:19 am
x 26

Re: Manual Object Line List Depth Bias

Post by Nickak2003 »

OK I feel like I hack away many times without really knowing what I'm doing. I don't think I understand what's going on. I did get it to work, but I have some questions on why. Here is more info:

first off, I have a gui the gui is an item with identity view/projection and is full screen with transparency. The gui material looks like so:

Code: Select all

	Ogre::HlmsMacroblock macroBlock;
	macroBlock.mDepthCheck = false;
	macroBlock.mDepthBiasConstant = 0.0;
	Ogre::HlmsBlendblock blendBlock;
	blendBlock.setBlendType(Ogre::SceneBlendType::SBT_TRANSPARENT_ALPHA);

Next, I create a manual object2 quad, the minimap, with identity view/projection. This is the material:

Code: Select all

			Ogre::HlmsMacroblock macroBlock;
			macroBlock.mDepthCheck = true;
			macroBlock.mDepthBiasConstant = 0.0;

next I create the viewport which is a manualobject2 line-list with identity view/proj which looks like so:

Code: Select all

			macroBlock.mDepthCheck = false;
			macroBlock.mDepthBiasConstant = 1.0;

If I change the minimap depthcheck = false, it doesn't draw, why is that?
Also, the depth bias constant doesn't seem to work if I change it from 0.0/1.0, to a value in-between, why?
Here is a video of it working:

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Manual Object Line List Depth Bias

Post by dark_sylinc »

Depth bias isn't constraint to a value in range 0-1, you can try values like 36 or 100.

The problem of depth bias is that it's very unpredictable. Its behavior can change between GPUs and APIs, which is why nobody uses it except as a last resort.

Increasing the Z position is usually a much better way. Depth buffers aare not THAT imprecise.

Disabling depth checks is also another good solution, as long as you set a higher render queue ID so that they are rendered last

Post Reply