DepthSortDescendingLess for equal depth modification

What it says on the tin: a place to discuss proposed new features.
Post Reply
Markus Oberrauter
Gnoblar
Posts: 6
Joined: Mon Nov 03, 2008 9:49 am

DepthSortDescendingLess for equal depth modification

Post by Markus Oberrauter » Fri Aug 21, 2009 9:24 am

To avoid alpha sorting issues I render some objects with a 2 pass material ( 1st pass depth only, 2nd pass with color write enabled )

Code: Select all

pass depth
{
	scene_blend alpha_blend
	depth_check on
	depth_write on
	colour_write off	
	.....
}

pass color
{	
	colour_write on
	.....
}
when the mesh contains more than one submesh ( SubMeshA, SubMeshB ) AND they use different materials ( each one with a depth and color pass ) then it is not guaranteed that the depth passes will be executed before the color passes. My current workaround is to change the DepthSortDecendingLess function for different renderables with equal depth a little bit ( OgreRenderQueueSortingGrouping.h, Line 176 ( Ogre 1.6.2 ) )

Code: Select all

	if (Math::RealEqual(adepth, bdepth))
	{
		// Must return deterministic result, doesn't matter what
		old: return a.pass < b.pass;
		new: return a.pass->getHash() < b.pass->getHash();
	}
now the depth passes ( 1st pass ) are always executed before the color passes ( 2nd etc... ) for all submeshes of the entity. This change shouldn´t affect performance, but gives better control for the renderorder when creating complex materials and meshes.

Another idea: Defining the "hash" value of the pass in the materialscript would give even more control to the material script writer ( primary for transparent objects ).
0 x

Post Reply