From 8e9c69a56647b5e07928e7679b8ac75d61576adb Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 14 Sep 2013 18:58:23 +0200 Subject: [PATCH] Fix regression from stereo branch in wind tree --- code/nel/include/nel/3d/render_trav.h | 5 +++-- code/nel/src/3d/meshvp_per_pixel_light.cpp | 1 + code/nel/src/3d/meshvp_wind_tree.cpp | 5 +++++ code/nel/src/3d/render_trav.cpp | 11 +++++++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/code/nel/include/nel/3d/render_trav.h b/code/nel/include/nel/3d/render_trav.h index 61d62e94c..d50d2c242 100644 --- a/code/nel/include/nel/3d/render_trav.h +++ b/code/nel/include/nel/3d/render_trav.h @@ -280,7 +280,8 @@ public: */ void changeLightSetup(CLightContribution *lightContribution, bool useLocalAttenuation); - + /// Must call before beginVPLightSetup + void prepareVPLightSetup(); /** 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 * 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. uint _VPNumLights; // Current support of specular - //bool _VPSupportSpecular; + // bool _VPSupportSpecular; // Sum of all ambiant of all lights + ambiantGlobal. NLMISC::CRGBAF _VPFinalAmbient; // Diffuse/Spec comp of all light / 255. diff --git a/code/nel/src/3d/meshvp_per_pixel_light.cpp b/code/nel/src/3d/meshvp_per_pixel_light.cpp index 68db4a3e6..816c20f3b 100644 --- a/code/nel/src/3d/meshvp_per_pixel_light.cpp +++ b/code/nel/src/3d/meshvp_per_pixel_light.cpp @@ -515,6 +515,7 @@ bool CMeshVPPerPixelLight::begin(IDriver *drv, // CRenderTrav *renderTrav= &scene->getRenderTrav(); /// Setup for gouraud lighting + renderTrav->prepareVPLightSetup(); renderTrav->beginVPLightSetup(program, invertedModelMat); // sint strongestLightIndex = renderTrav->getStrongestLightIndex(); diff --git a/code/nel/src/3d/meshvp_wind_tree.cpp b/code/nel/src/3d/meshvp_wind_tree.cpp index e991df44b..3ae8c1cd5 100644 --- a/code/nel/src/3d/meshvp_wind_tree.cpp +++ b/code/nel/src/3d/meshvp_wind_tree.cpp @@ -385,6 +385,8 @@ bool CMeshVPWindTree::begin(IDriver *driver, CScene *scene, CMeshBaseInstance *m // Activate the good VertexProgram //=============== + // Update nb vp lights + renderTrav->prepareVPLightSetup(); // Get how many pointLights are setuped now. 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) { + // Update nb vp lights + renderTrav->prepareVPLightSetup(); + // Get how many pointLights are setuped now. nlassert(scene != NULL); CRenderTrav *renderTrav= &scene->getRenderTrav(); diff --git a/code/nel/src/3d/render_trav.cpp b/code/nel/src/3d/render_trav.cpp index a13095db9..e7dfe89b1 100644 --- a/code/nel/src/3d/render_trav.cpp +++ b/code/nel/src/3d/render_trav.cpp @@ -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) { uint i; - nlassert(MaxVPLight==4); - _VPNumLights= min(_NumLightEnabled, (uint)MaxVPLight); + // nlassert(MaxVPLight==4); + // _VPNumLights= min(_NumLightEnabled, (uint)MaxVPLight); // _VPCurrentCtStart= ctStart; // _VPSupportSpecular= supportSpecular; _VPCurrent = program;