|
|
|
@ -21,8 +21,6 @@
|
|
|
|
|
#include "nel/3d/texture_bump.h"
|
|
|
|
|
#include "nel/3d/material.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace NL3D {
|
|
|
|
|
|
|
|
|
|
static void convBlend(CMaterial::TBlend blend, GLenum& glenum)
|
|
|
|
@ -86,7 +84,6 @@ static inline void convTexAddr(ITexture *tex, CMaterial::TTexAddressingMode mode
|
|
|
|
|
GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV, GL_DOT_PRODUCT_DEPTH_REPLACE_NV
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const GLenum glTexCubeAddrModesNV[] =
|
|
|
|
|
{
|
|
|
|
|
GL_NONE, GL_TEXTURE_CUBE_MAP_ARB, GL_PASS_THROUGH_NV, GL_CULL_FRAGMENT_NV,
|
|
|
|
@ -107,8 +104,6 @@ static inline void convTexAddr(ITexture *tex, CMaterial::TTexAddressingMode mode
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------
|
|
|
|
|
void CDriverGL::setTextureEnvFunction(uint stage, CMaterial& mat)
|
|
|
|
|
{
|
|
|
|
@ -152,7 +147,6 @@ void CDriverGL::setTextureEnvFunction(uint stage, CMaterial& mat)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------
|
|
|
|
|
void CDriverGL::setupUserTextureMatrix(uint numStages, CMaterial& mat)
|
|
|
|
|
{
|
|
|
|
@ -219,7 +213,6 @@ void CDriverGL::disableUserTextureMatrix()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------
|
|
|
|
|
CMaterial::TShader CDriverGL::getSupportedShader(CMaterial::TShader shader)
|
|
|
|
|
{
|
|
|
|
@ -235,9 +228,6 @@ CMaterial::TShader CDriverGL::getSupportedShader(CMaterial::TShader shader)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------
|
|
|
|
|
void CDriverGL::setTextureShaders(const uint8 *addressingModes, const CSmartPtr<ITexture> *textures)
|
|
|
|
|
{
|
|
|
|
@ -256,10 +246,7 @@ void CDriverGL::setTextureShaders(const uint8 *addressingModes, const CSmartPtr<
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------
|
|
|
|
|
|
|
|
|
|
bool CDriverGL::setupMaterial(CMaterial& mat)
|
|
|
|
|
{
|
|
|
|
|
H_AUTO_OGL(CDriverGL_setupMaterial)
|
|
|
|
@ -268,7 +255,6 @@ bool CDriverGL::setupMaterial(CMaterial& mat)
|
|
|
|
|
uint32 touched=mat.getTouched();
|
|
|
|
|
uint stage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// profile.
|
|
|
|
|
_NbSetupMaterialCall++;
|
|
|
|
|
|
|
|
|
@ -287,7 +273,6 @@ bool CDriverGL::setupMaterial(CMaterial& mat)
|
|
|
|
|
}
|
|
|
|
|
pShader=static_cast<CShaderGL*>((IMaterialDrvInfos*)(mat._MatDrvInfo));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1. Setup modified fields of material.
|
|
|
|
|
//=====================================
|
|
|
|
|
if( touched )
|
|
|
|
@ -329,7 +314,6 @@ bool CDriverGL::setupMaterial(CMaterial& mat)
|
|
|
|
|
pShader->SupportedShader= getSupportedShader(mat.getShader());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Since modified, must rebind all openGL states. And do this also for the delete/new problem.
|
|
|
|
|
/* If an old material is deleted, _CurrentMaterial is invalid. But this is grave only if a new
|
|
|
|
|
material is created, with the same pointer (bad luck). Since an newly allocated material always
|
|
|
|
@ -342,7 +326,6 @@ bool CDriverGL::setupMaterial(CMaterial& mat)
|
|
|
|
|
mat.clearTouched(0xFFFFFFFF);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Now we can get the supported shader from the cache.
|
|
|
|
|
CMaterial::TShader matShader = pShader->SupportedShader;
|
|
|
|
|
|
|
|
|
@ -417,7 +400,6 @@ bool CDriverGL::setupMaterial(CMaterial& mat)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. Bind OpenGL States.
|
|
|
|
|
//=======================
|
|
|
|
|
if (_CurrentMaterial!=&mat)
|
|
|
|
@ -446,7 +428,6 @@ bool CDriverGL::setupMaterial(CMaterial& mat)
|
|
|
|
|
_DriverGLStates.alphaFunc(mat.getAlphaTestThreshold());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Bind ZBuffer Part.
|
|
|
|
|
//===================
|
|
|
|
|
_DriverGLStates.enableZWrite(mat.getFlags()&IDRV_MAT_ZWRITE);
|
|
|
|
@ -526,7 +507,6 @@ bool CDriverGL::setupMaterial(CMaterial& mat)
|
|
|
|
|
_CurrentMaterial=&mat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 4. Misc
|
|
|
|
|
//=====================================
|
|
|
|
|
|
|
|
|
@ -547,7 +527,6 @@ bool CDriverGL::setupMaterial(CMaterial& mat)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
sint CDriverGL::beginMultiPass()
|
|
|
|
|
{
|
|
|
|
@ -574,6 +553,7 @@ sint CDriverGL::beginMultiPass()
|
|
|
|
|
default: return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CDriverGL::setupPass(uint pass)
|
|
|
|
|
{
|
|
|
|
@ -607,7 +587,6 @@ void CDriverGL::setupPass(uint pass)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CDriverGL::endMultiPass()
|
|
|
|
|
{
|
|
|
|
@ -640,7 +619,6 @@ void CDriverGL::endMultiPass()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CDriverGL::computeLightMapInfos (const CMaterial &mat)
|
|
|
|
|
{
|
|
|
|
@ -682,7 +660,6 @@ void CDriverGL::computeLightMapInfos (const CMaterial &mat)
|
|
|
|
|
// NB: _NLightMaps==0 means there is no lightmaps at all.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
sint CDriverGL::beginLightMapMultiPass ()
|
|
|
|
|
{
|
|
|
|
@ -714,13 +691,13 @@ sint CDriverGL::beginLightMapMultiPass ()
|
|
|
|
|
// Manage too if no lightmaps.
|
|
|
|
|
return std::max (_NLightMapPass, (uint)1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CDriverGL::setupLightMapPass(uint pass)
|
|
|
|
|
{
|
|
|
|
|
H_AUTO_OGL(CDriverGL_setupLightMapPass)
|
|
|
|
|
const CMaterial &mat= *_CurrentMaterial;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// common colors
|
|
|
|
|
static uint32 packedColorBlack= CRGBA(0,0,0,255).getPacked();
|
|
|
|
|
static GLfloat glcolBlack[4]= {0.f,0.f,0.f,1.f};
|
|
|
|
@ -759,7 +736,6 @@ void CDriverGL::setupLightMapPass(uint pass)
|
|
|
|
|
|
|
|
|
|
nlassert(pass<_NLightMapPass);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// setup Texture Pass.
|
|
|
|
|
//=========================
|
|
|
|
|
uint lmapId;
|
|
|
|
@ -953,7 +929,6 @@ void CDriverGL::setupLightMapPass(uint pass)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// setup blend / lighting.
|
|
|
|
|
//=========================
|
|
|
|
|
|
|
|
|
@ -1012,7 +987,6 @@ void CDriverGL::setupLightMapPass(uint pass)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Dynamic lighting: The influence of the dynamic light must be added only in the first pass (only one time)
|
|
|
|
|
if(pass==0)
|
|
|
|
|
{
|
|
|
|
@ -1026,6 +1000,7 @@ void CDriverGL::setupLightMapPass(uint pass)
|
|
|
|
|
else if(pass==1)
|
|
|
|
|
_DriverGLStates.setDiffuse(packedColorBlack, glcolBlack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CDriverGL::endLightMapMultiPass()
|
|
|
|
|
{
|
|
|
|
@ -1057,7 +1032,6 @@ void CDriverGL::endLightMapMultiPass()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CDriverGL::resetLightMapVertexSetup()
|
|
|
|
|
{
|
|
|
|
@ -1079,7 +1053,6 @@ void CDriverGL::resetLightMapVertexSetup()
|
|
|
|
|
_LastVertexSetupIsLightMap= false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CDriverGL::startSpecularBatch()
|
|
|
|
|
{
|
|
|
|
@ -1185,6 +1158,7 @@ sint CDriverGL::beginSpecularMultiPass()
|
|
|
|
|
else
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CDriverGL::setupSpecularPass(uint pass)
|
|
|
|
|
{
|
|
|
|
@ -1308,10 +1282,9 @@ void CDriverGL::setupSpecularPass(uint pass)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ // We have to do it in 2 passes
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
// We have to do it in 2 passes
|
|
|
|
|
// For Both Pass, setup correct Env.
|
|
|
|
|
|
|
|
|
|
if( pass == 0 )
|
|
|
|
|
{ // Just display the texture
|
|
|
|
|
_DriverGLStates.enableBlend(false);
|
|
|
|
@ -1333,7 +1306,6 @@ void CDriverGL::setupSpecularPass(uint pass)
|
|
|
|
|
|
|
|
|
|
activateTexEnvMode(0, env);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set stage 1
|
|
|
|
|
if( mat.getTexture(0) == NULL )
|
|
|
|
|
{
|
|
|
|
@ -1355,6 +1327,7 @@ void CDriverGL::setupSpecularPass(uint pass)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CDriverGL::endSpecularMultiPass()
|
|
|
|
|
{
|
|
|
|
@ -1364,7 +1337,6 @@ void CDriverGL::endSpecularMultiPass()
|
|
|
|
|
setupSpecularEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// a functor that can is used to generate a cube map used for specular / diffuse lighting
|
|
|
|
|
struct CSpecCubeMapFunctor : ICubeMapFunctor
|
|
|
|
|
{
|
|
|
|
@ -1380,13 +1352,11 @@ struct CSpecCubeMapFunctor : ICubeMapFunctor
|
|
|
|
|
float Exp;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* /// parameters for specular cube map generation
|
|
|
|
|
const uint MaxSpecularExp = 64;
|
|
|
|
|
const uint SpecularExpStep = 8;
|
|
|
|
|
const uint SpecularMapSize = 32; */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
CTextureCube *CDriverGL::getSpecularCubeMap(uint exp)
|
|
|
|
|
{
|
|
|
|
@ -1434,7 +1404,6 @@ CTextureCube *CDriverGL::getSpecularCubeMap(uint exp)
|
|
|
|
|
|
|
|
|
|
NLMISC::clamp(exp, 1u, (MaxExponent - 1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint cubeMapIndex = expToCubeMap[exp];
|
|
|
|
|
nlassert(cubeMapIndex < numCubeMap);
|
|
|
|
|
|
|
|
|
@ -1542,7 +1511,6 @@ void CDriverGL::setupPPLPass(uint pass)
|
|
|
|
|
|
|
|
|
|
// setup the tex envs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Stage 0 is rgb = DiffuseCubeMap * LightColor + DiffuseGouraud * 1
|
|
|
|
|
if(_CurrentTexEnvSpecial[0] != TexEnvSpecialPPLStage0)
|
|
|
|
|
{
|
|
|
|
@ -1591,8 +1559,6 @@ void CDriverGL::setupPPLPass(uint pass)
|
|
|
|
|
env.Env.SrcArg1Alpha = CMaterial::Diffuse;
|
|
|
|
|
activateTexEnvMode(1, env);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Stage 2 is rgb = SpecularCubeMap * SpecularLightColor + Prec * 1
|
|
|
|
|
// alpha = prec alpha
|
|
|
|
|
|
|
|
|
@ -1674,7 +1640,6 @@ void CDriverGL::endPPLMultiPass()
|
|
|
|
|
// nothing to do there ...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ******PER PIXEL LIGHTING, NO SPECULAR**************************************
|
|
|
|
|
sint CDriverGL::beginPPLNoSpecMultiPass()
|
|
|
|
|
{
|
|
|
|
@ -1704,7 +1669,6 @@ void CDriverGL::setupPPLNoSpecPass(uint pass)
|
|
|
|
|
activateTexture(0, tex0);
|
|
|
|
|
activateTexture(1, mat.getTexture(0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (uint k = 2; k < inlGetNumTextStages(); ++k)
|
|
|
|
|
{
|
|
|
|
|
activateTexture(k, NULL);
|
|
|
|
@ -1712,7 +1676,6 @@ void CDriverGL::setupPPLNoSpecPass(uint pass)
|
|
|
|
|
|
|
|
|
|
// setup the tex envs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Stage 0 is rgb = DiffuseCubeMap * LightColor + DiffuseGouraud * 1 (TODO : EnvCombine3)
|
|
|
|
|
if(_CurrentTexEnvSpecial[0] != TexEnvSpecialPPLStage0)
|
|
|
|
|
{
|
|
|
|
@ -1784,7 +1747,6 @@ void CDriverGL::endPPLNoSpecMultiPass()
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
/*inline void CDriverGL::setupCausticsFirstTex(const CMaterial &mat)
|
|
|
|
|
{
|
|
|
|
@ -1999,7 +1961,6 @@ void CDriverGL::endCloudMultiPass()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
sint CDriverGL::beginWaterMultiPass()
|
|
|
|
|
{
|
|
|
|
@ -2088,7 +2049,6 @@ void CDriverGL::setupWaterPassR200(const CMaterial &mat)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
/** water setup for ARB_fragment_program
|
|
|
|
|
*/
|
|
|
|
@ -2175,7 +2135,6 @@ void CDriverGL::setupWaterPassARB(const CMaterial &mat)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
/** Presetupped texture shader for water shader on NV20
|
|
|
|
|
*/
|
|
|
|
@ -2187,7 +2146,6 @@ static const uint8 WaterNoDiffuseTexAddrMode[IDRV_MAT_MAXTEXTURES] =
|
|
|
|
|
CMaterial::TextureOff
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const uint8 WaterTexAddrMode[IDRV_MAT_MAXTEXTURES] =
|
|
|
|
|
{
|
|
|
|
|
CMaterial::FetchTexture,
|
|
|
|
@ -2198,7 +2156,6 @@ static const uint8 WaterTexAddrMode[IDRV_MAT_MAXTEXTURES] =
|
|
|
|
|
|
|
|
|
|
static const float IdentityTexMat[4] = { 1.f, 0.f, 0.f, 1.f };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CDriverGL::setupWaterPassNV20(const CMaterial &mat)
|
|
|
|
|
{
|
|
|
|
|