Jump to content
  • Advertisement
Sign in to follow this  
Lopez

Early Z - How to?

This topic is 4554 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I've managed to push my geforce 5600 to draw a 20k scene mesh, with 5 materials, all using GLSL shaders, at 300 fps. I want to get it faster. I think I understand the concept of early z... 1. disable color writes / enable depth writes 2. render geometry 3. enable color writes / disable depth writes 3. render geometry by shader/material using the following code isn't working though...

	if(_cam!=NULL){
		_octree.DrawOcclusion(&_octree, &_world, _cam, 0);
		if(bShaders){
			//	render only z
			glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
			glDepthMask(GL_TRUE);
			_octree.DrawOctreeMesh( &_octree, &_world,_cam );

			//	now render scene by material
			int num		=	_world.pMaterials.size();
			int count;
			for(count=0;count<num;++count){
				//	render only color
				glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
				glDepthMask(GL_FALSE);
				_octree.DrawOctreeByMaterial(&_octree, &_world,_cam, count, 0);
				glDepthMask(GL_TRUE);
			}
		}
		else{
			_octree.DrawOctree_NoShaders(&_octree, &_world, _cam);
		}
	}
	else{
		int num		=	_world.pMaterials.size();
		int count;
		for(count=0;count<num;++count){
			_octree.DrawOctreeByMaterial(&_octree, &_world, NULL, count, 0);
		}
	}




Do I have to alter my shaders in some way to accomodate the early-z? Or am I doing the rendering routine incorrectly?

Share this post


Link to post
Share on other sites
Advertisement
that should work but its not the ideal method speedwise
u wanna lay down the depth pass first (of all solid geometry) for the whole scene in one go ie not continually changing states
also for extra speed (if theres a lot of occlusion eg a terrain with hills viewwed from FirstPerson) u will want to do occlusion tests whilst laying down the first depth pass (though on the nv3x this is broken but if u have >15% occlusion its still a win, on other cards eg nv4x> or ati its a win always)

Share this post


Link to post
Share on other sites
cheers zedzeek, the problem is that when I use the aforementioned method, no gometry is rendered to screen.

Share this post


Link to post
Share on other sites
You should make sure that the second pass uses a depth comparison with less or equal. Otherwise your geometry will not be rendered as the depth buffer has already that Z value.

EDIT:
You should also move the glColorMask and glDepthMask calls out of the loop.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!