Code: Select all
//---------------------------------------------------------------------
void D3D9RenderSystem::_beginFrame()
{
HRESULT hr;
if( !mActiveViewport )
OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "Cannot begin frame - no viewport selected.", "D3D9RenderSystem::_beginFrame" );
if( FAILED( hr = mpD3DDevice->BeginScene() ) )
{
String msg = DXGetErrorDescription9(hr);
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error beginning frame :" + msg, "D3D9RenderSystem::_beginFrame" );
}
if(!mBasicStatesInitialised)
{
// First-time
// setup some defaults
// Allow specular
hr = __SetRenderState(D3DRS_SPECULARENABLE, TRUE);
if (FAILED(hr))
{
String msg = DXGetErrorDescription9(hr);
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Error enabling alpha blending option : " + msg, "D3D9RenderSystem::_beginFrame");
}
mBasicStatesInitialised = true;
}
}
I wrote "simple" shader for calculating lighting on my model with specularity and difference in fps was significant - if I added specular color calculation fps decreased from 200 to 100fps (GeForce 8600GT). I didn't test it with fixed pipeline, but with older cards I remember, that it significaly decreased fps. So my question is if somebody though about this issue and why specular calculations are always enabled? (maybe I missed something, but I found D3DRS_SPECULARENABLE only in _beginFrame method)Specular highlights almost double the cost of a light. Use them only when you must. Set the D3DRS_SPECULARENABLE render state to 0, the default value, whenever possible. When defining materials, you must set the specular power value to zero to turn off specular highlights for that material; just setting the specular color to 0,0,0 is not enough.