diff options
Diffstat (limited to 'indra')
25 files changed, 672 insertions, 395 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 2adbb213e6..80680948b5 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -80,7 +80,7 @@ LLSettingsBase::LLSettingsBase(const LLSD setting) : //========================================================================= void LLSettingsBase::lerpSettings(const LLSettingsBase &other, F64 mix) { - mSettings = interpolateSDMap(mSettings, other.mSettings, mix); + mSettings = interpolateSDMap(mSettings, other.mSettings, other.getParameterMap(), mix); setDirtyFlag(true); } @@ -158,7 +158,7 @@ LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) cons return newSettings; } -LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F64 mix) const +LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, F64 mix) const { LLSD newSettings; @@ -173,81 +173,33 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F if (skip.find(key_name) != skip.end()) continue; - if (!other.has(key_name)) - { // The other does not contain this setting, keep the original value - // TODO: Should I blend this out instead? - newSettings[key_name] = value; - continue; - } - LLSD::Type setting_type = value.type(); - LLSD other_value = other[key_name]; - - if (other_value.type() != setting_type) - { - // The data type mismatched between this and other. Hard switch when we pass the break point - // but issue a warning. - LL_WARNS("SETTINGS") << "Setting lerp between mismatched types for '" << key_name << "'." << LL_ENDL; - newSettings[key_name] = (mix > BREAK_POINT) ? other_value : value; - continue; + LLSD other_value; + if (other.has(key_name)) + { + other_value = other[key_name]; } - - switch (setting_type) + else { - case LLSD::TypeInteger: - // lerp between the two values rounding the result to the nearest integer. - newSettings[key_name] = LLSD::Integer(llroundf(lerp(value.asReal(), other_value.asReal(), mix))); - break; - case LLSD::TypeReal: - // lerp between the two values. - newSettings[key_name] = LLSD::Real(lerp(value.asReal(), other_value.asReal(), mix)); - break; - case LLSD::TypeMap: - // deep copy. - newSettings[key_name] = interpolateSDMap(value, other_value, mix); - break; - - case LLSD::TypeArray: + parammapping_t::const_iterator def_iter = defaults.find(key_name); + if (def_iter != defaults.end()) { - LLSD newvalue(LLSD::emptyArray()); - - if (slerps.find(key_name) != slerps.end()) - { - LLQuaternion a(value); - LLQuaternion b(other_value); - LLQuaternion q = slerp(mix, a, b); - newvalue = q.getValue(); - } - else - { // TODO: We could expand this to inspect the type and do a deep lerp based on type. - // for now assume a heterogeneous array of reals. - size_t len = std::max(value.size(), other_value.size()); - - for (size_t i = 0; i < len; ++i) - { - - newvalue[i] = lerp(value[i].asReal(), other_value[i].asReal(), mix); - } - } - - newSettings[key_name] = newvalue; + other_value = def_iter->second.getDefaultValue(); + } + else if (value.type() == LLSD::TypeMap) + { + // interpolate in case there are defaults inside (part of legacy) + other_value = LLSDMap(); + } + else + { + // The other or defaults does not contain this setting, keep the original value + // TODO: Should I blend this out instead? + newSettings[key_name] = value; + continue; } - - break; - - case LLSD::TypeUUID: - newSettings[key_name] = value.asUUID(); - break; - -// case LLSD::TypeBoolean: -// case LLSD::TypeString: -// case LLSD::TypeURI: -// case LLSD::TypeBinary: -// case LLSD::TypeDate: - default: - // atomic or unknown data types. Lerping between them does not make sense so switch at the break. - newSettings[key_name] = (mix > BREAK_POINT) ? other_value : value; - break; } + + newSettings[key_name] = interpolateSDValue(key_name, value, other_value, defaults, mix, slerps); } // Special handling cases @@ -264,6 +216,27 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F // Now add anything that is in other but not in the settings for (LLSD::map_const_iterator it = other.beginMap(); it != other.endMap(); ++it) { + std::string key_name = (*it).first; + + if (skip.find(key_name) != skip.end()) + continue; + + if (settings.has(key_name)) + continue; + + parammapping_t::const_iterator def_iter = defaults.find(key_name); + if (def_iter != defaults.end()) + { + // Blend against default value + newSettings[key_name] = interpolateSDValue(key_name, def_iter->second.getDefaultValue(), (*it).second, defaults, mix, slerps); + } + // else do nothing when no known defaults + // TODO: Should I blend this out instead? + } + + // Note: writes variables from skip list, bug? + for (LLSD::map_const_iterator it = other.beginMap(); it != other.endMap(); ++it) + { // TODO: Should I blend this in instead? if (skip.find((*it).first) == skip.end()) continue; @@ -277,6 +250,81 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F return newSettings; } +LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD &value, const LLSD &other_value, const parammapping_t& defaults, BlendFactor mix, const stringset_t& slerps) const +{ + LLSD new_value; + + LLSD::Type setting_type = value.type(); + + if (other_value.type() != setting_type) + { + // The data type mismatched between this and other. Hard switch when we pass the break point + // but issue a warning. + LL_WARNS("SETTINGS") << "Setting lerp between mismatched types for '" << key_name << "'." << LL_ENDL; + new_value = (mix > BREAK_POINT) ? other_value : value; + } + + switch (setting_type) + { + case LLSD::TypeInteger: + // lerp between the two values rounding the result to the nearest integer. + new_value = LLSD::Integer(llroundf(lerp(value.asReal(), other_value.asReal(), mix))); + break; + case LLSD::TypeReal: + // lerp between the two values. + new_value = LLSD::Real(lerp(value.asReal(), other_value.asReal(), mix)); + break; + case LLSD::TypeMap: + // deep copy. + new_value = interpolateSDMap(value, other_value, defaults, mix); + break; + + case LLSD::TypeArray: + { + LLSD new_array(LLSD::emptyArray()); + + if (slerps.find(key_name) != slerps.end()) + { + LLQuaternion a(value); + LLQuaternion b(other_value); + LLQuaternion q = slerp(mix, a, b); + new_array = q.getValue(); + } + else + { // TODO: We could expand this to inspect the type and do a deep lerp based on type. + // for now assume a heterogeneous array of reals. + size_t len = std::max(value.size(), other_value.size()); + + for (size_t i = 0; i < len; ++i) + { + + new_array[i] = lerp(value[i].asReal(), other_value[i].asReal(), mix); + } + } + + new_value = new_array; + } + + break; + + case LLSD::TypeUUID: + new_value = value.asUUID(); + break; + + // case LLSD::TypeBoolean: + // case LLSD::TypeString: + // case LLSD::TypeURI: + // case LLSD::TypeBinary: + // case LLSD::TypeDate: + default: + // atomic or unknown data types. Lerping between them does not make sense so switch at the break. + new_value = (mix > BREAK_POINT) ? other_value : value; + break; + } + + return new_value; +} + LLSettingsBase::stringset_t LLSettingsBase::getSkipInterpolateKeys() const { static stringset_t skipSet; diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index aea1bc3fde..c7b685c6d5 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -76,7 +76,21 @@ public: static const U32 FLAG_NOMOD; static const U32 FLAG_NOTRANS; - typedef std::map<std::string, S32> parammapping_t; + class DefaultParam + { + public: + DefaultParam(S32 key, const LLSD& value) : mShaderKey(key), mDefaultValue(value) {} + DefaultParam() : mShaderKey(-1) {} + S32 getShaderKey() const { return mShaderKey; } + const LLSD getDefaultValue() const { return mDefaultValue; } + + private: + S32 mShaderKey; + LLSD mDefaultValue; + }; + // Contains settings' names (map key), related shader id-key and default + // value for revert in case we need to reset shader (no need to search each time) + typedef std::map<std::string, DefaultParam> parammapping_t; typedef PTR_NAMESPACE::shared_ptr<LLSettingsBase> ptr_t; @@ -312,7 +326,15 @@ protected: // combining settings objects. Customize for specific setting types virtual void lerpSettings(const LLSettingsBase &other, BlendFactor mix); - LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, BlendFactor mix) const; + + // combining settings maps where it can based on mix rate + // @settings initial value (mix==0) + // @other target value (mix==1) + // @defaults list of default values for legacy fields and (re)setting shaders + // @mix from 0 to 1, ratio or rate of transition from initial 'settings' to 'other' + // return interpolated and combined LLSD map + LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, BlendFactor mix) const; + LLSD interpolateSDValue(const std::string& name, const LLSD &value, const LLSD &other, const parammapping_t& defaults, BlendFactor mix, const stringset_t& slerps) const; /// when lerping between settings, some may require special handling. /// Get a list of these key to be skipped by the default settings lerp. diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 8a1e74d7ea..cf6bc45080 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -438,7 +438,14 @@ void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(end); if (other) { - LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); + if (!mSettings.has(SETTING_LEGACY_HAZE) && !mSettings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) + { + // Special case since SETTING_AMBIENT is both in outer and legacy maps, we prioritize legacy one + // see getAmbientColor() + setAmbientColor(getAmbientColor()); + } + + LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, other->getParameterMap(), blendf); replaceSettings(blenddata); mNextSunTextureId = other->getSunTextureId(); mNextMoonTextureId = other->getMoonTextureId(); @@ -924,6 +931,7 @@ LLVector3 LLSettingsSky::getLightDirection() const LLColor3 LLSettingsSky::getAmbientColor() const { + // Todo: this causes complications, preferably to get rid of this duality if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) { return LLColor3(mSettings[SETTING_LEGACY_HAZE][SETTING_AMBIENT]); diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index 87744453ed..7cfff954a0 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -178,7 +178,7 @@ void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf) LLSettingsWater::ptr_t other = PTR_NAMESPACE::static_pointer_cast<LLSettingsWater>(end); if (other) { - LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); + LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, other->getParameterMap(), blendf); replaceSettings(blenddata); mNextNormalMapID = other->getNormalMapID(); mNextTransparentTextureID = other->getTransparentTextureID(); diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 2f78b6e104..a55a72c18f 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -36,6 +36,7 @@ #include "llsys.h" #include "llgl.h" +#include "llglstates.h" #include "llrender.h" #include "llerror.h" @@ -2478,27 +2479,45 @@ void LLGLDepthTest::checkState() } } -LLGLSquashToFarClip::LLGLSquashToFarClip(glh::matrix4f P, U32 layer) +LLGLSquashToFarClip::LLGLSquashToFarClip() +{ + glh::matrix4f proj = get_current_projection(); + setProjectionMatrix(proj, 0); +} + +LLGLSquashToFarClip::LLGLSquashToFarClip(glh::matrix4f& P, U32 layer) +{ + setProjectionMatrix(P, layer); +} + + +void LLGLSquashToFarClip::setProjectionMatrix(glh::matrix4f& projection, U32 layer) { F32 depth = 0.99999f - 0.0001f * layer; for (U32 i = 0; i < 4; i++) { - P.element(2, i) = P.element(3, i) * depth; + projection.element(2, i) = projection.element(3, i) * depth; } + U32 last_matrix_mode = gGL.getMatrixMode(); + gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); - gGL.loadMatrix(P.m); - gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.loadMatrix(projection.m); + + gGL.matrixMode(last_matrix_mode); } LLGLSquashToFarClip::~LLGLSquashToFarClip() { + U32 last_matrix_mode = gGL.getMatrixMode(); + gGL.matrixMode(LLRender::MM_PROJECTION); gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); + + gGL.matrixMode(last_matrix_mode); } @@ -2561,5 +2580,39 @@ void LLGLSyncFence::wait() #endif } +LLGLSPipelineSkyBox::LLGLSPipelineSkyBox() +: mAlphaTest(GL_ALPHA_TEST) +, mCullFace(GL_CULL_FACE) +, mSquashClip() +{ + if (!LLGLSLShader::sNoFixedFunction) + { + glDisable(GL_LIGHTING); + glDisable(GL_FOG); + glDisable(GL_CLIP_PLANE0); + } +} +LLGLSPipelineSkyBox::~LLGLSPipelineSkyBox() +{ + if (!LLGLSLShader::sNoFixedFunction) + { + glEnable(GL_LIGHTING); + glEnable(GL_FOG); + glEnable(GL_CLIP_PLANE0); + } +} +LLGLSPipelineDepthTestSkyBox::LLGLSPipelineDepthTestSkyBox(bool depth_test, bool depth_write) +: LLGLSPipelineSkyBox() +, mDepth(depth_test ? GL_TRUE : GL_FALSE, depth_write ? GL_TRUE : GL_FALSE, GL_LEQUAL) +{ + +} + +LLGLSPipelineBlendSkyBox::LLGLSPipelineBlendSkyBox(bool depth_test, bool depth_write) +: LLGLSPipelineDepthTestSkyBox(depth_test, depth_write) +, mBlend(GL_BLEND) +{ + gGL.setSceneBlendType(LLRender::BT_ALPHA); +} diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 4c4302d05b..96cbf2e3c2 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -360,14 +360,17 @@ private: Modify and load projection matrix to push depth values to far clip plane. Restores projection matrix on destruction. - GL_MODELVIEW_MATRIX is active whenever program execution - leaves this class. + Saves/restores matrix mode around projection manipulation. Does not stack. */ class LLGLSquashToFarClip { public: - LLGLSquashToFarClip(glh::matrix4f projection, U32 layer = 0); + LLGLSquashToFarClip(); + LLGLSquashToFarClip(glh::matrix4f& projection, U32 layer = 0); + + void setProjectionMatrix(glh::matrix4f& projection, U32 layer); + ~LLGLSquashToFarClip(); }; diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index c03d33080f..f0cc9acc06 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -37,12 +37,6 @@ #include "OpenGL/OpenGL.h" #endif -#ifdef LL_RELEASE_FOR_DOWNLOAD -#define UNIFORM_ERRS LL_WARNS_ONCE("Shader") -#else -#define UNIFORM_ERRS LL_ERRS("Shader") -#endif - // Lots of STL stuff in here, using namespace std to keep things more readable using std::vector; using std::pair; @@ -456,12 +450,12 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes, } if( !success ) { - LL_WARNS("ShaderLoading") << "Failed to link shader: " << mName << LL_ENDL; + LL_SHADER_LOADING_WARNS() << "Failed to link shader: " << mName << LL_ENDL; // Try again using a lower shader level; if (mShaderLevel > 0) { - LL_WARNS("ShaderLoading") << "Failed to link using shader level " << mShaderLevel << " trying again using shader level " << (mShaderLevel - 1) << LL_ENDL; + LL_SHADER_LOADING_WARNS() << "Failed to link using shader level " << mShaderLevel << " trying again using shader level " << (mShaderLevel - 1) << LL_ENDL; mShaderLevel--; return createShader(attributes,uniforms); } @@ -504,7 +498,7 @@ BOOL LLGLSLShader::attachObject(std::string object) } else { - LL_WARNS("ShaderLoading") << "Attempting to attach shader object that hasn't been compiled: " << object << LL_ENDL; + LL_SHADER_LOADING_WARNS() << "Attempting to attach shader object that hasn't been compiled: " << object << LL_ENDL; return FALSE; } } @@ -519,7 +513,7 @@ void LLGLSLShader::attachObject(GLhandleARB object) } else { - LL_WARNS("ShaderLoading") << "Attempting to attach non existing shader object. " << LL_ENDL; + LL_SHADER_LOADING_WARNS() << "Attempting to attach non existing shader object. " << LL_ENDL; } } @@ -937,7 +931,7 @@ S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture *texture, LLTexUnit::eTextu { if (uniform < 0 || uniform >= (S32)mTexture.size()) { - UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform out of range: " << uniform << LL_ENDL; return -1; } @@ -963,7 +957,7 @@ S32 LLGLSLShader::unbindTexture(S32 uniform, LLTexUnit::eTextureType mode) { if (uniform < 0 || uniform >= (S32)mTexture.size()) { - UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform out of range: " << uniform << LL_ENDL; return -1; } @@ -981,7 +975,7 @@ S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode) { if (uniform < 0 || uniform >= (S32)mTexture.size()) { - UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform out of range: " << uniform << LL_ENDL; return -1; } S32 index = mTexture[uniform]; @@ -997,7 +991,7 @@ S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode) { if (uniform < 0 || uniform >= (S32)mTexture.size()) { - UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform out of range: " << uniform << LL_ENDL; return -1; } S32 index = mTexture[uniform]; @@ -1026,7 +1020,7 @@ void LLGLSLShader::uniform1i(U32 index, GLint x) { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1048,7 +1042,7 @@ void LLGLSLShader::uniform1f(U32 index, GLfloat x) { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1070,7 +1064,7 @@ void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y) { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1093,7 +1087,7 @@ void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z) { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1116,7 +1110,7 @@ void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1139,7 +1133,7 @@ void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v) { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1162,7 +1156,7 @@ void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v) { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1185,7 +1179,7 @@ void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v) { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1208,7 +1202,7 @@ void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v) { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1231,7 +1225,7 @@ void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v) { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1254,7 +1248,7 @@ void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, c { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1271,7 +1265,7 @@ void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, c { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1288,7 +1282,7 @@ void LLGLSLShader::uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } @@ -1305,7 +1299,7 @@ void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, c { if (mUniform.size() <= index) { - UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL; + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; return; } diff --git a/indra/llrender/llglstates.h b/indra/llrender/llglstates.h index 0e2c3bcb44..a4924eba14 100644 --- a/indra/llrender/llglstates.h +++ b/indra/llrender/llglstates.h @@ -208,11 +208,27 @@ public: class LLGLSPipelineSkyBox { protected: - LLGLDisable mAlphaTest, mCullFace, mFog; + LLGLDisable mAlphaTest; + LLGLDisable mCullFace; + LLGLSquashToFarClip mSquashClip; public: - LLGLSPipelineSkyBox() - : mAlphaTest(GL_ALPHA_TEST), mCullFace(GL_CULL_FACE), mFog(GL_FOG) - { } + LLGLSPipelineSkyBox(); + ~LLGLSPipelineSkyBox(); +}; + +class LLGLSPipelineDepthTestSkyBox : public LLGLSPipelineSkyBox +{ +public: + LLGLSPipelineDepthTestSkyBox(bool depth_test, bool depth_write); + + LLGLDepthTest mDepth; +}; + +class LLGLSPipelineBlendSkyBox : public LLGLSPipelineDepthTestSkyBox +{ +public: + LLGLSPipelineBlendSkyBox(bool depth_test, bool depth_write); + LLGLEnable mBlend; }; class LLGLSTracker diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 251c02dd77..5733a18f47 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1270,7 +1270,7 @@ void LLRender::syncMatrices() glh::matrix4f& mat = mMatrix[MM_PROJECTION][mMatIdx[MM_PROJECTION]]; // it would be nice to have this automatically track the state of the proj matrix - // but certain render paths require it to be mismatched *sigh* + // but certain render paths (deferred lighting) require it to be mismatched *sigh* //if (shader->getUniformLocation(LLShaderMgr::INVERSE_PROJECTION_MATRIX)) //{ // glh::matrix4f inv_proj = mat.inverse(); diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 62cd526550..a79db80ebe 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -517,4 +517,13 @@ void set_current_projection(glh::matrix4f& mat); glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat znear, GLfloat zfar); glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar); glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up); + +#if LL_RELEASE_FOR_DOWNLOAD + #define LL_SHADER_LOADING_WARNS(...) LL_WARNS_ONCE("ShaderLoading") + #define LL_SHADER_UNIFORM_ERRS(...) LL_WARNS_ONCE("Shader") +#else + #define LL_SHADER_LOADING_WARNS(...) LL_WARNS() + #define LL_SHADER_UNIFORM_ERRS(...) LL_ERRS("Shader") +#endif + #endif diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 8617b58d2e..9da705bb2d 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -25,18 +25,14 @@ */ #include "linden_common.h" - #include "llshadermgr.h" - -#include "llfile.h" #include "llrender.h" +#include "llfile.h" #if LL_DARWIN #include "OpenGL/OpenGL.h" #endif -#define UNIFORM_ERRS LL_WARNS_ONCE("Shader") - // Lots of STL stuff in here, using namespace std to keep things more readable using std::vector; using std::pair; @@ -537,6 +533,16 @@ static std::string get_object_log(GLhandleARB ret) return res; } +//dump shader source for debugging +void LLShaderMgr::dumpShaderSource(U32 shader_code_count, GLcharARB** shader_code_text) +{ + for (GLuint i = 0; i < shader_code_count; i++) + { + LL_SHADER_LOADING_WARNS() << i << ": " << shader_code_text[i] << LL_ENDL; + } + LL_SHADER_LOADING_WARNS() << LL_ENDL; +} + void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns, const std::string& filename) { std::string log = get_object_log(ret); @@ -548,8 +554,8 @@ void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns, const std::string& if (log.length() > 0) { - LL_WARNS("ShaderLoading") << "Shader loading from " << fname << ":\n" << LL_ENDL; - LL_WARNS("ShaderLoading") << log << LL_ENDL; + LL_SHADER_LOADING_WARNS() << "Shader loading from " << fname << ":\n" << LL_ENDL; + LL_SHADER_LOADING_WARNS() << log << LL_ENDL; } } @@ -570,11 +576,11 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade error = glGetError(); if (error != GL_NO_ERROR) { - LL_WARNS("ShaderLoading") << "GL ERROR entering loadShaderFile(): " << error << LL_ENDL; + LL_SHADER_LOADING_WARNS() << "GL ERROR entering loadShaderFile(): " << error << LL_ENDL; } } - LL_DEBUGS("ShaderLoading") << "Loading shader file: " << filename << " class " << shader_level << LL_ENDL; + //LL_SHADER_LOADING_WARNS() << "Loading shader file: " << filename << " class " << shader_level << LL_ENDL; if (filename.empty()) { @@ -588,6 +594,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade S32 try_gpu_class = shader_level; S32 gpu_class; + std::string open_file_name; //find the most relevant file for (gpu_class = try_gpu_class; gpu_class > 0; gpu_class--) { //search from the current gpu class down to class 1 to find the most relevant shader @@ -595,18 +602,33 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade fname << getShaderDirPrefix(); fname << gpu_class << "/" << filename; - LL_DEBUGS("ShaderLoading") << "Looking in " << fname.str() << LL_ENDL; - file = LLFile::fopen(fname.str(), "r"); /* Flawfinder: ignore */ + open_file_name = fname.str(); + + /* + Would be awesome, if we didn't have shaders that re-use files + with different environments to say, add skinning, etc + can't depend on cached version to have evaluate ifdefs identically... + if we can define a deterministic hash for the shader based on + all the inputs, maybe we can save some time here. + if (mShaderObjects.count(filename) > 0) + { + return mShaderObjects[filename]; + } + + */ + + LL_DEBUGS("ShaderLoading") << "Looking in " << open_file_name << LL_ENDL; + file = LLFile::fopen(open_file_name, "r"); /* Flawfinder: ignore */ if (file) { - LL_DEBUGS("ShaderLoading") << "Loading file: shaders/class" << gpu_class << "/" << filename << " (Want class " << gpu_class << ")" << LL_ENDL; + LL_DEBUGS("ShaderLoading") << "Loading file: shaders/class" << gpu_class << "/" << open_file_name << " (Want class " << gpu_class << ")" << LL_ENDL; break; // done } } if (file == NULL) { - LL_WARNS("ShaderLoading") << "GLSL Shader file not found: " << filename << LL_ENDL; + LL_SHADER_LOADING_WARNS() << "GLSL Shader file not found: " << filename << LL_ENDL; return 0; } @@ -685,7 +707,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade extra_code_text[extra_code_count++] = strdup("#define texture2D texture\n"); extra_code_text[extra_code_count++] = strdup("#define textureCube texture\n"); extra_code_text[extra_code_count++] = strdup("#define texture2DLod textureLod\n"); - extra_code_text[extra_code_count++] = strdup("#define shadow2D(a,b) vec2(texture(a,b))\n"); + extra_code_text[extra_code_count++] = strdup("#define shadow2D(a,b) vec2(texture(a,b))\n"); if (major_version > 1 || minor_version >= 40) { //GLSL 1.40 replaces texture2DRect et al with texture @@ -1012,7 +1034,7 @@ BOOL LLShaderMgr::linkProgramObject(GLhandleARB obj, BOOL suppress_errors) if (!suppress_errors && success == GL_FALSE) { //an error occured, print log - LL_WARNS("ShaderLoading") << "GLSL Linker Error:" << LL_ENDL; + LL_SHADER_LOADING_WARNS() << "GLSL Linker Error:" << LL_ENDL; } #if LL_DARWIN @@ -1045,7 +1067,7 @@ BOOL LLShaderMgr::linkProgramObject(GLhandleARB obj, BOOL suppress_errors) CGLGetParameter(ctx, kCGLCPGPUFragmentProcessing, &fragmentGPUProcessing); if (!fragmentGPUProcessing || !vertexGPUProcessing) { - LL_WARNS("ShaderLoading") << "GLSL Linker: Running in Software:" << LL_ENDL; + LL_SHADER_LOADING_WARNS() << "GLSL Linker: Running in Software:" << LL_ENDL; success = GL_FALSE; suppress_errors = FALSE; } @@ -1056,7 +1078,7 @@ BOOL LLShaderMgr::linkProgramObject(GLhandleARB obj, BOOL suppress_errors) LLStringUtil::toLower(log); if (log.find("software") != std::string::npos) { - LL_WARNS("ShaderLoading") << "GLSL Linker: Running in Software:" << LL_ENDL; + LL_SHADER_LOADING_WARNS() << "GLSL Linker: Running in Software:" << LL_ENDL; success = GL_FALSE; suppress_errors = FALSE; } @@ -1072,7 +1094,7 @@ BOOL LLShaderMgr::validateProgramObject(GLhandleARB obj) glGetObjectParameterivARB(obj, GL_OBJECT_VALIDATE_STATUS_ARB, &success); if (success == GL_FALSE) { - LL_WARNS("ShaderLoading") << "GLSL program not valid: " << LL_ENDL; + LL_SHADER_LOADING_WARNS() << "GLSL program not valid: " << LL_ENDL; dumpObjectLog(obj); } else @@ -1326,9 +1348,12 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("rainbow_map"); mReservedUniforms.push_back("halo_map"); mReservedUniforms.push_back("moon_brightness"); - mReservedUniforms.push_back("moon_phase"); mReservedUniforms.push_back("cloud_variance"); + mReservedUniforms.push_back("sh_input_r"); + mReservedUniforms.push_back("sh_input_g"); + mReservedUniforms.push_back("sh_input_b"); + llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); std::set<std::string> dupe_check; diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index af34c70c54..c22fe44750 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -241,10 +241,13 @@ public: HALO_MAP, MOON_BRIGHTNESS, - MOON_PHASE, CLOUD_VARIANCE, + SH_INPUT_L1R, + SH_INPUT_L1G, + SH_INPUT_L1B, + END_RESERVED_UNIFORMS } eGLSLReservedUniforms; @@ -255,6 +258,7 @@ public: BOOL attachShaderFeatures(LLGLSLShader * shader); void dumpObjectLog(GLhandleARB ret, BOOL warns = TRUE, const std::string& filename = ""); + void dumpShaderSource(U32 shader_code_count, GLcharARB** shader_code_text); BOOL linkProgramObject(GLhandleARB obj, BOOL suppress_errors = FALSE); BOOL validateProgramObject(GLhandleARB obj); GLhandleARB loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, boost::unordered_map<std::string, std::string>* defines = NULL, S32 texture_index_channels = -1); diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl index 584bd568c5..bf0a9048f0 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl @@ -23,16 +23,29 @@ * $/LicenseInfo$ */ +vec3 atmosFragAmbient(vec3 light, vec3 sunlit) +{ + return light; +} - -vec3 atmosLighting(vec3 light) +vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) { /* stub function for fallback compatibility on class1 hardware */ - return light; + return light; } +vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit) +{ + return light * sunlit; +} -void calcFragAtmospherics(vec3 inPositionEye, float ambFactor) { +vec3 atmosLighting(vec3 light) +{ + return atmosFragLighting(light, vec3(0), vec3(1.0)); +} + +void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive) +{ /* stub function for fallback compatibility on class1 hardware */ } diff --git a/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl index 62f4e51449..b7f117fc5f 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl @@ -23,17 +23,28 @@ * $/LicenseInfo$ */ - - +uniform int no_atmo; uniform vec4 gamma; -/// Soft clips the light with a gamma correction -vec3 scaleSoftClip(vec3 light) { +vec3 scaleFragSoftClip(vec3 light) +{ // For compatibility with lower cards. Do nothing. return light; } +/// Soft clips the light with a gamma correction +vec3 scaleSoftClip(vec3 light) +{ + // For compatibility with lower cards. Do nothing. + return scaleFragSoftClip(light); +} + +vec3 fullbrightScaleSoftClipFrag(vec3 light, vec3 atten) +{ + return (no_atmo == 1) ? light : mix(scaleFragSoftClip(light.rgb), light.rgb, atten); +} + vec3 fullbrightScaleSoftClip(vec3 light) { - return scaleSoftClip(light); + return fullbrightScaleSoftClipFrag(light, vec3(1)); } diff --git a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl index 7c95ecdb14..c3c8329017 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl @@ -22,25 +22,40 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - +uniform int no_atmo; -vec3 atmosTransport(vec3 light) +vec3 atmosFragTransport(vec3 light, vec3 atten, vec3 additive) { /* stub function for fallback compatibility on class1 hardware */ return light; } -vec3 fullbrightAtmosTransport(vec3 light) +vec3 fullbrightFragAtmosTransport(vec3 light, vec3 atten, vec3 additive) { /* stub function for fallback compatibility on class1 hardware */ return light; } +vec3 fullbrightFragShinyAtmosTransport(vec3 light, vec3 atten, vec3 additive) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} -vec3 fullbrightShinyAtmosTransport(vec3 light) +vec3 atmosTransport(vec3 light) { /* stub function for fallback compatibility on class1 hardware */ - return light; + return atmosFragTransport(light, vec3(1), vec3(0)); +} + +vec3 fullbrightAtmosTransport(vec3 light) +{ + return fullbrightFragAtmosTransport(light, vec3(1), vec3(0)); +} + +vec3 fullbrightShinyAtmosTransport(vec3 light) +{ + return fullbrightFragShinyAtmosTransport(light, vec3(1), vec3(0)); } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index cdd84faba9..e3fa431ddf 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -22,11 +22,13 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + +/*[EXTRA_CODE_HERE]*/ + #ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; +out vec4 frag_data[3]; #else -#define frag_color gl_FragColor +#define frag_data gl_FragData #endif ///////////////////////////////////////////////////////////////////////// @@ -74,28 +76,37 @@ void main() vec2 uv3 = vary_texcoord2.xy; vec2 uv4 = vary_texcoord3.xy; - vec2 disturbance = vec2(cloudNoise(uv1 / 16.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + vec2 disturbance = vec2(cloudNoise(uv1 / 8.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); + vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); // Offset texture coords - uv1 += cloud_pos_density1.xy + disturbance; //large texture, visible density + uv1 += cloud_pos_density1.xy + (disturbance * 0.02); //large texture, visible density uv2 += cloud_pos_density1.xy; //large texture, self shadow - uv3 += cloud_pos_density2.xy + disturbance; //small texture, visible density + uv3 += cloud_pos_density2.xy; //small texture, visible density uv4 += cloud_pos_density2.xy; //small texture, self shadow + float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y)); + + cloudDensity *= 1.0 - (density_variance * density_variance); // Compute alpha1, the main cloud opacity float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z; - alpha1 = min(max(alpha1 + cloudDensity, 0.) * (10. + disturbance.y) * cloud_pos_density1.z, 1.); + alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10 * cloud_pos_density1.z, 1.); // And smooth alpha1 = 1. - alpha1 * alpha1; alpha1 = 1. - alpha1 * alpha1; + if (alpha1 < 0.001f) + { + discard; + } + // Compute alpha2, for self shadowing effect // (1 - alpha2) will later be used as percentage of incoming sunlight float alpha2 = (cloudNoise(uv2).x - 0.5); - alpha2 = min(max(alpha2 + cloudDensity, 0.) * (2.5 + disturbance.x) * cloud_pos_density1.z, 1.); + alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); // And smooth alpha2 = 1. - alpha2; @@ -107,7 +118,8 @@ void main() color *= 2.; /// Gamma correct for WL (soft clip effect). - frag_color.rgb = scaleSoftClip(color.rgb); - frag_color.a = alpha1; + frag_data[0] = vec4(scaleSoftClip(color.rgb), alpha1); + frag_data[1] = vec4(0.0,0.0,0.0,0.0); + frag_data[2] = vec4(0,0,1,0); } diff --git a/indra/newview/lldrawpoolground.cpp b/indra/newview/lldrawpoolground.cpp index e5ce0413b1..bae07a171b 100644 --- a/indra/newview/lldrawpoolground.cpp +++ b/indra/newview/lldrawpoolground.cpp @@ -63,13 +63,9 @@ void LLDrawPoolGround::render(S32 pass) return; } - LLGLSPipelineSkyBox gls_skybox; + LLGLSPipelineDepthTestSkyBox gls_skybox(true, false); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - - LLGLSquashToFarClip far_clip(get_current_projection()); - F32 water_height = gAgent.getRegion()->getWaterHeight(); gGL.pushMatrix(); LLVector3 origin = LLViewerCamera::getInstance()->getOrigin(); @@ -77,8 +73,6 @@ void LLDrawPoolGround::render(S32 pass) LLFace *facep = mDrawFace[0]; - gPipeline.disableLights(); - LLOverrideFaceColor col(this, gSky.mVOSkyp->getGLFogColor()); facep->renderIndexed(); diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index c4560e89f4..9f3cf8f78e 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -29,20 +29,20 @@ #include "lldrawpoolwlsky.h" #include "llerror.h" -#include "llgl.h" -#include "pipeline.h" -#include "llviewercamera.h" +#include "llface.h" #include "llimage.h" -#include "llviewershadermgr.h" +#include "llrender.h" +#include "llatmosphere.h" +#include "llenvironment.h" #include "llglslshader.h" +#include "llgl.h" + +#include "llviewerregion.h" +#include "llviewershadermgr.h" +#include "llviewercamera.h" +#include "pipeline.h" #include "llsky.h" #include "llvowlsky.h" -#include "llviewerregion.h" -#include "llface.h" -#include "llrender.h" - -#include "llenvironment.h" -#include "llatmosphere.h" static LLStaticHashedString sCamPosLocal("camPosLocal"); static LLStaticHashedString sCustomAlpha("custom_alpha"); @@ -163,10 +163,12 @@ void LLDrawPoolWLSky::renderDome(const LLVector3& camPosLocal, F32 camHeightLoca gGL.popMatrix(); } -void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const +void LLDrawPoolWLSky::renderSkyHazeAdvanced(const LLVector3& camPosLocal, F32 camHeightLocal) const { if (gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders() && gAtmosphere) { + LLGLSPipelineDepthTestSkyBox sky(true, false); + sky_shader->bind(); // bind precomputed textures necessary for calculating sun and sky luminance @@ -208,20 +210,20 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->uniform3f(sCamPosLocal, camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]); - LLGLDisable cull(GL_CULL_FACE); renderFsSky(camPosLocal, camHeightLocal, sky_shader); sky_shader->unbind(); } } -void LLDrawPoolWLSky::renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const +void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const { LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) { - LLGLDisable blend(GL_BLEND); + LLGLSPipelineDepthTestSkyBox sky(true, false); + sky_shader->bind(); LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); @@ -247,19 +249,28 @@ void LLDrawPoolWLSky::renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightL } } +void LLDrawPoolWLSky::renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const +{ + LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); + + if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) + { + LLGLSPipelineDepthTestSkyBox sky(true, false); + sky_shader->bind(); + renderDome(origin, camHeightLocal, sky_shader); + sky_shader->unbind(); + } +} + void LLDrawPoolWLSky::renderStars(void) const { - LLGLSPipelineSkyBox gls_sky; - LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_ALPHA); + LLGLSPipelineBlendSkyBox gls_skybox(true, false); // *NOTE: have to have bound the cloud noise texture already since register // combiners blending below requires something to be bound // and we might as well only bind once. gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - gPipeline.disableLights(); - // *NOTE: we divide by two here and GL_ALPHA_SCALE by two below to avoid // clamping and allow the star_alpha param to brighten the stars. LLColor4 star_alpha(LLColor4::black); @@ -323,9 +334,7 @@ void LLDrawPoolWLSky::renderStars(void) const void LLDrawPoolWLSky::renderStarsDeferred(void) const { - LLGLSPipelineSkyBox gls_sky; - LLGLEnable blend(GL_BLEND); - LLGLDepthTest depth_test(GL_TRUE, GL_FALSE, GL_LESS); + LLGLSPipelineBlendSkyBox gls_sky(true, false); gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); @@ -384,39 +393,183 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const gDeferredStarProgram.unbind(); } -void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeightLocal) const +void LLDrawPoolWLSky::renderSkyCloudsAdvanced(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader* cloudshader) const +{ + if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && gSky.mVOSkyp->getCloudNoiseTex()) + { + LLGLSPipelineBlendSkyBox pipeline(true, true); + + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + cloudshader->bind(); + + LLPointer<LLViewerTexture> cloud_noise = gSky.mVOSkyp->getCloudNoiseTex(); + LLPointer<LLViewerTexture> cloud_noise_next = gSky.mVOSkyp->getCloudNoiseTexNext(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + + F32 cloud_variance = psky ? psky->getCloudVariance() : 0.0f; + F32 blend_factor = psky ? psky->getBlendFactor() : 0.0f; + + // if we even have sun disc textures to work with... + if (cloud_noise || cloud_noise_next) + { + if (cloud_noise && (!cloud_noise_next || (cloud_noise == cloud_noise_next))) + { + // Bind current and next sun textures + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (cloud_noise_next && !cloud_noise) + { + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise_next, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (cloud_noise_next != cloud_noise) + { + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise, LLTexUnit::TT_TEXTURE); + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP_NEXT, cloud_noise_next, LLTexUnit::TT_TEXTURE); + } + } + + cloudshader->bindTexture(LLShaderMgr::TRANSMITTANCE_TEX, gAtmosphere->getTransmittance()); + cloudshader->bindTexture(LLShaderMgr::SCATTER_TEX, gAtmosphere->getScattering()); + cloudshader->bindTexture(LLShaderMgr::SINGLE_MIE_SCATTER_TEX, gAtmosphere->getMieScattering()); + cloudshader->bindTexture(LLShaderMgr::ILLUMINANCE_TEX, gAtmosphere->getIlluminance()); + + LLVector3 sun_dir = LLEnvironment::instance().getSunDirection(); + LLVector3 moon_dir = LLEnvironment::instance().getMoonDirection(); + + F32 sunSize = (float)cosf(psky->getSunArcRadians()); + cloudshader->uniform1f(LLShaderMgr::SUN_SIZE, sunSize); + cloudshader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, sun_dir.mV); + cloudshader->uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, moon_dir.mV); + + cloudshader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + cloudshader->uniform1f(LLShaderMgr::CLOUD_VARIANCE, cloud_variance); + + cloudshader->uniform3f(sCamPosLocal, camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]); + + /// Render the skydome + renderDome(camPosLocal, camHeightLocal, cloudshader); + + cloudshader->unbind(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + } +} + +void LLDrawPoolWLSky::renderSkyCloudsDeferred(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader* cloudshader) const { if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && gSky.mVOSkyp->getCloudNoiseTex()) { - LLGLDepthTest depth(GL_TRUE, GL_TRUE); - LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_ALPHA); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + LLGLSPipelineBlendSkyBox pipeline(true, true); - cloud_shader->bind(); + cloudshader->bind(); + + LLPointer<LLViewerTexture> cloud_noise = gSky.mVOSkyp->getCloudNoiseTex(); + LLPointer<LLViewerTexture> cloud_noise_next = gSky.mVOSkyp->getCloudNoiseTexNext(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + + F32 cloud_variance = psky ? psky->getCloudVariance() : 0.0f; + F32 blend_factor = psky ? psky->getBlendFactor() : 0.0f; - cloud_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, gSky.mVOSkyp->getCloudNoiseTex()); - cloud_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP_NEXT, gSky.mVOSkyp->getCloudNoiseTexNext()); + // if we even have sun disc textures to work with... + if (cloud_noise || cloud_noise_next) + { + if (cloud_noise && (!cloud_noise_next || (cloud_noise == cloud_noise_next))) + { + // Bind current and next sun textures + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (cloud_noise_next && !cloud_noise) + { + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise_next, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (cloud_noise_next != cloud_noise) + { + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise, LLTexUnit::TT_TEXTURE); + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP_NEXT, cloud_noise_next, LLTexUnit::TT_TEXTURE); + } + } + cloudshader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + cloudshader->uniform1f(LLShaderMgr::CLOUD_VARIANCE, cloud_variance); + + /// Render the skydome + renderDome(camPosLocal, camHeightLocal, cloudshader); + + cloudshader->unbind(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + } +} + +void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader* cloudshader) const +{ + if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && gSky.mVOSkyp->getCloudNoiseTex()) + { LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - F32 blend_factor = psky ? psky->getBlendFactor() : 0.0f; + LLGLSPipelineBlendSkyBox pipeline(true, true); + + cloudshader->bind(); + + LLPointer<LLViewerTexture> cloud_noise = gSky.mVOSkyp->getCloudNoiseTex(); + LLPointer<LLViewerTexture> cloud_noise_next = gSky.mVOSkyp->getCloudNoiseTexNext(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + F32 cloud_variance = psky ? psky->getCloudVariance() : 0.0f; + F32 blend_factor = psky ? psky->getBlendFactor() : 0.0f; + + // if we even have sun disc textures to work with... + if (cloud_noise || cloud_noise_next) + { + if (cloud_noise && (!cloud_noise_next || (cloud_noise == cloud_noise_next))) + { + // Bind current and next sun textures + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (cloud_noise_next && !cloud_noise) + { + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise_next, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (cloud_noise_next != cloud_noise) + { + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, cloud_noise, LLTexUnit::TT_TEXTURE); + cloudshader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP_NEXT, cloud_noise_next, LLTexUnit::TT_TEXTURE); + } + } - cloud_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); - cloud_shader->uniform1f(LLShaderMgr::CLOUD_VARIANCE, cloud_variance); + cloudshader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + cloudshader->uniform1f(LLShaderMgr::CLOUD_VARIANCE, cloud_variance); /// Render the skydome - renderDome(camPosLocal, camHeightLocal, cloud_shader); + renderDome(camPosLocal, camHeightLocal, cloudshader); + + cloudshader->unbind(); - cloud_shader->unbind(); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); } } void LLDrawPoolWLSky::renderHeavenlyBodies() { - LLGLSPipelineSkyBox gls_skybox; - LLGLEnable blend_on(GL_BLEND); - gPipeline.disableLights(); + LLGLSPipelineBlendSkyBox gls_skybox(true, false); LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); gGL.pushMatrix(); @@ -540,35 +693,26 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) const F32 camHeightLocal = LLEnvironment::instance().getCamHeight(); - LLGLSNoFog disableFog; - LLGLDisable clip(GL_CLIP_PLANE0); - gGL.setColorMask(true, false); - LLGLSquashToFarClip far_clip(get_current_projection()); - LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); if (gPipeline.canUseWindLightShaders()) { + if (gPipeline.useAdvancedAtmospherics()) { - // Disable depth-writes for sky, but re-enable depth writes for the cloud - // rendering below so the cloud shader can write out depth for the stars to test against - LLGLDepthTest depth(GL_TRUE, GL_FALSE); - - if (gPipeline.useAdvancedAtmospherics()) - { - renderSkyHazeDeferred(origin, camHeightLocal); - } - else - { - renderSkyHaze(origin, camHeightLocal); - } + renderSkyHazeAdvanced(origin, camHeightLocal); + renderHeavenlyBodies(); + renderSkyCloudsAdvanced(origin, camHeightLocal, cloud_shader); + } + else + { + renderSkyHazeDeferred(origin, camHeightLocal); renderHeavenlyBodies(); + renderSkyCloudsDeferred(origin, camHeightLocal, cloud_shader); } + } - renderSkyClouds(origin, camHeightLocal); - } gGL.setColorMask(true, true); } @@ -576,21 +720,12 @@ void LLDrawPoolWLSky::renderPostDeferred(S32 pass) { LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); - LLGLSNoFog disableFog; - LLGLDisable clip(GL_CLIP_PLANE0); - LLGLSquashToFarClip far_clip(get_current_projection()); + LLGLSPipelineBlendSkyBox sky(true, false); gGL.pushMatrix(); gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); - gGL.setColorMask(true, false); - - // would be nice to do this here, but would need said bodies - // to render at a realistic distance for depth-testing against the clouds... - //renderHeavenlyBodies(); renderStarsDeferred(); - gGL.popMatrix(); - gGL.setColorMask(true, true); } void LLDrawPoolWLSky::render(S32 pass) @@ -602,35 +737,14 @@ void LLDrawPoolWLSky::render(S32 pass) LL_RECORD_BLOCK_TIME(FTM_RENDER_WL_SKY); const F32 camHeightLocal = LLEnvironment::instance().getCamHeight(); - - LLGLSNoFog disableFog; - LLGLDepthTest depth(GL_TRUE, GL_FALSE); - LLGLDisable clip(GL_CLIP_PLANE0); - - LLGLSquashToFarClip far_clip(get_current_projection()); - LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); - renderSkyHaze(origin, camHeightLocal); - - gGL.pushMatrix(); - - // MAINT-9006 keep sun position consistent between ALM and non-ALM rendering - //gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); - - // *NOTE: have to bind a texture here since register combiners blending in - // renderStars() requires something to be bound and we might as well only - // bind the moon's texture once. - gGL.getTexUnit(0)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture()); - gGL.getTexUnit(1)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture(LLRender::ALTERNATE_DIFFUSE_MAP)); - - renderHeavenlyBodies(); - - renderStars(); - - gGL.popMatrix(); + LLGLSPipelineBlendSkyBox sky(true, false); - renderSkyClouds(origin, camHeightLocal); + renderSkyHaze(origin, camHeightLocal); + renderStars(); + renderHeavenlyBodies(); + renderSkyClouds(origin, camHeightLocal, cloud_shader); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } diff --git a/indra/newview/lldrawpoolwlsky.h b/indra/newview/lldrawpoolwlsky.h index 309efdbc5b..4338de32dc 100644 --- a/indra/newview/lldrawpoolwlsky.h +++ b/indra/newview/lldrawpoolwlsky.h @@ -81,14 +81,19 @@ public: private: void renderFsSky(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const; void renderDome(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const; - void renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const; - void renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const; - void renderStarsDeferred(void) const; + void renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const; + void renderSkyClouds(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader* cloudshader) const; + + void renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const; + void renderSkyCloudsDeferred(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader* cloudshader) const; + void renderSkyHazeAdvanced(const LLVector3& camPosLocal, F32 camHeightLocal) const; + void renderSkyCloudsAdvanced(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader* cloudshader) const; + + void renderStarsDeferred(void) const; void renderStars(void) const; - void renderSkyClouds(const LLVector3& camPosLocal, F32 camHeightLocal) const; - void renderHeavenlyBodies(); + void renderHeavenlyBodies(); }; #endif // LL_DRAWPOOLWLSKY_H diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index ae625630eb..da558a0ba3 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -885,6 +885,7 @@ void LLEnvironment::updateCloudScroll() } +// static void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting) { LL_RECORD_BLOCK_TIME(FTM_SHADER_PARAM_UPDATE); @@ -894,62 +895,19 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS for (auto &it: params) { LLSD value; - - bool found_in_settings = psetting->mSettings.has(it.first); - bool found_in_legacy_settings = !found_in_settings && psetting->mSettings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE].has(it.first); - - if (found_in_settings) - { - value = psetting->mSettings[it.first]; - } - else if (found_in_legacy_settings) + // legacy first since it contains ambient color and we prioritize value from legacy, see getAmbientColor() + if (psetting->mSettings.has(LLSettingsSky::SETTING_LEGACY_HAZE) && psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE].has(it.first)) { value = psetting->mSettings[LLSettingsSky::SETTING_LEGACY_HAZE][it.first]; } - else if (psetting->getSettingsType() == "sky") + else if (psetting->mSettings.has(it.first)) { - // Legacy atmospherics is a special case, - // these values either have non zero defaults when they are not present - // in LLSD or need to be acounted for (reset) even if they are not present - // Todo: consider better options, for example make LLSettingsSky init these options - // Todo: we should reset shaders for all missing fields, not just these ones - LLSettingsSky::ptr_t skyp = std::static_pointer_cast<LLSettingsSky>(psetting); - if (it.first == LLSettingsSky::SETTING_BLUE_DENSITY) - { - value = skyp->getBlueDensity().getValue(); - } - else if (it.first == LLSettingsSky::SETTING_BLUE_HORIZON) - { - value = skyp->getBlueHorizon().getValue(); - } - else if (it.first == LLSettingsSky::SETTING_DENSITY_MULTIPLIER) - { - value = skyp->getDensityMultiplier(); - } - else if (it.first == LLSettingsSky::SETTING_DISTANCE_MULTIPLIER) - { - value = skyp->getDistanceMultiplier(); - } - else if (it.first == LLSettingsSky::SETTING_HAZE_DENSITY) - { - value = skyp->getHazeDensity(); - } - else if (it.first == LLSettingsSky::SETTING_HAZE_HORIZON) - { - value = skyp->getHazeHorizon(); - } - else if (it.first == LLSettingsSky::SETTING_AMBIENT) - { - value = skyp->getAmbientColor().getValue(); - } - else - { - continue; - } + value = psetting->mSettings[it.first]; } else { - continue; + // We need to reset shaders, use defaults + value = it.second.getDefaultValue(); } LLSD::Type setting_type = value.type(); @@ -957,16 +915,16 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS switch (setting_type) { case LLSD::TypeInteger: - shader->uniform1i(it.second, value.asInteger()); + shader->uniform1i(it.second.getShaderKey(), value.asInteger()); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; break; case LLSD::TypeReal: - shader->uniform1f(it.second, value.asReal()); + shader->uniform1f(it.second.getShaderKey(), value.asReal()); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; break; case LLSD::TypeBoolean: - shader->uniform1i(it.second, value.asBoolean() ? 1 : 0); + shader->uniform1i(it.second.getShaderKey(), value.asBoolean() ? 1 : 0); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; break; @@ -974,8 +932,7 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS { LLVector4 vect4(value); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; - shader->uniform4fv(it.second, 1, vect4.mV); - + shader->uniform4fv(it.second.getShaderKey(), 1, vect4.mV); break; } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 31c9d290be..63020ab5d7 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -124,7 +124,7 @@ public: void update(const LLViewerCamera * cam); - void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); + static void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting); void updateShaderUniforms(LLGLSLShader *shader); void setSelectedEnvironment(EnvSelection_t env, LLSettingsBase::Seconds transition = TRANSITION_DEFAULT, bool forced = false); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index dad7fc9448..2696ad4df5 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -683,26 +683,31 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const if (param_map.empty()) { // LEGACY_ATMOSPHERICS - param_map[SETTING_AMBIENT] = LLShaderMgr::AMBIENT; - param_map[SETTING_BLUE_DENSITY] = LLShaderMgr::BLUE_DENSITY; - param_map[SETTING_BLUE_HORIZON] = LLShaderMgr::BLUE_HORIZON; - param_map[SETTING_HAZE_DENSITY] = LLShaderMgr::HAZE_DENSITY; - param_map[SETTING_HAZE_HORIZON] = LLShaderMgr::HAZE_HORIZON; - param_map[SETTING_DENSITY_MULTIPLIER] = LLShaderMgr::DENSITY_MULTIPLIER; - param_map[SETTING_DISTANCE_MULTIPLIER] = LLShaderMgr::DISTANCE_MULTIPLIER; - - param_map[SETTING_CLOUD_COLOR] = LLShaderMgr::CLOUD_COLOR; - param_map[SETTING_CLOUD_POS_DENSITY2] = LLShaderMgr::CLOUD_POS_DENSITY2; - param_map[SETTING_CLOUD_SCALE] = LLShaderMgr::CLOUD_SCALE; - param_map[SETTING_CLOUD_SHADOW] = LLShaderMgr::CLOUD_SHADOW; - param_map[SETTING_CLOUD_VARIANCE] = LLShaderMgr::CLOUD_VARIANCE; - param_map[SETTING_GLOW] = LLShaderMgr::GLOW; - param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y; - param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR; - param_map[SETTING_MOON_BRIGHTNESS] = LLShaderMgr::MOON_BRIGHTNESS; - param_map[SETTING_SKY_MOISTURE_LEVEL] = LLShaderMgr::MOISTURE_LEVEL; - param_map[SETTING_SKY_DROPLET_RADIUS] = LLShaderMgr::DROPLET_RADIUS; - param_map[SETTING_SKY_ICE_LEVEL] = LLShaderMgr::ICE_LEVEL; + + // Todo: default 'legacy' values duplicate the ones from functions like getBlueDensity() find a better home for them + // There is LLSettingsSky::defaults(), but it doesn't contain everything since it is geared towards creating new settings. + param_map[SETTING_AMBIENT] = DefaultParam(LLShaderMgr::AMBIENT, LLColor3(0.25f, 0.25f, 0.25f).getValue()); + param_map[SETTING_BLUE_DENSITY] = DefaultParam(LLShaderMgr::BLUE_DENSITY, LLColor3(0.2447f, 0.4487f, 0.7599f).getValue()); + param_map[SETTING_BLUE_HORIZON] = DefaultParam(LLShaderMgr::BLUE_HORIZON, LLColor3(0.4954f, 0.4954f, 0.6399f).getValue()); + param_map[SETTING_HAZE_DENSITY] = DefaultParam(LLShaderMgr::HAZE_DENSITY, LLSD(0.7f)); + param_map[SETTING_HAZE_HORIZON] = DefaultParam(LLShaderMgr::HAZE_HORIZON, LLSD(0.19f)); + param_map[SETTING_DENSITY_MULTIPLIER] = DefaultParam(LLShaderMgr::DENSITY_MULTIPLIER, LLSD(0.0001f)); + param_map[SETTING_DISTANCE_MULTIPLIER] = DefaultParam(LLShaderMgr::DISTANCE_MULTIPLIER, LLSD(0.8f)); + + // Following values are always present, so we can just zero these ones, but used values from defaults() + LLSD& sky_defaults = LLSettingsSky::defaults(); + param_map[SETTING_CLOUD_COLOR] = DefaultParam(LLShaderMgr::CLOUD_COLOR, sky_defaults[SETTING_CLOUD_COLOR]); + param_map[SETTING_CLOUD_POS_DENSITY2] = DefaultParam(LLShaderMgr::CLOUD_POS_DENSITY2, sky_defaults[SETTING_CLOUD_POS_DENSITY2]); + param_map[SETTING_CLOUD_SCALE] = DefaultParam(LLShaderMgr::CLOUD_SCALE, sky_defaults[SETTING_CLOUD_SCALE]); + param_map[SETTING_CLOUD_SHADOW] = DefaultParam(LLShaderMgr::CLOUD_SHADOW, sky_defaults[SETTING_CLOUD_SHADOW]); + param_map[SETTING_CLOUD_VARIANCE] = DefaultParam(LLShaderMgr::CLOUD_VARIANCE, sky_defaults[SETTING_CLOUD_VARIANCE]); + param_map[SETTING_GLOW] = DefaultParam(LLShaderMgr::GLOW, sky_defaults[SETTING_GLOW]); + param_map[SETTING_MAX_Y] = DefaultParam(LLShaderMgr::MAX_Y, sky_defaults[SETTING_MAX_Y]); + param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); + param_map[SETTING_MOON_BRIGHTNESS] = DefaultParam(LLShaderMgr::MOON_BRIGHTNESS, sky_defaults[SETTING_MOON_BRIGHTNESS]); + param_map[SETTING_SKY_MOISTURE_LEVEL] = DefaultParam(LLShaderMgr::MOISTURE_LEVEL, sky_defaults[SETTING_SKY_MOISTURE_LEVEL]); + param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); + param_map[SETTING_SKY_ICE_LEVEL] = DefaultParam(LLShaderMgr::ICE_LEVEL, sky_defaults[SETTING_SKY_ICE_LEVEL]); // AdvancedAtmospherics TODO // Provide mappings for new shader params here @@ -911,8 +916,9 @@ LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const if (param_map.empty()) { - param_map[SETTING_FOG_COLOR] = LLShaderMgr::WATER_FOGCOLOR; - param_map[SETTING_FOG_DENSITY] = LLShaderMgr::WATER_FOGDENSITY; + LLSD &water_defaults = LLSettingsWater::defaults(); + param_map[SETTING_FOG_COLOR] = DefaultParam(LLShaderMgr::WATER_FOGCOLOR, water_defaults[SETTING_FOG_COLOR]); + param_map[SETTING_FOG_DENSITY] = DefaultParam(LLShaderMgr::WATER_FOGDENSITY, water_defaults[SETTING_FOG_DENSITY]); } return param_map; } diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 7d4d737db4..9371711ca1 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1272,7 +1272,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh { LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_DRAW_WATER); - LLGLSquashToFarClip squash(get_current_projection(), 1); + LLGLSquashToFarClip squash; if (camera->getOrigin().isExactlyZero()) { //origin is invalid, draw entire box gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index d98fd34714..8a949c6b4e 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -31,25 +31,26 @@ #include "llfeaturemanager.h" #include "llviewershadermgr.h" - -#include "llfile.h" -#include "llviewerwindow.h" -#include "llwindow.h" #include "llviewercontrol.h" -#include "pipeline.h" + +#include "llrender.h" +#include "llenvironment.h" +#include "llatmosphere.h" #include "llworld.h" #include "llsky.h" #include "llvosky.h" -#include "llrender.h" + +#include "pipeline.h" + +#include "llfile.h" +#include "llviewerwindow.h" +#include "llwindow.h" + #include "lljoint.h" #include "llskinningutil.h" -#include "llenvironment.h" -#include "llatmosphere.h" -#ifdef LL_RELEASE_FOR_DOWNLOAD -#define UNIFORM_ERRS LL_WARNS_ONCE("Shader") -#else -#define UNIFORM_ERRS LL_ERRS("Shader") +#if LL_WINDOWS +#pragma optimize("", off) #endif static LLStaticHashedString sTexture0("texture0"); @@ -486,7 +487,7 @@ void LLViewerShaderMgr::setShaders() S32 effect_class = 2; S32 wl_class = 3; S32 water_class = 2; - S32 deferred_class = 0; + S32 deferred_class = 2; S32 transform_class = gGLManager.mHasTransformFeedback ? 1 : 0; static LLCachedControl<bool> use_transform_feedback(gSavedSettings, "RenderUseTransformFeedback", false); @@ -935,6 +936,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders() // Note usage of GL_VERTEX_SHADER_ARB if (loadShaderFile(shaders[i].first, shaders[i].second, GL_VERTEX_SHADER_ARB, &attribs) == 0) { + LL_SHADER_LOADING_WARNS() << "Failed to load vertex shader " << shaders[i].first << LL_ENDL; return FALSE; } } @@ -991,6 +993,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders() // Note usage of GL_FRAGMENT_SHADER_ARB if (loadShaderFile(shaders[i].first, shaders[i].second, GL_FRAGMENT_SHADER_ARB, &attribs, index_channels[i]) == 0) { + LL_SHADER_LOADING_WARNS() << "Failed to load fragment shader " << shaders[i].first << LL_ENDL; return FALSE; } } diff --git a/indra/newview/llxmlrpclistener.cpp b/indra/newview/llxmlrpclistener.cpp index 7bc8af4a0b..0693d08dfb 100644 --- a/indra/newview/llxmlrpclistener.cpp +++ b/indra/newview/llxmlrpclistener.cpp @@ -105,29 +105,12 @@ public: def(CURLE_UNSUPPORTED_PROTOCOL); /* 1 */ def(CURLE_FAILED_INIT); /* 2 */ def(CURLE_URL_MALFORMAT); /* 3 */ - def(CURLE_URL_MALFORMAT_USER); /* 4 - NOT USED */ def(CURLE_COULDNT_RESOLVE_PROXY); /* 5 */ def(CURLE_COULDNT_RESOLVE_HOST); /* 6 */ def(CURLE_COULDNT_CONNECT); /* 7 */ - def(CURLE_FTP_WEIRD_SERVER_REPLY); /* 8 */ - def(CURLE_FTP_ACCESS_DENIED); /* 9 a service was denied by the FTP server - due to lack of access - when login fails - this is not returned. */ - def(CURLE_FTP_USER_PASSWORD_INCORRECT); /* 10 - NOT USED */ - def(CURLE_FTP_WEIRD_PASS_REPLY); /* 11 */ - def(CURLE_FTP_WEIRD_USER_REPLY); /* 12 */ - def(CURLE_FTP_WEIRD_PASV_REPLY); /* 13 */ - def(CURLE_FTP_WEIRD_227_FORMAT); /* 14 */ - def(CURLE_FTP_CANT_GET_HOST); /* 15 */ - def(CURLE_FTP_CANT_RECONNECT); /* 16 */ - def(CURLE_FTP_COULDNT_SET_BINARY); /* 17 */ def(CURLE_PARTIAL_FILE); /* 18 */ - def(CURLE_FTP_COULDNT_RETR_FILE); /* 19 */ - def(CURLE_FTP_WRITE_ERROR); /* 20 */ - def(CURLE_FTP_QUOTE_ERROR); /* 21 */ def(CURLE_HTTP_RETURNED_ERROR); /* 22 */ def(CURLE_WRITE_ERROR); /* 23 */ - def(CURLE_MALFORMAT_USER); /* 24 - NOT USED */ def(CURLE_UPLOAD_FAILED); /* 25 - failed upload "command" */ def(CURLE_READ_ERROR); /* 26 - could open/read from file */ def(CURLE_OUT_OF_MEMORY); /* 27 */ @@ -135,29 +118,18 @@ public: instead of a memory allocation error if CURL_DOES_CONVERSIONS is defined */ - def(CURLE_OPERATION_TIMEOUTED); /* 28 - the timeout time was reached */ - def(CURLE_FTP_COULDNT_SET_ASCII); /* 29 - TYPE A failed */ - def(CURLE_FTP_PORT_FAILED); /* 30 - FTP PORT operation failed */ - def(CURLE_FTP_COULDNT_USE_REST); /* 31 - the REST command failed */ - def(CURLE_FTP_COULDNT_GET_SIZE); /* 32 - the SIZE command failed */ + def(CURLE_OPERATION_TIMEDOUT); /* 28 - the timeout time was reached */ def(CURLE_HTTP_RANGE_ERROR); /* 33 - RANGE "command" didn't work */ def(CURLE_HTTP_POST_ERROR); /* 34 */ def(CURLE_SSL_CONNECT_ERROR); /* 35 - wrong when connecting with SSL */ def(CURLE_BAD_DOWNLOAD_RESUME); /* 36 - couldn't resume download */ def(CURLE_FILE_COULDNT_READ_FILE); /* 37 */ - def(CURLE_LDAP_CANNOT_BIND); /* 38 */ - def(CURLE_LDAP_SEARCH_FAILED); /* 39 */ def(CURLE_LIBRARY_NOT_FOUND); /* 40 */ def(CURLE_FUNCTION_NOT_FOUND); /* 41 */ def(CURLE_ABORTED_BY_CALLBACK); /* 42 */ def(CURLE_BAD_FUNCTION_ARGUMENT); /* 43 */ - def(CURLE_BAD_CALLING_ORDER); /* 44 - NOT USED */ def(CURLE_INTERFACE_FAILED); /* 45 - CURLOPT_INTERFACE failed */ - def(CURLE_BAD_PASSWORD_ENTERED); /* 46 - NOT USED */ def(CURLE_TOO_MANY_REDIRECTS ); /* 47 - catch endless re-direct loops */ - def(CURLE_UNKNOWN_TELNET_OPTION); /* 48 - User specified an unknown option */ - def(CURLE_TELNET_OPTION_SYNTAX ); /* 49 - Malformed telnet option */ - def(CURLE_OBSOLETE); /* 50 - NOT USED */ def(CURLE_SSL_PEER_CERTIFICATE); /* 51 - peer's certificate wasn't ok */ def(CURLE_GOT_NOTHING); /* 52 - when this is a specific error */ def(CURLE_SSL_ENGINE_NOTFOUND); /* 53 - SSL crypto engine not found */ @@ -165,26 +137,19 @@ public: default */ def(CURLE_SEND_ERROR); /* 55 - failed sending network data */ def(CURLE_RECV_ERROR); /* 56 - failure in receiving network data */ - def(CURLE_SHARE_IN_USE); /* 57 - share is in use */ + def(CURLE_SSL_CERTPROBLEM); /* 58 - problem with the local certificate */ def(CURLE_SSL_CIPHER); /* 59 - couldn't use specified cipher */ def(CURLE_SSL_CACERT); /* 60 - problem with the CA cert (path?) */ def(CURLE_BAD_CONTENT_ENCODING); /* 61 - Unrecognized transfer encoding */ - def(CURLE_LDAP_INVALID_URL); /* 62 - Invalid LDAP URL */ + def(CURLE_FILESIZE_EXCEEDED); /* 63 - Maximum file size exceeded */ - def(CURLE_FTP_SSL_FAILED); /* 64 - Requested FTP SSL level failed */ + def(CURLE_SEND_FAIL_REWIND); /* 65 - Sending the data requires a rewind that failed */ def(CURLE_SSL_ENGINE_INITFAILED); /* 66 - failed to initialise ENGINE */ def(CURLE_LOGIN_DENIED); /* 67 - user); password or similar was not accepted and we failed to login */ - def(CURLE_TFTP_NOTFOUND); /* 68 - file not found on server */ - def(CURLE_TFTP_PERM); /* 69 - permission problem on server */ - def(CURLE_TFTP_DISKFULL); /* 70 - out of disk space on server */ - def(CURLE_TFTP_ILLEGAL); /* 71 - Illegal TFTP operation */ - def(CURLE_TFTP_UNKNOWNID); /* 72 - Unknown transfer ID */ - def(CURLE_TFTP_EXISTS); /* 73 - File already exists */ - def(CURLE_TFTP_NOSUCHUSER); /* 74 - No such user */ def(CURLE_CONV_FAILED); /* 75 - conversion failed */ def(CURLE_CONV_REQD); /* 76 - caller must register conversion callbacks using curl_easy_setopt options |