V3 merge. Slight update. Fixes lighting oddities.

This commit is contained in:
Shyotl
2011-12-16 01:50:57 -06:00
parent 0030ca3af7
commit 1bfa72fa7c
7 changed files with 36 additions and 35 deletions

View File

@@ -75,7 +75,7 @@ BOOL shouldChange(const LLVector4& v1, const LLVector4& v2)
LLShaderFeatures::LLShaderFeatures() LLShaderFeatures::LLShaderFeatures()
: calculatesLighting(false), isShiny(false), isFullbright(false), hasWaterFog(false), : calculatesLighting(false), isShiny(false), isFullbright(false), hasWaterFog(false),
hasTransport(false), hasSkinning(false), hasObjectSkinning(false), hasAtmospherics(false), isSpecular(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) hasAlphaMask(false)
{ {
} }

View File

@@ -42,6 +42,7 @@ public:
bool calculatesLighting; bool calculatesLighting;
bool calculatesAtmospherics; bool calculatesAtmospherics;
bool hasLighting; // implies no transport (it's possible to have neither though) 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 isShiny;
bool isFullbright; // implies no lighting bool isFullbright; // implies no lighting
bool isSpecular; bool isSpecular;

View File

@@ -2,31 +2,25 @@
* @file llshadermgr.cpp * @file llshadermgr.cpp
* @brief Shader manager implementation. * @brief Shader manager implementation.
* *
* $LicenseInfo:firstyear=2005&license=viewergpl$ * $LicenseInfo:firstyear=2005&license=viewerlgpl$
*
* Copyright (c) 2005-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code * Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab * Copyright (C) 2010, Linden Research, Inc.
* 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
* *
* There are special exceptions to the terms and conditions of the GPL as * This library is free software; you can redistribute it and/or
* it is applied to this Source Code. View the full text of the exception * modify it under the terms of the GNU Lesser General Public
* in the file doc/FLOSS-exception.txt in this software distribution, or * License as published by the Free Software Foundation;
* online at * version 2.1 of the License only.
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
* *
* By copying, modifying or distributing this software, you acknowledge * This library is distributed in the hope that it will be useful,
* that you have read and understood your obligations described above, * but WITHOUT ANY WARRANTY; without even the implied warranty of
* and agree to abide by those obligations. * 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 * You should have received a copy of the GNU Lesser General Public
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, * License along with this library; if not, write to the Free Software
* COMPLETENESS OR PERFORMANCE. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$ * $/LicenseInfo$
*/ */
@@ -116,9 +110,13 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
return FALSE; 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")) if (!shader->attachObject("lighting/lightSpecularV.glsl"))
@@ -133,9 +131,12 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
return FALSE; 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")) 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 //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 buff[1024];
GLcharARB* text[4096]; GLcharARB* text[4096];
GLuint count = 0; 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 ATTRIBUTE attribute\n");
text[count++] = strdup("#define VARYING varying\n"); text[count++] = strdup("#define VARYING varying\n");
} }
else if (version < 3.f) else if (version < 3.3f)
{ {
//set version to 1.20 //set version to 1.20
text[count++] = strdup("#version 120\n"); text[count++] = strdup("#version 120\n");
@@ -808,6 +809,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
dumpObjectLog(ret); dumpObjectLog(ret);
error_str = get_object_log(ret); error_str = get_object_log(ret);
#if LL_WINDOWS
std::stringstream ostr; std::stringstream ostr;
//dump shader source for debugging //dump shader source for debugging
for (GLuint i = 0; i < count; i++) 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; LL_WARNS("ShaderLoading") << "\n" << ostr.str() << llendl;
#endif // LL_WINDOWS
glDeleteObjectARB(ret); //no longer need handle glDeleteObjectARB(ret); //no longer need handle
ret = 0; ret = 0;
} }

View File

@@ -30,7 +30,6 @@ ATTRIBUTE vec3 normal;
ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec4 diffuse_color;
ATTRIBUTE vec2 texcoord0; ATTRIBUTE vec2 texcoord0;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
mat4 getObjectSkinnedTransform(); mat4 getObjectSkinnedTransform();
void calcAtmospherics(vec3 inPositionEye); void calcAtmospherics(vec3 inPositionEye);

View File

@@ -39,8 +39,6 @@ float calcDirectionalLight(vec3 n, vec3 l);
mat4 getObjectSkinnedTransform(); mat4 getObjectSkinnedTransform();
vec3 atmosAmbient(vec3 light); vec3 atmosAmbient(vec3 light);
vec3 atmosAffectDirectionalLight(float lightIntensity); vec3 atmosAffectDirectionalLight(float lightIntensity);
vec3 scaleDownLight(vec3 light);
vec3 scaleUpLight(vec3 light);
VARYING vec3 vary_ambient; VARYING vec3 vary_ambient;
VARYING vec3 vary_directional; VARYING vec3 vary_directional;

View File

@@ -984,11 +984,12 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{ {
gDeferredSkinnedAlphaProgram.mName = "Deferred Skinned Alpha Shader"; gDeferredSkinnedAlphaProgram.mName = "Deferred Skinned Alpha Shader";
gDeferredSkinnedAlphaProgram.mFeatures.hasObjectSkinning = true; gDeferredSkinnedAlphaProgram.mFeatures.hasObjectSkinning = true;
gDeferredSkinnedAlphaProgram.mFeatures.calculatesLighting = true;
gDeferredSkinnedAlphaProgram.mFeatures.calculatesAtmospherics = true; gDeferredSkinnedAlphaProgram.mFeatures.calculatesAtmospherics = true;
gDeferredSkinnedAlphaProgram.mFeatures.hasGamma = true; gDeferredSkinnedAlphaProgram.mFeatures.hasGamma = true;
gDeferredSkinnedAlphaProgram.mFeatures.hasAtmospherics = true; gDeferredSkinnedAlphaProgram.mFeatures.hasAtmospherics = true;
gDeferredSkinnedAlphaProgram.mFeatures.calculatesLighting = true;
gDeferredSkinnedAlphaProgram.mFeatures.hasLighting = true; gDeferredSkinnedAlphaProgram.mFeatures.hasLighting = true;
gDeferredSkinnedAlphaProgram.mFeatures.isAlphaLighting = true;
gDeferredSkinnedAlphaProgram.mFeatures.disableTextureIndex = true; gDeferredSkinnedAlphaProgram.mFeatures.disableTextureIndex = true;
gDeferredSkinnedAlphaProgram.mShaderFiles.clear(); gDeferredSkinnedAlphaProgram.mShaderFiles.clear();
gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); 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.hasGamma = true;
gDeferredAlphaProgram.mFeatures.hasAtmospherics = true; gDeferredAlphaProgram.mFeatures.hasAtmospherics = true;
gDeferredAlphaProgram.mFeatures.hasLighting = true; gDeferredAlphaProgram.mFeatures.hasLighting = true;
gDeferredAlphaProgram.mFeatures.isAlphaLighting = true;
gDeferredAlphaProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels gDeferredAlphaProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of texture channels
if (mVertexShaderLevel[SHADER_DEFERRED] < 1) if (mVertexShaderLevel[SHADER_DEFERRED] < 1)
{ {
@@ -1265,6 +1267,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarAlphaProgram.mFeatures.hasGamma = true; gDeferredAvatarAlphaProgram.mFeatures.hasGamma = true;
gDeferredAvatarAlphaProgram.mFeatures.hasAtmospherics = true; gDeferredAvatarAlphaProgram.mFeatures.hasAtmospherics = true;
gDeferredAvatarAlphaProgram.mFeatures.hasLighting = true; gDeferredAvatarAlphaProgram.mFeatures.hasLighting = true;
gDeferredAvatarAlphaProgram.mFeatures.isAlphaLighting = true;
gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true; gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true;
gDeferredAvatarAlphaProgram.mShaderFiles.clear(); gDeferredAvatarAlphaProgram.mShaderFiles.clear();
gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaV.glsl", GL_VERTEX_SHADER_ARB));

View File

@@ -7111,7 +7111,6 @@ void LLPipeline::renderDeferredLighting()
F32 s = volume->getLightRadius()*1.5f; F32 s = volume->getLightRadius()*1.5f;
LLColor3 col = volume->getLightColor(); LLColor3 col = volume->getLightColor();
col *= volume->getLightIntensity();
if (col.magVecSquared() < 0.001f) if (col.magVecSquared() < 0.001f)
{ {
@@ -7225,7 +7224,6 @@ void LLPipeline::renderDeferredLighting()
setupSpotLight(gDeferredSpotLightProgram, drawablep); setupSpotLight(gDeferredSpotLightProgram, drawablep);
LLColor3 col = volume->getLightColor(); LLColor3 col = volume->getLightColor();
col *= volume->getLightIntensity();
//vertex positions are encoded so the 3 bits of their vertex index //vertex positions are encoded so the 3 bits of their vertex index
//correspond to their axis facing, with bit position 3,2,1 matching //correspond to their axis facing, with bit position 3,2,1 matching
@@ -7335,7 +7333,6 @@ void LLPipeline::renderDeferredLighting()
setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); setupSpotLight(gDeferredMultiSpotLightProgram, drawablep);
LLColor3 col = volume->getLightColor(); LLColor3 col = volume->getLightColor();
col *= volume->getLightIntensity();
gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v);
gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s*s); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s*s);