mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-21 00:18:43 +00:00
Add container for lighted vertex program
--HG-- branch : multipass-stereo
This commit is contained in:
parent
ab231ea700
commit
a72f25e763
4 changed files with 91 additions and 6 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "nel/3d/mesh_block_manager.h"
|
||||
#include "nel/3d/shadow_map_manager.h"
|
||||
#include "nel/3d/u_scene.h"
|
||||
#include "nel/3d/vertex_program.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
@ -68,6 +69,41 @@ class CWaterModel;
|
|||
#define NL3D_SHADOW_MESH_SKIN_MANAGER_MAXVERTICES 3000
|
||||
#define NL3D_SHADOW_MESH_SKIN_MANAGER_NUMVB 8
|
||||
|
||||
/// Container for lighted vertex program.
|
||||
class CVertexProgramLighted : CVertexProgram
|
||||
{
|
||||
public:
|
||||
static const uint MaxLight = 4;
|
||||
static const uint MaxPointLight = (MaxLight - 1);
|
||||
struct CIdxLighted
|
||||
{
|
||||
uint Ambient;
|
||||
uint Diffuse[MaxLight];
|
||||
uint Specular[MaxLight];
|
||||
uint DirOrPos[MaxLight]; // light 0, directional sun; light 1,2,3, omni point light
|
||||
uint EyePosition;
|
||||
uint DiffuseAlpha;
|
||||
};
|
||||
struct CFeaturesLighted
|
||||
{
|
||||
/// Number of point lights that this program is generated for, varies from 0 to 3.
|
||||
uint NumActivePointLights;
|
||||
bool SupportSpecular;
|
||||
bool Normalize;
|
||||
/// Start of constants to use for lighting with assembly shaders.
|
||||
uint CtStartNeLVP;
|
||||
};
|
||||
CVertexProgramLighted() { }
|
||||
virtual ~CVertexProgramLighted() { }
|
||||
virtual void buildInfo();
|
||||
const CIdxLighted &idxLighted() const { return m_IdxLighted; }
|
||||
const CFeaturesLighted &featuresLighted() const { return m_FeaturesLighted; }
|
||||
|
||||
private:
|
||||
CIdxLighted m_IdxLighted;
|
||||
CFeaturesLighted m_FeaturesLighted;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
|
@ -224,7 +260,7 @@ public:
|
|||
// @{
|
||||
|
||||
// Max VP Light setup Infos.
|
||||
enum {MaxVPLight= 4};
|
||||
enum {MaxVPLight = CVertexProgramLighted::MaxLight};
|
||||
|
||||
/** reset the lighting setup in the driver (all lights are disabled).
|
||||
* called at beginning of traverse(). Must be called by any model (before and after rendering)
|
||||
|
@ -299,7 +335,8 @@ public:
|
|||
* \param numActivePoinLights tells how many point light from 0 to 3 this VP must handle. NB: the Sun directionnal is not option
|
||||
* NB: nlassert(numActiveLights<=MaxVPLight-1).
|
||||
*/
|
||||
static std::string getLightVPFragment(uint numActivePointLights, uint ctStart, bool supportSpecular, bool normalize);
|
||||
static std::string getLightVPFragmentNeLVP(uint numActivePointLights, uint ctStart, bool supportSpecular, bool normalize);
|
||||
// TODO_VP_GLSL
|
||||
|
||||
/** This returns a reference to a driver light, by its index
|
||||
* \see getStrongestLightIndex
|
||||
|
|
|
@ -393,10 +393,10 @@ void CMeshVPPerPixelLight::initInstance(CMeshBaseInstance *mbi)
|
|||
for (uint vp = 0; vp < NumVp; ++vp)
|
||||
{
|
||||
// \todo yoyo TODO_OPTIM Manage different number of pointLights
|
||||
// NB: never call getLightVPFragment() with normalize, because already done by PerPixel fragment before.
|
||||
// NB: never call getLightVPFragmentNeLVP() with normalize, because already done by PerPixel fragment before.
|
||||
std::string vpCode = std::string(vpName[vp])
|
||||
+ std::string("# ***************") // temp for debug
|
||||
+ CRenderTrav::getLightVPFragment(CRenderTrav::MaxVPLight-1, VPLightConstantStart, (vp & 2) != 0, false)
|
||||
+ CRenderTrav::getLightVPFragmentNeLVP(CRenderTrav::MaxVPLight-1, VPLightConstantStart, (vp & 2) != 0, false)
|
||||
+ std::string("# ***************") // temp for debug
|
||||
+ std::string(PPLightingVPCodeEnd);
|
||||
#ifdef NL_DEBUG
|
||||
|
|
|
@ -155,7 +155,7 @@ void CMeshVPWindTree::initInstance(CMeshBaseInstance *mbi)
|
|||
|
||||
// combine fragments
|
||||
vpCode= string(WindTreeVPCodeWave)
|
||||
+ CRenderTrav::getLightVPFragment(numPls, VPLightConstantStart, specular, normalize)
|
||||
+ CRenderTrav::getLightVPFragmentNeLVP(numPls, VPLightConstantStart, specular, normalize)
|
||||
+ WindTreeVPCodeEnd;
|
||||
_VertexProgram[i] = new CVertexProgram(vpCode.c_str());
|
||||
// TODO_VP_GLSL
|
||||
|
|
|
@ -1168,8 +1168,56 @@ static void strReplaceAll(string &strInOut, const string &tokenSrc, const string
|
|||
}
|
||||
}
|
||||
|
||||
void CVertexProgramLighted::buildInfo()
|
||||
{
|
||||
if (m_FeaturesLighted.CtStartNeLVP != ~0)
|
||||
{
|
||||
// Fixed uniform locations
|
||||
m_IdxLighted.Ambient = 0;
|
||||
for (uint i = 0; i < MaxLight; ++i)
|
||||
{
|
||||
m_IdxLighted.Diffuse[i] = 1 + i;
|
||||
}
|
||||
if (m_FeaturesLighted.SupportSpecular)
|
||||
{
|
||||
for (uint i = 0; i < MaxLight; ++i)
|
||||
{
|
||||
m_IdxLighted.Specular[i] = 5 + i;
|
||||
}
|
||||
m_IdxLighted.DirOrPos[0] = 9;
|
||||
for (uint i = 1; i < MaxLight; ++i)
|
||||
{
|
||||
m_IdxLighted.DirOrPos[i] = (12 - 1) + i;
|
||||
}
|
||||
m_IdxLighted.DiffuseAlpha = 10;
|
||||
m_IdxLighted.EyePosition = 11;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint i = 0; i < MaxLight; ++i)
|
||||
{
|
||||
m_IdxLighted.Specular[i] = ~0;
|
||||
}
|
||||
for (uint i = 0; i < MaxLight; ++i)
|
||||
{
|
||||
m_IdxLighted.DirOrPos[i] = 5 + i;
|
||||
}
|
||||
m_IdxLighted.DiffuseAlpha = 9;
|
||||
m_IdxLighted.EyePosition = ~0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Named uniform locations
|
||||
// TODO_VP_GLSL
|
||||
// m_IdxLighted.Ambient = getUniformIndex("ambient");
|
||||
// etc
|
||||
}
|
||||
}
|
||||
|
||||
// generates the lighting part of a vertex program, nelvp profile
|
||||
// ***************************************************************************
|
||||
std::string CRenderTrav::getLightVPFragment(uint numActivePointLights, uint ctStart, bool supportSpecular, bool normalize)
|
||||
std::string CRenderTrav::getLightVPFragmentNeLVP(uint numActivePointLights, uint ctStart, bool supportSpecular, bool normalize)
|
||||
{
|
||||
string ret;
|
||||
|
||||
|
|
Loading…
Reference in a new issue