Fix regression from stereo branch in wind tree

This commit is contained in:
kaetemi 2013-09-14 18:58:23 +02:00
parent 60cd1f6116
commit adcb3e032b
4 changed files with 18 additions and 4 deletions

View file

@ -280,7 +280,8 @@ public:
*/ */
void changeLightSetup(CLightContribution *lightContribution, bool useLocalAttenuation); void changeLightSetup(CLightContribution *lightContribution, bool useLocalAttenuation);
/// Must call before beginVPLightSetup
void prepareVPLightSetup();
/** setup the driver VP constants to get info from current LightSetup. /** setup the driver VP constants to get info from current LightSetup.
* Only 0..3 Light + SunLights are supported. The VP do NOT support distance/Spot attenuation * Only 0..3 Light + SunLights are supported. The VP do NOT support distance/Spot attenuation
* Also it does not handle World Matrix with non uniform scale correctly since lighting is made in ObjectSpace * Also it does not handle World Matrix with non uniform scale correctly since lighting is made in ObjectSpace
@ -425,7 +426,7 @@ private:
// Current num of VP lights enabled. // Current num of VP lights enabled.
uint _VPNumLights; uint _VPNumLights;
// Current support of specular // Current support of specular
//bool _VPSupportSpecular; // bool _VPSupportSpecular;
// Sum of all ambiant of all lights + ambiantGlobal. // Sum of all ambiant of all lights + ambiantGlobal.
NLMISC::CRGBAF _VPFinalAmbient; NLMISC::CRGBAF _VPFinalAmbient;
// Diffuse/Spec comp of all light / 255. // Diffuse/Spec comp of all light / 255.

View file

@ -515,6 +515,7 @@ bool CMeshVPPerPixelLight::begin(IDriver *drv,
// //
CRenderTrav *renderTrav= &scene->getRenderTrav(); CRenderTrav *renderTrav= &scene->getRenderTrav();
/// Setup for gouraud lighting /// Setup for gouraud lighting
renderTrav->prepareVPLightSetup();
renderTrav->beginVPLightSetup(program, invertedModelMat); renderTrav->beginVPLightSetup(program, invertedModelMat);
// //
sint strongestLightIndex = renderTrav->getStrongestLightIndex(); sint strongestLightIndex = renderTrav->getStrongestLightIndex();

View file

@ -385,6 +385,8 @@ bool CMeshVPWindTree::begin(IDriver *driver, CScene *scene, CMeshBaseInstance *m
// Activate the good VertexProgram // Activate the good VertexProgram
//=============== //===============
// Update nb vp lights
renderTrav->prepareVPLightSetup();
// Get how many pointLights are setuped now. // Get how many pointLights are setuped now.
nlassert(scene != NULL); nlassert(scene != NULL);
@ -510,6 +512,9 @@ void CMeshVPWindTree::beginMBRMesh(IDriver *driver, CScene *scene)
// *************************************************************************** // ***************************************************************************
void CMeshVPWindTree::beginMBRInstance(IDriver *driver, CScene *scene, CMeshBaseInstance *mbi, const NLMISC::CMatrix &invertedModelMat) void CMeshVPWindTree::beginMBRInstance(IDriver *driver, CScene *scene, CMeshBaseInstance *mbi, const NLMISC::CMatrix &invertedModelMat)
{ {
// Update nb vp lights
renderTrav->prepareVPLightSetup();
// 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();

View file

@ -760,13 +760,20 @@ void CRenderTrav::changeLightSetup(CLightContribution *lightContribution, bool
// *************************************************************************** // ***************************************************************************
// *************************************************************************** // ***************************************************************************
void CRenderTrav::prepareVPLightSetup()
{
nlassert(MaxVPLight==4);
_VPNumLights= min(_NumLightEnabled, (uint)MaxVPLight);
// Must force real light setup at least the first time, in changeVPLightSetupMaterial()
_VPMaterialCacheDirty= true;
}
// *************************************************************************** // ***************************************************************************
void CRenderTrav::beginVPLightSetup(CVertexProgramLighted *program, const CMatrix &invObjectWM) void CRenderTrav::beginVPLightSetup(CVertexProgramLighted *program, const CMatrix &invObjectWM)
{ {
uint i; uint i;
nlassert(MaxVPLight==4); // nlassert(MaxVPLight==4);
_VPNumLights= min(_NumLightEnabled, (uint)MaxVPLight); // _VPNumLights= min(_NumLightEnabled, (uint)MaxVPLight);
// _VPCurrentCtStart= ctStart; // _VPCurrentCtStart= ctStart;
// _VPSupportSpecular= supportSpecular; // _VPSupportSpecular= supportSpecular;
_VPCurrent = program; _VPCurrent = program;