Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

extralongpants

a good rendering loop

This topic is 5365 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

I started rewriting my renderer in hopes of making it substantially faster. I have found that I may be looping through the vertices and triangles of each mesh too many times. In my old loop, I went through the mesh once per light for lighting, 3-4 times per light for stencil shadow volumes, once per light for bump map coords, and another time to finally render it. That's obviously enough looping to kill any performance I might have had. So, I came up with this psuedo code loop, and was wondering if some of you guys could critique it, or what-not (For clarity: My renderer will render batches of meshes per material by using its own pre-allocated vertex array):
for( each draw_pack) //a draw_pack contains info like depth testing and blending functions

{
	SetupDrawPack();

	for( each material )//a material contains texture info

	{
		SetupMaterial(); //binds current textures


		for( each visible mesh )
		{
			for(each visible triangle)
			{
				for(each light)
				{
					light.AddLightingToTriangle(curTri);
					light.AdjustEmbossMapTexCoords(curTri);
					light.shadowVolume[curVolume].AddData(curTri);

					AddTriIndicesToGlobalIndiceList(curTri);
								
				}
			}
			
			for(each vertice)
			{
				AddVertDataToGlobalVertList(curVert);
			}
		}
	}

	SubmitGlobalVertList();
	ClearLists();				//doesn't iterate through list, just sets # used to 0

}

DrawShadowVolumesEtc();

Anyway, i may have forgotten some things, but i was just hoping some of you could critique the basic loop. Thankyou for any help! ----------------------------- I never chew my cabbage twice [edited by - odiousangel on February 6, 2004 4:04:07 PM] [edited by - odiousangel on February 6, 2004 4:05:47 PM]

Share this post


Link to post
Share on other sites
Advertisement

  • 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!