diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl.cpp index d051cb9e8..59df7d526 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl.cpp @@ -249,7 +249,6 @@ CDriverGL3::CDriverGL3() _ForceDXTCCompression= false; _ForceTextureResizePower= 0; - _ForceNativeFragmentPrograms = true; _SumTextureMemoryUsed = false; @@ -279,12 +278,6 @@ CDriverGL3::CDriverGL3() _LightMapLastStageEnv.Env.SrcArg0Alpha= CMaterial::Texture; _LightMapLastStageEnv.Env.OpArg0Alpha= CMaterial::SrcAlpha; - ATIWaterShaderHandleNoDiffuseMap = 0; - ATIWaterShaderHandle = 0; - ATICloudShaderHandle = 0; - - std::fill(ARBWaterShader, ARBWaterShader + 4, 0); - /// buildCausticCubeMapTex(); _SpecularBatchOn= false; @@ -452,10 +445,6 @@ bool CDriverGL3::setupDisplay() //=========================================================== initEMBM(); - // Init fragment shaders if present - //=========================================================== - initFragmentShaders(); - // Activate the default texture environnments for all stages. //=========================================================== for(uint stage=0;stagegetShader() == CMaterial::Cloud); - if (ATICloudShaderHandle) - glDisable(GL_FRAGMENT_SHADER_ATI); } // *************************************************************************** @@ -1671,93 +1621,34 @@ sint CDriverGL3::beginWaterMultiPass() return 1; } - // *************************************************************************** -/** water setup for ATI +/** Presetupped texture shader for water shader on NV20 */ -void CDriverGL3::setupWaterPassR200(const CMaterial &mat) +static const uint8 WaterNoDiffuseTexAddrMode[IDRV_MAT_MAXTEXTURES] = { - H_AUTO_OGL(CDriverGL3_setupWaterPassR200); + CMaterial::FetchTexture, + CMaterial::OffsetTexture, + CMaterial::OffsetTexture, + CMaterial::TextureOff +}; - uint k; - ITexture *tex = mat.getTexture(0); - if (tex) - { -// if (tex->isBumpMap()) -// { -// CTextureBump *tb = static_cast(tex); -// } - setupTexture(*tex); - activateTexture(0, tex); - } - tex = mat.getTexture(1); - if (tex) - { -// if (tex->isBumpMap()) -// { -// CTextureBump *tb = static_cast(tex); -// } - setupTexture(*tex); - activateTexture(1, tex); - } - tex = mat.getTexture(2); - if (tex) - { - setupTexture(*tex); - activateTexture(2, tex); - } - tex = mat.getTexture(3); - if (tex) - { - setupTexture(*tex); - activateTexture(3, tex); - } - for (k = 4; k < inlGetNumTextStages(); ++k) - { - activateTexture(k, NULL); - } - if (mat.getTexture(3) != NULL) // is there a diffuse map ? - { - nglBindFragmentShaderATI(ATIWaterShaderHandle); - } - else - { - nglBindFragmentShaderATI(ATIWaterShaderHandleNoDiffuseMap); - } - glEnable(GL_FRAGMENT_SHADER_ATI); +static const uint8 WaterTexAddrMode[IDRV_MAT_MAXTEXTURES] = +{ + CMaterial::FetchTexture, + CMaterial::OffsetTexture, + CMaterial::OffsetTexture, + CMaterial::FetchTexture +}; - // set constants - if (mat.getTexture(0) && mat.getTexture(0)->isBumpMap()) - { - float factor = NLMISC::safe_cast(mat.getTexture(0))->getNormalizationFactor(); - float cst[4] = { factor, factor, factor, 0.f }; - nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst); - } - else - { - float cst[4] = { 1.f, 1.f, 1.f, 0.f }; - nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst); - } - // - if (mat.getTexture(1) && mat.getTexture(1)->isBumpMap()) - { - float factor = NLMISC::safe_cast(mat.getTexture(1))->getNormalizationFactor(); - float cst[4] = { factor, factor, factor, 0.f }; - nglSetFragmentShaderConstantATI(GL_CON_1_ATI, cst); - } - else - { - float cst[4] = { 1.f, 1.f, 1.f, 0.f }; - nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst); - } -} +static const float IdentityTexMat[4] = { 1.f, 0.f, 0.f, 1.f }; // *************************************************************************** -/** water setup for ARB_fragment_program - */ -void CDriverGL3::setupWaterPassARB(const CMaterial &mat) +void CDriverGL3::setupWaterPass(uint /* pass */) { - H_AUTO_OGL(CDriverGL3_setupWaterPassARB); + H_AUTO_OGL(CDriverGL3_setupWaterPass) + nlassert (_CurrentMaterial); + CMaterial &mat = *_CurrentMaterial; + nlassert(_CurrentMaterial->getShader() == CMaterial::Water); uint k; ITexture *tex = mat.getTexture(0); @@ -1790,85 +1681,7 @@ void CDriverGL3::setupWaterPassARB(const CMaterial &mat) { activateTexture(k, NULL); } - nglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ARBWaterShader[(_FogEnabled ? 1 : 0) | (mat.getTexture(3) != NULL ? 2 : 0)]); - glEnable(GL_FRAGMENT_PROGRAM_ARB); - - // setup the constant - if (mat.getTexture(0) && mat.getTexture(0)->isBumpMap()) - { - float factor = 0.25f * NLMISC::safe_cast(mat.getTexture(0))->getNormalizationFactor(); - nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, 2.f * factor, -1.f * factor, 0.f, 0.f); // scale_bias from [0, 1] to [-1, 1] and factor applied - } - else - { - nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, 2.f, -1.f, 0.f, 0.f); // scale_bias from [0, 1] to [-1, 1] and factor applied - } - - // setup the constant - if (mat.getTexture(1) && mat.getTexture(1)->isBumpMap()) - { - float factor = NLMISC::safe_cast(mat.getTexture(1))->getNormalizationFactor(); - nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 2.f * factor, -1.f * factor, 0.f, 0.f); // scale_bias from [0, 1] to [-1, 1] and factor applied - } - else - { - nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 2.f, -1.f, 0.f, 0.f); // scale_bias from [0, 1] to [-1, 1] and factor applied - } - - if (_FogEnabled) - { - if (_FogStart == _FogEnd) - { - nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2, 0.f, 0.f, 0.f, 0.f); - } - else - { - /** Unfortunately, the EXT_vertex_shader extension has to output the fog values in the [0, 1] range to work with the standard pipeline. - * So we must add a special path for this case, where the fog coordinate is 'unscaled' again. - * NB : this is fixed in later drivers (from 6.14.10.6343), so check this - */ - nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2, - 1.f/ (_FogEnd - _FogStart), _FogEnd / (_FogEnd - _FogStart), 0.f, 0.f); - } - } -} - -// *************************************************************************** -/** Presetupped texture shader for water shader on NV20 - */ -static const uint8 WaterNoDiffuseTexAddrMode[IDRV_MAT_MAXTEXTURES] = -{ - CMaterial::FetchTexture, - CMaterial::OffsetTexture, - CMaterial::OffsetTexture, - CMaterial::TextureOff -}; - -static const uint8 WaterTexAddrMode[IDRV_MAT_MAXTEXTURES] = -{ - CMaterial::FetchTexture, - CMaterial::OffsetTexture, - CMaterial::OffsetTexture, - CMaterial::FetchTexture -}; - -static const float IdentityTexMat[4] = { 1.f, 0.f, 0.f, 1.f }; -// *************************************************************************** -void CDriverGL3::setupWaterPass(uint /* pass */) -{ - H_AUTO_OGL(CDriverGL3_setupWaterPass) - nlassert (_CurrentMaterial); - CMaterial &mat = *_CurrentMaterial; - nlassert(_CurrentMaterial->getShader() == CMaterial::Water); - - if (ARBWaterShader[0]) - { - setupWaterPassARB(mat); - } - else if (ATIWaterShaderHandleNoDiffuseMap) - { - setupWaterPassR200(mat); - } } // *************************************************************************** @@ -1878,14 +1691,7 @@ void CDriverGL3::endWaterMultiPass() nlassert(_CurrentMaterial->getShader() == CMaterial::Water); // NB : as fragment shaders / programs bypass the texture envs, no special env enum is added (c.f CTexEnvSpecial) - if (ARBWaterShader[0]) - { - glDisable(GL_FRAGMENT_PROGRAM_ARB); - } - else if (ATIWaterShaderHandleNoDiffuseMap) - { - glDisable(GL_FRAGMENT_SHADER_ATI); - } + } #ifdef NL_STATIC