V3 merge. Slight update. Fixes lighting oddities.
This commit is contained in:
@@ -75,7 +75,7 @@ BOOL shouldChange(const LLVector4& v1, const LLVector4& v2)
|
||||
LLShaderFeatures::LLShaderFeatures()
|
||||
: calculatesLighting(false), isShiny(false), isFullbright(false), hasWaterFog(false),
|
||||
hasTransport(false), hasSkinning(false), hasObjectSkinning(false), hasAtmospherics(false), isSpecular(false),
|
||||
hasGamma(false), hasLighting(false), calculatesAtmospherics(false), mIndexedTextureChannels(0), disableTextureIndex(false),
|
||||
hasGamma(false), hasLighting(false), isAlphaLighting(false), calculatesAtmospherics(false), mIndexedTextureChannels(0), disableTextureIndex(false),
|
||||
hasAlphaMask(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
bool calculatesLighting;
|
||||
bool calculatesAtmospherics;
|
||||
bool hasLighting; // implies no transport (it's possible to have neither though)
|
||||
bool isAlphaLighting; // indicates lighting shaders need not be linked in (lighting performed directly in alpha shader to match deferred lighting functions
|
||||
bool isShiny;
|
||||
bool isFullbright; // implies no lighting
|
||||
bool isSpecular;
|
||||
|
||||
@@ -2,31 +2,25 @@
|
||||
* @file llshadermgr.cpp
|
||||
* @brief Shader manager implementation.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2005&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2005-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* 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.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* 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.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* 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$
|
||||
*/
|
||||
|
||||
@@ -116,9 +110,13 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!shader->attachObject("lighting/sumLightsSpecularV.glsl"))
|
||||
if (!features->isAlphaLighting)
|
||||
{
|
||||
return FALSE;
|
||||
if (!shader->attachObject("lighting/sumLightsSpecularV.glsl"))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!shader->attachObject("lighting/lightSpecularV.glsl"))
|
||||
@@ -133,9 +131,12 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!shader->attachObject("lighting/sumLightsV.glsl"))
|
||||
if (!features->isAlphaLighting)
|
||||
{
|
||||
return FALSE;
|
||||
if (!shader->attachObject("lighting/sumLightsV.glsl"))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shader->attachObject("lighting/lightV.glsl"))
|
||||
@@ -570,7 +571,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
}
|
||||
|
||||
//we can't have any lines longer than 1024 characters
|
||||
//or any shaders longer than 1024 lines... deal - DaveP
|
||||
//or any shaders longer than 4096 lines... deal - DaveP
|
||||
GLcharARB buff[1024];
|
||||
GLcharARB* text[4096];
|
||||
GLuint count = 0;
|
||||
@@ -588,7 +589,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
text[count++] = strdup("#define ATTRIBUTE attribute\n");
|
||||
text[count++] = strdup("#define VARYING varying\n");
|
||||
}
|
||||
else if (version < 3.f)
|
||||
else if (version < 3.3f)
|
||||
{
|
||||
//set version to 1.20
|
||||
text[count++] = strdup("#version 120\n");
|
||||
@@ -808,6 +809,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
dumpObjectLog(ret);
|
||||
error_str = get_object_log(ret);
|
||||
|
||||
#if LL_WINDOWS
|
||||
std::stringstream ostr;
|
||||
//dump shader source for debugging
|
||||
for (GLuint i = 0; i < count; i++)
|
||||
@@ -824,6 +826,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
}
|
||||
|
||||
LL_WARNS("ShaderLoading") << "\n" << ostr.str() << llendl;
|
||||
#endif // LL_WINDOWS
|
||||
glDeleteObjectARB(ret); //no longer need handle
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ ATTRIBUTE vec3 normal;
|
||||
ATTRIBUTE vec4 diffuse_color;
|
||||
ATTRIBUTE vec2 texcoord0;
|
||||
|
||||
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
|
||||
mat4 getObjectSkinnedTransform();
|
||||
void calcAtmospherics(vec3 inPositionEye);
|
||||
|
||||
|
||||
@@ -39,8 +39,6 @@ float calcDirectionalLight(vec3 n, vec3 l);
|
||||
mat4 getObjectSkinnedTransform();
|
||||
vec3 atmosAmbient(vec3 light);
|
||||
vec3 atmosAffectDirectionalLight(float lightIntensity);
|
||||
vec3 scaleDownLight(vec3 light);
|
||||
vec3 scaleUpLight(vec3 light);
|
||||
|
||||
VARYING vec3 vary_ambient;
|
||||
VARYING vec3 vary_directional;
|
||||
|
||||
@@ -984,11 +984,12 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
|
||||
{
|
||||
gDeferredSkinnedAlphaProgram.mName = "Deferred Skinned Alpha Shader";
|
||||
gDeferredSkinnedAlphaProgram.mFeatures.hasObjectSkinning = true;
|
||||
gDeferredSkinnedAlphaProgram.mFeatures.calculatesLighting = true;
|
||||
gDeferredSkinnedAlphaProgram.mFeatures.calculatesAtmospherics = true;
|
||||
gDeferredSkinnedAlphaProgram.mFeatures.hasGamma = true;
|
||||
gDeferredSkinnedAlphaProgram.mFeatures.hasAtmospherics = true;
|
||||
gDeferredSkinnedAlphaProgram.mFeatures.calculatesLighting = true;
|
||||
gDeferredSkinnedAlphaProgram.mFeatures.hasLighting = true;
|
||||
gDeferredSkinnedAlphaProgram.mFeatures.isAlphaLighting = true;
|
||||
gDeferredSkinnedAlphaProgram.mFeatures.disableTextureIndex = true;
|
||||
gDeferredSkinnedAlphaProgram.mShaderFiles.clear();
|
||||
gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
@@ -1116,6 +1117,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
|
||||
gDeferredAlphaProgram.mFeatures.hasGamma = true;
|
||||
gDeferredAlphaProgram.mFeatures.hasAtmospherics = true;
|
||||
gDeferredAlphaProgram.mFeatures.hasLighting = true;
|
||||
gDeferredAlphaProgram.mFeatures.isAlphaLighting = true;
|
||||
gDeferredAlphaProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels
|
||||
if (mVertexShaderLevel[SHADER_DEFERRED] < 1)
|
||||
{
|
||||
@@ -1265,6 +1267,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
|
||||
gDeferredAvatarAlphaProgram.mFeatures.hasGamma = true;
|
||||
gDeferredAvatarAlphaProgram.mFeatures.hasAtmospherics = true;
|
||||
gDeferredAvatarAlphaProgram.mFeatures.hasLighting = true;
|
||||
gDeferredAvatarAlphaProgram.mFeatures.isAlphaLighting = true;
|
||||
gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true;
|
||||
gDeferredAvatarAlphaProgram.mShaderFiles.clear();
|
||||
gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
|
||||
@@ -7111,7 +7111,6 @@ void LLPipeline::renderDeferredLighting()
|
||||
F32 s = volume->getLightRadius()*1.5f;
|
||||
|
||||
LLColor3 col = volume->getLightColor();
|
||||
col *= volume->getLightIntensity();
|
||||
|
||||
if (col.magVecSquared() < 0.001f)
|
||||
{
|
||||
@@ -7225,7 +7224,6 @@ void LLPipeline::renderDeferredLighting()
|
||||
setupSpotLight(gDeferredSpotLightProgram, drawablep);
|
||||
|
||||
LLColor3 col = volume->getLightColor();
|
||||
col *= volume->getLightIntensity();
|
||||
|
||||
//vertex positions are encoded so the 3 bits of their vertex index
|
||||
//correspond to their axis facing, with bit position 3,2,1 matching
|
||||
@@ -7335,7 +7333,6 @@ void LLPipeline::renderDeferredLighting()
|
||||
setupSpotLight(gDeferredMultiSpotLightProgram, drawablep);
|
||||
|
||||
LLColor3 col = volume->getLightColor();
|
||||
col *= volume->getLightIntensity();
|
||||
|
||||
gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v);
|
||||
gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s*s);
|
||||
|
||||
Reference in New Issue
Block a user