Skip to main content
GameDev.net gamedev.net
🔒 Locked

Reducing Passes

Started by de_matt Mar 30, 2004 at 12:32 PM 3 replies 350+ views
Original Post
de_matt
de_matt
Hya, I''m writing a terrain engine. I''m using a quadtree for the culling. When I clip to the quadtree I make a list of all the tree segments to rende. Each segment''s got it''s own Index buffer. Each segment''s rendered 5 times for each of my terrain textures (grass, mud, rock, snow, water). My current test level''s a 65*65 vertices height grid but it gets framerates of under 100. It''s in windowed and I''m also rendering trees (tree, bush) etc. What could be the reason for this slow FPS? What could I do to sort it out? Thanks matt
neneboricua19
neneboricua19
Can you use multitexturing to reduce the number of passes? You may have to add more sets of texture coordinates to your terrain but that''s much better than rendering the same geometry 5 times.

neneboricua
Palidine
Palidine
quote:
Original post by de_matt
What could be the reason for this slow FPS? What could I do to sort it out?



definitely reducing rendering passes is a good guess. the best way of course to figure out where your app is slow is to run a profiled build so you can see where the most amount of time is spent in your app. then optimize the s#$t out of it (probably through an algorithmic change). i forget the name of the profiler i just downloaded & installed (sneftel just sent it out yesterday if you want to scan through his profile).

-me

de_matt
de_matt
I''ve thought of a way to use just one index buffer without making it a large one. Would removing all but one of the d3ddevice->SetIndices() call make a large difference?

I''m gonna do it anyway cus it''ll save loading times and memory.
de_matt
de_matt
Here''s my basic render code. Can anyone suggest a way to reduce the passes:

//Selects the render type depending on the model type
void CBazModel::rRender(LPDIRECT3DDEVICE8 &pd3ddevice, CBazCamera &rt_cam)
{
//only re-check the octree segments if the camera has moved.
if (rt_cam.cam_FrustumUpdated == true)
{
oct_totalrender = 0; //reset number of octs to render.
Render_Octree(0, pd3ddevice, rt_cam); //clip octree
rt_cam.cam_FrustumUpdated = false;
}

int i = 0, j = 1;

//set up sources
pd3ddevice->SetVertexShader( FVF_CUSTOMVERTEX );
pd3ddevice->SetStreamSource( 0, vb, sizeof(CUSTOMVERTEX) );

//start texture
pd3ddevice->SetTexture( 0, bmTextures[0].baztexture);

//texture stage 0
pd3ddevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
pd3ddevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pd3ddevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
pd3ddevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);

//texture stage 1 + filtering
pd3ddevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
pd3ddevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pd3ddevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
pd3ddevice->SetTextureStageState(1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
pd3ddevice->SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
pd3ddevice->SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);

//First time render
//rRender_Segment(pd3ddevice, 1);
//Render_Octree(0, pd3ddevice, rt_cam);
for (i = 0; i < oct_totalrender; i++)
rRender_Segment(pd3ddevice, oct_renderlist);

//Set render states
pd3ddevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
pd3ddevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
pd3ddevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR);
pd3ddevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR);

//Change textures and render a further 3 times
for (j = 1; j < 5; j++)
{
//Water doesn''t use magfilter
if (j == 4)
pd3ddevice->SetTextureStageState(1, D3DTSS_MAGFILTER, D3DTEXF_NONE);

pd3ddevice->SetTexture(0, bmTextures[j].baztexture);
pd3ddevice->SetTexture(1, bmAlphaTextures[j].baztexture);

//rRender_Segment(pd3ddevice, 1);
//Render_Octree(0, pd3ddevice, rt_cam);
for (i = 0; i < oct_totalrender; i++)
rRender_Segment(pd3ddevice, oct_renderlist[i]);
}

//disable allpha blending
pd3ddevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 0);
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.