SH-2545 Fix for transparent water option doing nothing when shaders are enabled.
parent
3211c6e308
commit
2322c57b4d
|
|
@ -762,12 +762,8 @@ void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, c
|
|||
}
|
||||
}
|
||||
|
||||
static LLFastTimer::DeclareTimer FTM_UNIFORM_LOCATION("Get Uniform Location");
|
||||
|
||||
GLint LLGLSLShader::getUniformLocation(const string& uniform)
|
||||
{
|
||||
LLFastTimer t(FTM_UNIFORM_LOCATION);
|
||||
|
||||
GLint ret = -1;
|
||||
if (mProgramObject > 0)
|
||||
{
|
||||
|
|
@ -792,8 +788,6 @@ GLint LLGLSLShader::getUniformLocation(const string& uniform)
|
|||
|
||||
GLint LLGLSLShader::getUniformLocation(U32 index)
|
||||
{
|
||||
LLFastTimer t(FTM_UNIFORM_LOCATION);
|
||||
|
||||
GLint ret = -1;
|
||||
if (mProgramObject > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
@ -1547,6 +1554,23 @@ BOOL LLViewerShaderMgr::loadShadersObject()
|
|||
success = gObjectSimpleNonIndexedProgram.createShader(NULL, NULL);
|
||||
}
|
||||
|
||||
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";
|
||||
|
|
@ -1564,6 +1588,23 @@ BOOL LLViewerShaderMgr::loadShadersObject()
|
|||
success = gObjectSimpleNonIndexedWaterProgram.createShader(NULL, NULL);
|
||||
}
|
||||
|
||||
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";
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue