|
|
|
@ -32,14 +32,13 @@
|
|
|
|
|
|
|
|
|
|
namespace NL3D
|
|
|
|
|
{
|
|
|
|
|
NLMISC::CSmartPtr<CVertexProgram> CMeshVPPerPixelLight::_VertexProgram[NumVp];
|
|
|
|
|
|
|
|
|
|
NLMISC::CSmartPtr<CVertexProgramPerPixelLight> CMeshVPPerPixelLight::_VertexProgram[NumVp];
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
// Light VP fragment constants start at 24
|
|
|
|
|
static const uint VPLightConstantStart = 24;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
|
@ -355,18 +354,33 @@ static const char* PPLightingVPCodeTest =
|
|
|
|
|
";
|
|
|
|
|
***************************************************************/
|
|
|
|
|
|
|
|
|
|
class CVertexProgramPerPixelLight : public CVertexProgramLighted
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
class CIdx
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
CVertexProgramPerPixelLight(uint vp);
|
|
|
|
|
virtual ~CVertexProgramPerPixelLight() { };
|
|
|
|
|
virtual void buildInfo();
|
|
|
|
|
const CIdx &idx() const { return m_Idx; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
CIdx m_Idx;
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
|
void CMeshVPPerPixelLight::initInstance(CMeshBaseInstance *mbi)
|
|
|
|
|
{
|
|
|
|
|
// init the vertexProgram code.
|
|
|
|
|
static bool vpCreated= false;
|
|
|
|
|
if (!vpCreated)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CVertexProgramPerPixelLight::CVertexProgramPerPixelLight(uint vp)
|
|
|
|
|
{
|
|
|
|
|
vpCreated= true;
|
|
|
|
|
// lighted settings
|
|
|
|
|
m_FeaturesLighted.SupportSpecular = (vp & 2) != 0;
|
|
|
|
|
m_FeaturesLighted.NumActivePointLights = MaxLight - 1;
|
|
|
|
|
m_FeaturesLighted.Normalize = false;
|
|
|
|
|
m_FeaturesLighted.CtStartNeLVP = VPLightConstantStart;
|
|
|
|
|
|
|
|
|
|
// nelvp
|
|
|
|
|
{
|
|
|
|
|
// Gives each vp name
|
|
|
|
|
// Bit 0 : 1 when it is a directionnal light
|
|
|
|
|
// Bit 1 : 1 when specular is needed
|
|
|
|
@ -389,14 +403,17 @@ void CMeshVPPerPixelLight::initInstance(CMeshBaseInstance *mbi)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
uint numvp = sizeof(vpName) / sizeof(const char *);
|
|
|
|
|
nlassert(NumVp == numvp); // make sure that it is in sync with header..todo : compile time assert :)
|
|
|
|
|
for (uint vp = 0; vp < NumVp; ++vp)
|
|
|
|
|
{
|
|
|
|
|
nlassert(CMeshVPPerPixelLight::NumVp == numvp); // make sure that it is in sync with header..todo : compile time assert :)
|
|
|
|
|
|
|
|
|
|
// \todo yoyo TODO_OPTIM Manage different number of pointLights
|
|
|
|
|
// 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::getLightVPFragmentNeLVP(CRenderTrav::MaxVPLight-1, VPLightConstantStart, (vp & 2) != 0, false)
|
|
|
|
|
+ CRenderTrav::getLightVPFragmentNeLVP(
|
|
|
|
|
m_FeaturesLighted.NumActivePointLights,
|
|
|
|
|
m_FeaturesLighted.CtStartNeLVP,
|
|
|
|
|
m_FeaturesLighted.SupportSpecular,
|
|
|
|
|
m_FeaturesLighted.Normalize)
|
|
|
|
|
+ std::string("# ***************") // temp for debug
|
|
|
|
|
+ std::string(PPLightingVPCodeEnd);
|
|
|
|
|
#ifdef NL_DEBUG
|
|
|
|
@ -414,9 +431,39 @@ void CMeshVPPerPixelLight::initInstance(CMeshBaseInstance *mbi)
|
|
|
|
|
nlassert(0);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
_VertexProgram[vp] = new CVertexProgram(vpCode.c_str());
|
|
|
|
|
|
|
|
|
|
CSource *source = new CSource();
|
|
|
|
|
source->DisplayName = NLMISC::toString("nelvp/MeshVPPerPixel/%i", vp);
|
|
|
|
|
source->Profile = CVertexProgram::nelvp;
|
|
|
|
|
source->setSource(vpCode);
|
|
|
|
|
addSource(source);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// glsl
|
|
|
|
|
{
|
|
|
|
|
// TODO_VP_GLSL
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CVertexProgramPerPixelLight::buildInfo()
|
|
|
|
|
{
|
|
|
|
|
CVertexProgramLighted::buildInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
|
void CMeshVPPerPixelLight::initInstance(CMeshBaseInstance *mbi)
|
|
|
|
|
{
|
|
|
|
|
// init the vertexProgram code.
|
|
|
|
|
static bool vpCreated= false;
|
|
|
|
|
if (!vpCreated)
|
|
|
|
|
{
|
|
|
|
|
vpCreated = true;
|
|
|
|
|
|
|
|
|
|
for (uint vp = 0; vp < NumVp; ++vp)
|
|
|
|
|
{
|
|
|
|
|
_VertexProgram[vp] = new CVertexProgramPerPixelLight(vp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -521,7 +568,7 @@ void CMeshVPPerPixelLight::enable(bool enabled, IDriver *drv)
|
|
|
|
|
| (SpecularLighting ? 2 : 0)
|
|
|
|
|
| (_IsPointLight ? 1 : 0);
|
|
|
|
|
//
|
|
|
|
|
drv->activeVertexProgram(_VertexProgram[idVP]);
|
|
|
|
|
drv->activeVertexProgram((CVertexProgramPerPixelLight *)_VertexProgram[idVP]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|