Adjust order for meshvp
This commit is contained in:
parent
ce7357ffa4
commit
f7e80187ad
2 changed files with 17 additions and 13 deletions
|
@ -437,6 +437,8 @@ bool CMeshVPPerPixelLight::begin(IDriver *drv,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
enable(true, drv); // must enable the vertex program before the vb is activated
|
||||||
|
//
|
||||||
CRenderTrav *renderTrav= &scene->getRenderTrav();
|
CRenderTrav *renderTrav= &scene->getRenderTrav();
|
||||||
/// Setup for gouraud lighting
|
/// Setup for gouraud lighting
|
||||||
renderTrav->beginVPLightSetup(VPLightConstantStart,
|
renderTrav->beginVPLightSetup(VPLightConstantStart,
|
||||||
|
@ -482,9 +484,7 @@ bool CMeshVPPerPixelLight::begin(IDriver *drv,
|
||||||
|
|
||||||
// c[0..3] take the ModelViewProjection Matrix. After setupModelMatrix();
|
// c[0..3] take the ModelViewProjection Matrix. After setupModelMatrix();
|
||||||
drv->setConstantMatrix(0, IDriver::ModelViewProjection, IDriver::Identity);
|
drv->setConstantMatrix(0, IDriver::ModelViewProjection, IDriver::Identity);
|
||||||
//
|
|
||||||
enable(true, drv); // must enable the vertex program before the vb is activated
|
|
||||||
//
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,6 +538,8 @@ bool CMeshVPPerPixelLight::setupForMaterial(const CMaterial &mat,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
bool enabled = (mat.getShader() == CMaterial::PerPixelLighting || mat.getShader() == CMaterial::PerPixelLightingNoSpec);
|
bool enabled = (mat.getShader() == CMaterial::PerPixelLighting || mat.getShader() == CMaterial::PerPixelLightingNoSpec);
|
||||||
|
bool change = (enabled != _Enabled);
|
||||||
|
enable(enabled, drv); // enable disable the vertex program (for material that don't have the right shader)
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
CRenderTrav *renderTrav= &scene->getRenderTrav();
|
CRenderTrav *renderTrav= &scene->getRenderTrav();
|
||||||
|
@ -547,8 +549,6 @@ bool CMeshVPPerPixelLight::setupForMaterial(const CMaterial &mat,
|
||||||
renderTrav->getStrongestLightColors(pplDiffuse, pplSpecular);
|
renderTrav->getStrongestLightColors(pplDiffuse, pplSpecular);
|
||||||
drv->setPerPixelLightingLight(pplDiffuse, pplSpecular, mat.getShininess());
|
drv->setPerPixelLightingLight(pplDiffuse, pplSpecular, mat.getShininess());
|
||||||
}
|
}
|
||||||
bool change = (enabled != _Enabled);
|
|
||||||
enable(enabled, drv); // enable disable the vertex program (for material that don't have the right shader)
|
|
||||||
return change;
|
return change;
|
||||||
}
|
}
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
|
|
|
@ -291,30 +291,34 @@ bool CMeshVPWindTree::begin(IDriver *driver, CScene *scene, CMeshBaseInstance *m
|
||||||
if (!(driver->supportVertexProgram() && !driver->isVertexProgramEmulated())) return false;
|
if (!(driver->supportVertexProgram() && !driver->isVertexProgramEmulated())) return false;
|
||||||
|
|
||||||
|
|
||||||
// precompute mesh
|
|
||||||
setupPerMesh(driver, scene);
|
|
||||||
|
|
||||||
// Setup instance constants
|
|
||||||
setupPerInstanceConstants(driver, scene, mbi, invertedModelMat);
|
|
||||||
|
|
||||||
// Activate the good VertexProgram
|
// Activate the good VertexProgram
|
||||||
//===============
|
//===============
|
||||||
|
|
||||||
|
|
||||||
// Get how many pointLights are setuped now.
|
// Get how many pointLights are setuped now.
|
||||||
nlassert(scene != NULL);
|
nlassert(scene != NULL);
|
||||||
CRenderTrav *renderTrav= &scene->getRenderTrav();
|
CRenderTrav *renderTrav= &scene->getRenderTrav();
|
||||||
sint numPls= renderTrav->getNumVPLights()-1;
|
sint numPls= renderTrav->getNumVPLights()-1;
|
||||||
clamp(numPls, 0, CRenderTrav::MaxVPLight-1);
|
clamp(numPls, 0, CRenderTrav::MaxVPLight-1);
|
||||||
|
|
||||||
|
|
||||||
// Enable normalize only if requested by user. Because lighting don't manage correct "scale lighting"
|
// Enable normalize only if requested by user. Because lighting don't manage correct "scale lighting"
|
||||||
uint idVP= (SpecularLighting?2:0) + (driver->isForceNormalize()?1:0) ;
|
uint idVP= (SpecularLighting?2:0) + (driver->isForceNormalize()?1:0) ;
|
||||||
// correct VP id for correct unmber of pls.
|
// correct VP id for correct unmber of pls.
|
||||||
idVP= numPls*4 + idVP;
|
idVP= numPls*4 + idVP;
|
||||||
|
|
||||||
// activate VP.
|
// activate VP.
|
||||||
driver->activeVertexProgram(_VertexProgram[idVP]);
|
driver->activeVertexProgram(_VertexProgram[idVP]);
|
||||||
|
|
||||||
|
|
||||||
|
// precompute mesh
|
||||||
|
setupPerMesh(driver, scene);
|
||||||
|
|
||||||
|
// Setup instance constants
|
||||||
|
setupPerInstanceConstants(driver, scene, mbi, invertedModelMat);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue