Cleanup
This commit is contained in:
parent
881949a5d7
commit
291c5d6012
3 changed files with 32 additions and 19 deletions
|
@ -55,15 +55,18 @@ static const char *TextureOffset =
|
||||||
END \n";
|
END \n";
|
||||||
|
|
||||||
|
|
||||||
static CVertexProgram TextureOffsetVertexProgram(TextureOffset);
|
static NLMISC::CSmartPtr<CVertexProgram> TextureOffsetVertexProgram;
|
||||||
|
|
||||||
// TODO_VP_GLSL
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
CBloomEffect::CBloomEffect()
|
CBloomEffect::CBloomEffect()
|
||||||
{
|
{
|
||||||
|
if (!TextureOffsetVertexProgram)
|
||||||
|
{
|
||||||
|
TextureOffsetVertexProgram = new CVertexProgram(TextureOffset);
|
||||||
|
}
|
||||||
|
|
||||||
_Driver = NULL;
|
_Driver = NULL;
|
||||||
_Scene = NULL;
|
_Scene = NULL;
|
||||||
_SquareBloom = true;
|
_SquareBloom = true;
|
||||||
|
@ -445,7 +448,7 @@ void CBloomEffect::applyBlur()
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize vertex program
|
// initialize vertex program
|
||||||
drvInternal->activeVertexProgram(&TextureOffsetVertexProgram);
|
drvInternal->activeVertexProgram(TextureOffsetVertexProgram);
|
||||||
drvInternal->setUniform4f(IDriver::VertexProgram, 8, 255.f, 255.f, 255.f, 255.f);
|
drvInternal->setUniform4f(IDriver::VertexProgram, 8, 255.f, 255.f, 255.f, 255.f);
|
||||||
drvInternal->setUniform4f(IDriver::VertexProgram, 9, 0.0f, 0.f, 0.f, 1.f);
|
drvInternal->setUniform4f(IDriver::VertexProgram, 9, 0.0f, 0.f, 0.f, 1.f);
|
||||||
|
|
||||||
|
@ -551,7 +554,7 @@ void CBloomEffect::doBlur(bool horizontalBlur)
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize vertex program
|
// initialize vertex program
|
||||||
drvInternal->activeVertexProgram(&TextureOffsetVertexProgram);
|
drvInternal->activeVertexProgram(TextureOffsetVertexProgram);
|
||||||
drvInternal->setUniform4f(IDriver::VertexProgram, 8, 255.f, 255.f, 255.f, 255.f);
|
drvInternal->setUniform4f(IDriver::VertexProgram, 8, 255.f, 255.f, 255.f, 255.f);
|
||||||
drvInternal->setUniform4f(IDriver::VertexProgram, 9, 0.0f, 0.f, 0.f, 1.f);
|
drvInternal->setUniform4f(IDriver::VertexProgram, 9, 0.0f, 0.f, 0.f, 1.f);
|
||||||
|
|
||||||
|
|
|
@ -274,13 +274,18 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static CVertexProgramTestMeshVP testMeshVP;
|
static NLMISC::CSmartPtr<CVertexProgramTestMeshVP> testMeshVP;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// *******************************************************************************
|
// *******************************************************************************
|
||||||
void CWaterEnvMap::renderTestMesh(IDriver &driver)
|
void CWaterEnvMap::renderTestMesh(IDriver &driver)
|
||||||
{
|
{
|
||||||
|
if (!testMeshVP)
|
||||||
|
{
|
||||||
|
testMeshVP = new CVertexProgramTestMeshVP();
|
||||||
|
}
|
||||||
|
|
||||||
doInit();
|
doInit();
|
||||||
CMaterial testMat;
|
CMaterial testMat;
|
||||||
testMat.setLighting(false);
|
testMat.setLighting(false);
|
||||||
|
@ -294,12 +299,12 @@ void CWaterEnvMap::renderTestMesh(IDriver &driver)
|
||||||
testMat.setZWrite(false);
|
testMat.setZWrite(false);
|
||||||
testMat.setZFunc(CMaterial::always);
|
testMat.setZFunc(CMaterial::always);
|
||||||
// tmp : test cubemap
|
// tmp : test cubemap
|
||||||
driver.activeVertexProgram(&testMeshVP);
|
driver.activeVertexProgram(testMeshVP);
|
||||||
driver.activeVertexBuffer(_TestVB);
|
driver.activeVertexBuffer(_TestVB);
|
||||||
driver.activeIndexBuffer(_TestIB);
|
driver.activeIndexBuffer(_TestIB);
|
||||||
_MaterialPassThruZTest.setTexture(0, _EnvCubic);
|
_MaterialPassThruZTest.setTexture(0, _EnvCubic);
|
||||||
driver.setUniformMatrix(IDriver::VertexProgram, testMeshVP.getUniformIndex(CGPUProgramIndex::ModelViewProjection), IDriver::ModelViewProjection, IDriver::Identity);
|
driver.setUniformMatrix(IDriver::VertexProgram, testMeshVP->getUniformIndex(CGPUProgramIndex::ModelViewProjection), IDriver::ModelViewProjection, IDriver::Identity);
|
||||||
driver.setUniform2f(IDriver::VertexProgram, testMeshVP.idx().ProgramConstant0, 2.f, 1.f);
|
driver.setUniform2f(IDriver::VertexProgram, testMeshVP->idx().ProgramConstant0, 2.f, 1.f);
|
||||||
//driver.renderTriangles(testMat, 0, TEST_VB_NUM_TRIS);
|
//driver.renderTriangles(testMat, 0, TEST_VB_NUM_TRIS);
|
||||||
driver.renderTriangles(_MaterialPassThruZTest, 0, TEST_VB_NUM_TRIS);
|
driver.renderTriangles(_MaterialPassThruZTest, 0, TEST_VB_NUM_TRIS);
|
||||||
driver.activeVertexProgram(NULL);
|
driver.activeVertexProgram(NULL);
|
||||||
|
|
|
@ -142,7 +142,7 @@ private:
|
||||||
CIdx m_Idx;
|
CIdx m_Idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
static CVertexProgramDecalAttenuation DecalAttenuationVertexProgram;
|
static NLMISC::CSmartPtr<CVertexProgramDecalAttenuation> DecalAttenuationVertexProgram;
|
||||||
|
|
||||||
|
|
||||||
typedef CShadowPolyReceiver::CRGBAVertex CRGBAVertex;
|
typedef CShadowPolyReceiver::CRGBAVertex CRGBAVertex;
|
||||||
|
@ -150,6 +150,10 @@ typedef CShadowPolyReceiver::CRGBAVertex CRGBAVertex;
|
||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
CDecal::CDecal()
|
CDecal::CDecal()
|
||||||
{
|
{
|
||||||
|
if (!DecalAttenuationVertexProgram)
|
||||||
|
{
|
||||||
|
DecalAttenuationVertexProgram = new CVertexProgramDecalAttenuation();
|
||||||
|
}
|
||||||
_ShadowMap = new CShadowMap(&(((CSceneUser *) Scene)->getScene().getRenderTrav().getShadowMapManager()));
|
_ShadowMap = new CShadowMap(&(((CSceneUser *) Scene)->getScene().getRenderTrav().getShadowMapManager()));
|
||||||
_Material.initUnlit();
|
_Material.initUnlit();
|
||||||
_Diffuse = CRGBA::White;
|
_Diffuse = CRGBA::White;
|
||||||
|
@ -361,6 +365,7 @@ void CDecal::renderTriCache(NL3D::IDriver &drv, NL3D::CShadowPolyReceiver &/*
|
||||||
drv.setupModelMatrix(modelMat);
|
drv.setupModelMatrix(modelMat);
|
||||||
if (useVertexProgram)
|
if (useVertexProgram)
|
||||||
{
|
{
|
||||||
|
CVertexProgramDecalAttenuation *program = DecalAttenuationVertexProgram;
|
||||||
{
|
{
|
||||||
CVertexBufferReadWrite vba;
|
CVertexBufferReadWrite vba;
|
||||||
_VB.setNumVertices((uint32)_TriCache.size());
|
_VB.setNumVertices((uint32)_TriCache.size());
|
||||||
|
@ -368,16 +373,16 @@ void CDecal::renderTriCache(NL3D::IDriver &drv, NL3D::CShadowPolyReceiver &/*
|
||||||
memcpy(vba.getVertexCoordPointer(), &_TriCache[0], sizeof(CRGBAVertex) * _TriCache.size());
|
memcpy(vba.getVertexCoordPointer(), &_TriCache[0], sizeof(CRGBAVertex) * _TriCache.size());
|
||||||
}
|
}
|
||||||
drv.activeVertexBuffer(_VB);
|
drv.activeVertexBuffer(_VB);
|
||||||
drv.setUniformMatrix(IDriver::VertexProgram, DecalAttenuationVertexProgram.getUniformIndex(CGPUProgramIndex::ModelViewProjection), NL3D::IDriver::ModelViewProjection, NL3D::IDriver::Identity);
|
drv.setUniformMatrix(IDriver::VertexProgram, program->getUniformIndex(CGPUProgramIndex::ModelViewProjection), NL3D::IDriver::ModelViewProjection, NL3D::IDriver::Identity);
|
||||||
drv.setUniform4f(IDriver::VertexProgram, DecalAttenuationVertexProgram.idx().WorldToUV0, _WorldToUVMatrix[0][0], _WorldToUVMatrix[1][0], _WorldToUVMatrix[2][0], _WorldToUVMatrix[3][0]);
|
drv.setUniform4f(IDriver::VertexProgram, program->idx().WorldToUV0, _WorldToUVMatrix[0][0], _WorldToUVMatrix[1][0], _WorldToUVMatrix[2][0], _WorldToUVMatrix[3][0]);
|
||||||
drv.setUniform4f(IDriver::VertexProgram, DecalAttenuationVertexProgram.idx().WorldToUV1, _WorldToUVMatrix[0][1], _WorldToUVMatrix[1][1], _WorldToUVMatrix[2][1], _WorldToUVMatrix[3][1]);
|
drv.setUniform4f(IDriver::VertexProgram, program->idx().WorldToUV1, _WorldToUVMatrix[0][1], _WorldToUVMatrix[1][1], _WorldToUVMatrix[2][1], _WorldToUVMatrix[3][1]);
|
||||||
drv.setUniform4f(IDriver::VertexProgram, DecalAttenuationVertexProgram.idx().Diffuse, _Diffuse.R * (1.f / 255.f), _Diffuse.G * (1.f / 255.f), _Diffuse.B * (1.f / 255.f), 1.f);
|
drv.setUniform4f(IDriver::VertexProgram, program->idx().Diffuse, _Diffuse.R * (1.f / 255.f), _Diffuse.G * (1.f / 255.f), _Diffuse.B * (1.f / 255.f), 1.f);
|
||||||
const NLMISC::CVector &camPos = MainCam.getMatrix().getPos();
|
const NLMISC::CVector &camPos = MainCam.getMatrix().getPos();
|
||||||
drv.setUniform4f(IDriver::VertexProgram, DecalAttenuationVertexProgram.idx().RefCamDist, camPos.x - _RefPosition.x, camPos.y - _RefPosition.y, camPos.z - _RefPosition.z, 1.f);
|
drv.setUniform4f(IDriver::VertexProgram, program->idx().RefCamDist, camPos.x - _RefPosition.x, camPos.y - _RefPosition.y, camPos.z - _RefPosition.z, 1.f);
|
||||||
// bottom & top blend
|
// bottom & top blend
|
||||||
float bottomBlendScale = 1.f / favoid0(_BottomBlendZMax - _BottomBlendZMin);
|
float bottomBlendScale = 1.f / favoid0(_BottomBlendZMax - _BottomBlendZMin);
|
||||||
float topBlendScale = 1.f / favoid0(_TopBlendZMin - _TopBlendZMax);
|
float topBlendScale = 1.f / favoid0(_TopBlendZMin - _TopBlendZMax);
|
||||||
drv.setUniform4f(IDriver::VertexProgram, DecalAttenuationVertexProgram.idx().BlendScale, bottomBlendScale, bottomBlendScale * (_RefPosition.z - _BottomBlendZMin),
|
drv.setUniform4f(IDriver::VertexProgram, program->idx().BlendScale, bottomBlendScale, bottomBlendScale * (_RefPosition.z - _BottomBlendZMin),
|
||||||
topBlendScale, topBlendScale * (_RefPosition.z - _TopBlendZMax));
|
topBlendScale, topBlendScale * (_RefPosition.z - _TopBlendZMax));
|
||||||
//
|
//
|
||||||
static volatile bool wantSimpleMat = false;
|
static volatile bool wantSimpleMat = false;
|
||||||
|
@ -618,11 +623,11 @@ void CDecalRenderList::renderAllDecals()
|
||||||
NL3D::IDriver *drvInternal = ((CDriverUser *) Driver)->getDriver();
|
NL3D::IDriver *drvInternal = ((CDriverUser *) Driver)->getDriver();
|
||||||
//
|
//
|
||||||
static volatile bool forceNoVertexProgram = false;
|
static volatile bool forceNoVertexProgram = false;
|
||||||
if (!forceNoVertexProgram && drvInternal->compileVertexProgram(&DecalAttenuationVertexProgram))
|
if (!forceNoVertexProgram && drvInternal->compileVertexProgram(DecalAttenuationVertexProgram))
|
||||||
{
|
{
|
||||||
drvInternal->activeVertexProgram(&DecalAttenuationVertexProgram);
|
drvInternal->activeVertexProgram(DecalAttenuationVertexProgram);
|
||||||
//drvInternal->setCons/tantMatrix(0, NL3D::IDriver::ModelViewProjection, NL3D::IDriver::Identity);
|
//drvInternal->setCons/tantMatrix(0, NL3D::IDriver::ModelViewProjection, NL3D::IDriver::Identity);
|
||||||
drvInternal->setUniform4f(IDriver::VertexProgram, DecalAttenuationVertexProgram.idx().DistScaleBias, _DistScale, _DistBias, 0.f, 1.f);
|
drvInternal->setUniform4f(IDriver::VertexProgram, DecalAttenuationVertexProgram->idx().DistScaleBias, _DistScale, _DistBias, 0.f, 1.f);
|
||||||
useVertexProgram = true;
|
useVertexProgram = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue