diff options
author | Dave Parks <davep@lindenlab.com> | 2011-10-11 14:55:33 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-10-11 14:55:33 -0500 |
commit | 2322c57b4dd2b4338eec2ca9db2425eff4bfd6d5 (patch) | |
tree | d237bc15606a154db8cede7d83cda3802d46d7a0 /indra/newview | |
parent | 3211c6e3089b03d73f2e260be4037304660f834d (diff) |
SH-2545 Fix for transparent water option doing nothing when shaders are enabled.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/objects/simpleTexGenV.glsl | 77 | ||||
-rw-r--r-- | indra/newview/lldrawpoolwater.cpp | 46 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.cpp | 43 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.h | 2 | ||||
-rw-r--r-- | indra/newview/llwlparamset.cpp | 4 |
5 files changed, 159 insertions, 13 deletions
diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleTexGenV.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleTexGenV.glsl new file mode 100644 index 0000000000..d4dee78793 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/simpleTexGenV.glsl @@ -0,0 +1,77 @@ +/** + * @file simpleV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat3 normal_matrix; +uniform mat4 texture_matrix0; +uniform mat4 modelview_matrix; +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +void passTextureIndex(); +ATTRIBUTE vec2 texcoord0; +ATTRIBUTE vec3 normal; + +uniform vec4 color; +uniform vec4 object_plane_t; +uniform vec4 object_plane_s; + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); +void calcAtmospherics(vec3 inPositionEye); + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1) +{ + vec4 tcoord; + + tcoord.x = dot(vpos, tp0); + tcoord.y = dot(vpos, tp1); + tcoord.z = tc.z; + tcoord.w = tc.w; + + tcoord = mat * tcoord; + + return tcoord; +} + +void main() +{ + //transform vertex + vec4 vert = vec4(position.xyz,1.0); + passTextureIndex(); + vec4 pos = (modelview_matrix * vert); + gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); + vary_texcoord0.xy = texgen_object(vec4(position.xyz, 1.0), vec4(texcoord0,0,1), texture_matrix0, object_plane_s, object_plane_t).xy; + + vec3 norm = normalize(normal_matrix * normal); + + calcAtmospherics(pos.xyz); + + vec4 color = calcLighting(pos.xyz, norm, color, vec4(0.)); + vertex_color = color; + + +} diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index f6fe96877d..4f6eaa5a5b 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -169,7 +169,7 @@ void LLDrawPoolWater::render(S32 pass) std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater()); // See if we are rendering water as opaque or not - if (!gSavedSettings.getBOOL("RenderTransparentWater") && !LLGLSLShader::sNoFixedFunction) + if (!gSavedSettings.getBOOL("RenderTransparentWater")) { // render water for low end hardware renderOpaqueLegacyWater(); @@ -334,9 +334,19 @@ void LLDrawPoolWater::renderOpaqueLegacyWater() { LLVOSky *voskyp = gSky.mVOSkyp; + LLGLSLShader* shader = NULL; if (LLGLSLShader::sNoFixedFunction) { - gObjectSimpleProgram.bind(); + if (LLPipeline::sUnderWaterRender) + { + shader = &gObjectSimpleNonIndexedTexGenWaterProgram; + } + else + { + shader = &gObjectSimpleNonIndexedTexGenProgram; + } + + shader->bind(); } stop_glerror(); @@ -361,10 +371,13 @@ void LLDrawPoolWater::renderOpaqueLegacyWater() gGL.getTexUnit(0)->bind(mOpaqueWaterImagep); // Automatically generate texture coords for water texture - glEnable(GL_TEXTURE_GEN_S); //texture unit 0 - glEnable(GL_TEXTURE_GEN_T); //texture unit 0 - glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + if (!shader) + { + glEnable(GL_TEXTURE_GEN_S); //texture unit 0 + glEnable(GL_TEXTURE_GEN_T); //texture unit 0 + glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + } // Use the fact that we know all water faces are the same size // to save some computation @@ -387,8 +400,16 @@ void LLDrawPoolWater::renderOpaqueLegacyWater() F32 tp0[4] = { 16.f / 256.f, 0.0f, 0.0f, offset }; F32 tp1[4] = { 0.0f, 16.f / 256.f, 0.0f, offset }; - glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); - glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); + if (!shader) + { + glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0); + glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1); + } + else + { + shader->uniform4fv("object_plane_s", 1, tp0); + shader->uniform4fv("object_plane_t", 1, tp1); + } gGL.diffuseColor3f(1.f, 1.f, 1.f); @@ -406,9 +427,12 @@ void LLDrawPoolWater::renderOpaqueLegacyWater() stop_glerror(); - // Reset the settings back to expected values - glDisable(GL_TEXTURE_GEN_S); //texture unit 0 - glDisable(GL_TEXTURE_GEN_T); //texture unit 0 + if (!shader) + { + // Reset the settings back to expected values + glDisable(GL_TEXTURE_GEN_S); //texture unit 0 + glDisable(GL_TEXTURE_GEN_T); //texture unit 0 + } gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 8bc573135c..80727764c1 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -96,6 +96,8 @@ LLGLSLShader gObjectFullbrightNoColorProgram; LLGLSLShader gObjectFullbrightNoColorWaterProgram; LLGLSLShader gObjectSimpleNonIndexedProgram; +LLGLSLShader gObjectSimpleNonIndexedTexGenProgram; +LLGLSLShader gObjectSimpleNonIndexedTexGenWaterProgram; LLGLSLShader gObjectSimpleNonIndexedWaterProgram; LLGLSLShader gObjectAlphaMaskNonIndexedProgram; LLGLSLShader gObjectAlphaMaskNonIndexedWaterProgram; @@ -217,6 +219,8 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gObjectFullbrightShinyProgram); mShaderList.push_back(&gObjectFullbrightShinyWaterProgram); mShaderList.push_back(&gObjectSimpleNonIndexedProgram); + mShaderList.push_back(&gObjectSimpleNonIndexedTexGenProgram); + mShaderList.push_back(&gObjectSimpleNonIndexedTexGenWaterProgram); mShaderList.push_back(&gObjectSimpleNonIndexedWaterProgram); mShaderList.push_back(&gObjectAlphaMaskNonIndexedProgram); mShaderList.push_back(&gObjectAlphaMaskNonIndexedWaterProgram); @@ -625,6 +629,8 @@ void LLViewerShaderMgr::unloadShaders() gObjectShinyWaterProgram.unload(); gObjectSimpleNonIndexedProgram.unload(); + gObjectSimpleNonIndexedTexGenProgram.unload(); + gObjectSimpleNonIndexedTexGenWaterProgram.unload(); gObjectSimpleNonIndexedWaterProgram.unload(); gObjectAlphaMaskNonIndexedProgram.unload(); gObjectAlphaMaskNonIndexedWaterProgram.unload(); @@ -1505,7 +1511,8 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightShinyNonIndexedProgram.unload(); gObjectFullbrightShinyNonIndexedWaterProgram.unload(); gObjectShinyNonIndexedWaterProgram.unload(); - gObjectSimpleNonIndexedProgram.unload(); + gObjectSimpleNonIndexedTexGenProgram.unload(); + gObjectSimpleNonIndexedTexGenWaterProgram.unload(); gObjectSimpleNonIndexedWaterProgram.unload(); gObjectAlphaMaskNonIndexedProgram.unload(); gObjectAlphaMaskNonIndexedWaterProgram.unload(); @@ -1549,6 +1556,23 @@ BOOL LLViewerShaderMgr::loadShadersObject() if (success) { + gObjectSimpleNonIndexedTexGenProgram.mName = "Non indexed tex-gen Shader"; + gObjectSimpleNonIndexedTexGenProgram.mFeatures.calculatesLighting = true; + gObjectSimpleNonIndexedTexGenProgram.mFeatures.calculatesAtmospherics = true; + gObjectSimpleNonIndexedTexGenProgram.mFeatures.hasGamma = true; + gObjectSimpleNonIndexedTexGenProgram.mFeatures.hasAtmospherics = true; + gObjectSimpleNonIndexedTexGenProgram.mFeatures.hasLighting = true; + gObjectSimpleNonIndexedTexGenProgram.mFeatures.disableTextureIndex = true; + gObjectSimpleNonIndexedTexGenProgram.mShaderFiles.clear(); + gObjectSimpleNonIndexedTexGenProgram.mShaderFiles.push_back(make_pair("objects/simpleTexGenV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectSimpleNonIndexedTexGenProgram.mShaderFiles.push_back(make_pair("objects/simpleF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectSimpleNonIndexedTexGenProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gObjectSimpleNonIndexedTexGenProgram.createShader(NULL, NULL); + } + + + if (success) + { gObjectSimpleNonIndexedWaterProgram.mName = "Non indexed Water Shader"; gObjectSimpleNonIndexedWaterProgram.mFeatures.calculatesLighting = true; gObjectSimpleNonIndexedWaterProgram.mFeatures.calculatesAtmospherics = true; @@ -1566,6 +1590,23 @@ BOOL LLViewerShaderMgr::loadShadersObject() if (success) { + gObjectSimpleNonIndexedTexGenWaterProgram.mName = "Non indexed tex-gen Water Shader"; + gObjectSimpleNonIndexedTexGenWaterProgram.mFeatures.calculatesLighting = true; + gObjectSimpleNonIndexedTexGenWaterProgram.mFeatures.calculatesAtmospherics = true; + gObjectSimpleNonIndexedTexGenWaterProgram.mFeatures.hasWaterFog = true; + gObjectSimpleNonIndexedTexGenWaterProgram.mFeatures.hasAtmospherics = true; + gObjectSimpleNonIndexedTexGenWaterProgram.mFeatures.hasLighting = true; + gObjectSimpleNonIndexedTexGenWaterProgram.mFeatures.disableTextureIndex = true; + gObjectSimpleNonIndexedTexGenWaterProgram.mShaderFiles.clear(); + gObjectSimpleNonIndexedTexGenWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleTexGenV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectSimpleNonIndexedTexGenWaterProgram.mShaderFiles.push_back(make_pair("objects/simpleWaterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectSimpleNonIndexedTexGenWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + gObjectSimpleNonIndexedTexGenWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + success = gObjectSimpleNonIndexedTexGenWaterProgram.createShader(NULL, NULL); + } + + if (success) + { gObjectAlphaMaskNonIndexedProgram.mName = "Non indexed alpha mask Shader"; gObjectAlphaMaskNonIndexedProgram.mFeatures.calculatesLighting = true; gObjectAlphaMaskNonIndexedProgram.mFeatures.calculatesAtmospherics = true; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 01f8c3987c..26cef8cb3e 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -229,6 +229,8 @@ extern LLGLSLShader gObjectSimpleAlphaMaskProgram; extern LLGLSLShader gObjectSimpleWaterProgram; extern LLGLSLShader gObjectSimpleWaterAlphaMaskProgram; extern LLGLSLShader gObjectSimpleNonIndexedProgram; +extern LLGLSLShader gObjectSimpleNonIndexedTexGenProgram; +extern LLGLSLShader gObjectSimpleNonIndexedTexGenWaterProgram; extern LLGLSLShader gObjectSimpleNonIndexedWaterProgram; extern LLGLSLShader gObjectAlphaMaskNonIndexedProgram; extern LLGLSLShader gObjectAlphaMaskNonIndexedWaterProgram; diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp index 4a1db3d26c..5bb7025031 100644 --- a/indra/newview/llwlparamset.cpp +++ b/indra/newview/llwlparamset.cpp @@ -73,11 +73,13 @@ static LLFastTimer::DeclareTimer FTM_WL_PARAM_UPDATE("WL Param Update"); void LLWLParamSet::update(LLGLSLShader * shader) const { + LLFastTimer t(FTM_WL_PARAM_UPDATE); + for(LLSD::map_const_iterator i = mParamValues.beginMap(); i != mParamValues.endMap(); ++i) { - LLFastTimer t(FTM_WL_PARAM_UPDATE); + const std::string& param = i->first; |