diff options
Diffstat (limited to 'indra')
80 files changed, 1480 insertions, 1539 deletions
diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 39dfee3755..8739eeef00 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -65,6 +65,9 @@ LLTimer* LLTimer::sTimer = NULL; //--------------------------------------------------------------------------- #if LL_WINDOWS + + +#if 0 void ms_sleep(U32 ms) { LL_PROFILE_ZONE_SCOPED; @@ -83,6 +86,31 @@ U32 micro_sleep(U64 us, U32 max_yields) ms_sleep((U32)(us / 1000)); return 0; } + +#else + +U32 micro_sleep(U64 us, U32 max_yields) +{ + LL_PROFILE_ZONE_SCOPED + LARGE_INTEGER ft; + ft.QuadPart = -static_cast<S64>(us * 10); // '-' using relative time + + HANDLE timer = CreateWaitableTimer(NULL, TRUE, NULL); + SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); + WaitForSingleObject(timer, INFINITE); + CloseHandle(timer); + + return 0; +} + +void ms_sleep(U32 ms) +{ + LL_PROFILE_ZONE_SCOPED + micro_sleep(ms * 1000, 0); +} + +#endif + #elif LL_LINUX || LL_DARWIN static void _sleep_loop(struct timespec& thiswait) { diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h index 60353bea6e..d925f56e97 100644 --- a/indra/llmath/v3color.h +++ b/indra/llmath/v3color.h @@ -88,6 +88,16 @@ public: const LLColor3& set(F32 x, F32 y, F32 z); // Sets LLColor3 to (x, y, z) const LLColor3& set(const LLColor3 &vec); // Sets LLColor3 to vec const LLColor3& set(const F32 *vec); // Sets LLColor3 to vec + + // set from a vector of unknown type and size + // may leave some data unmodified + template<typename T> + const LLColor3& set(const std::vector<T>& v); + + // write to a vector of unknown type and size + // maye leave some data unmodified + template<typename T> + void write(std::vector<T>& v) const; F32 magVec() const; // deprecated F32 magVecSquared() const; // deprecated @@ -485,7 +495,7 @@ inline const LLColor3 srgbColor3(const LLColor3 &a) { return srgbColor; } -inline const LLColor3 linearColor3(const F32* v) { +inline const LLColor3 linearColor3p(const F32* v) { LLColor3 linearColor; linearColor.mV[0] = sRGBtoLinear(v[0]); linearColor.mV[1] = sRGBtoLinear(v[1]); @@ -496,12 +506,34 @@ inline const LLColor3 linearColor3(const F32* v) { template<class T> inline const LLColor3 linearColor3(const T& a) { - return linearColor3(a.mV); + return linearColor3p(a.mV); } template<class T> inline const LLVector3 linearColor3v(const T& a) { - return LLVector3(linearColor3(a.mV).mV); + return LLVector3(linearColor3p(a.mV).mV); +} + +template<typename T> +const LLColor3& LLColor3::set(const std::vector<T>& v) +{ + for (S32 i = 0; i < llmin((S32)v.size(), 3); ++i) + { + mV[i] = v[i]; + } + + return *this; +} + +// write to a vector of unknown type and size +// maye leave some data unmodified +template<typename T> +void LLColor3::write(std::vector<T>& v) const +{ + for (int i = 0; i < llmin((S32)v.size(), 3); ++i) + { + v[i] = mV[i]; + } } #endif diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index f2863be531..daa61594fb 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -91,6 +91,15 @@ class LLColor4 const LLColor4& set(const F64 *vec); // Sets LLColor4 to (double)vec const LLColor4& set(const LLColor4U& color4u); // Sets LLColor4 to color4u, rescaled. + // set from a vector of unknown type and size + // may leave some data unmodified + template<typename T> + const LLColor4& set(const std::vector<T>& v); + + // write to a vector of unknown type and size + // maye leave some data unmodified + template<typename T> + void write(std::vector<T>& v) const; const LLColor4& setAlpha(F32 a); @@ -690,5 +699,25 @@ inline const LLColor4 linearColor4(const LLColor4 &a) return linearColor; } +template<typename T> +const LLColor4& LLColor4::set(const std::vector<T>& v) +{ + for (S32 i = 0; i < llmin((S32)v.size(), 4); ++i) + { + mV[i] = v[i]; + } + + return *this; +} + +template<typename T> +void LLColor4::write(std::vector<T>& v) const +{ + for (int i = 0; i < llmin((S32)v.size(), 4); ++i) + { + v[i] = mV[i]; + } +} + #endif diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index bb14bb9242..328b22f900 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -33,6 +33,7 @@ include_directories(SYSTEM set(llprimitive_SOURCE_FILES lldaeloader.cpp llgltfloader.cpp + llgltfmaterial.cpp llmaterialid.cpp llmaterial.cpp llmaterialtable.cpp diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp new file mode 100644 index 0000000000..951b768678 --- /dev/null +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -0,0 +1,293 @@ +/** + * @file llgltfmaterial.cpp + * @brief Material definition + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llgltfmaterial.h" + +#include "tiny_gltf.h" + +bool LLGLTFMaterial::fromJSON(const std::string& json, std::string& warn_msg, std::string& error_msg) +{ + tinygltf::TinyGLTF gltf; + + tinygltf::Model model_in; + + if (gltf.LoadASCIIFromString(&model_in, &error_msg, &warn_msg, json.c_str(), json.length(), "")) + { + setFromModel(model_in, 0); + + //DEBUG generate json and print + LL_INFOS() << asJSON(true) << LL_ENDL; + + return true; + } + + return false; +} + +std::string LLGLTFMaterial::asJSON(bool prettyprint) const +{ + tinygltf::TinyGLTF gltf; + tinygltf::Model model_out; + + std::ostringstream str; + + writeToModel(model_out, 0); + + gltf.WriteGltfSceneToStream(&model_out, str, prettyprint, false); + + return str.str(); +} + +void LLGLTFMaterial::setFromModel(const tinygltf::Model& model, S32 mat_index) +{ + if (model.materials.size() <= mat_index) + { + return; + } + + const tinygltf::Material& material_in = model.materials[mat_index]; + + // get base color texture + S32 tex_index = material_in.pbrMetallicRoughness.baseColorTexture.index; + if (tex_index >= 0) + { + mBaseColorId.set(model.images[tex_index].uri); + } + else + { + mBaseColorId.setNull(); + } + + // get normal map + tex_index = material_in.normalTexture.index; + if (tex_index >= 0) + { + mNormalId.set(model.images[tex_index].uri); + } + else + { + mNormalId.setNull(); + } + + // get metallic-roughness texture + tex_index = material_in.pbrMetallicRoughness.metallicRoughnessTexture.index; + if (tex_index >= 0) + { + mMetallicRoughnessId.set(model.images[tex_index].uri); + } + else + { + mMetallicRoughnessId.setNull(); + } + + // get emissive texture + tex_index = material_in.emissiveTexture.index; + if (tex_index >= 0) + { + mEmissiveId.set(model.images[tex_index].uri); + } + else + { + mEmissiveId.setNull(); + } + + setAlphaMode(material_in.alphaMode); + mAlphaCutoff = llclamp((F32)material_in.alphaCutoff, 0.f, 1.f); + + mBaseColor.set(material_in.pbrMetallicRoughness.baseColorFactor); + mEmissiveColor.set(material_in.emissiveFactor); + + mMetallicFactor = llclamp((F32)material_in.pbrMetallicRoughness.metallicFactor, 0.f, 1.f); + mRoughnessFactor = llclamp((F32)material_in.pbrMetallicRoughness.roughnessFactor, 0.f, 1.f); + + mDoubleSided = material_in.doubleSided; +} + +void LLGLTFMaterial::writeToModel(tinygltf::Model& model, S32 mat_index) const +{ + if (model.materials.size() < mat_index+1) + { + model.materials.resize(mat_index + 1); + } + + tinygltf::Material& material_out = model.materials[mat_index]; + + // set base color texture + if (mBaseColorId.notNull()) + { + U32 idx = model.images.size(); + model.images.resize(idx + 1); + model.textures.resize(idx + 1); + + material_out.pbrMetallicRoughness.baseColorTexture.index = idx; + model.textures[idx].source = idx; + model.images[idx].uri = mBaseColorId.asString(); + } + + // set normal texture + if (mNormalId.notNull()) + { + U32 idx = model.images.size(); + model.images.resize(idx + 1); + model.textures.resize(idx + 1); + + material_out.normalTexture.index = idx; + model.textures[idx].source = idx; + model.images[idx].uri = mNormalId.asString(); + } + + // set metallic-roughness texture + if (mMetallicRoughnessId.notNull()) + { + U32 idx = model.images.size(); + model.images.resize(idx + 1); + model.textures.resize(idx + 1); + + material_out.pbrMetallicRoughness.metallicRoughnessTexture.index = idx; + model.textures[idx].source = idx; + model.images[idx].uri = mMetallicRoughnessId.asString(); + } + + // set emissive texture + if (mEmissiveId.notNull()) + { + U32 idx = model.images.size(); + model.images.resize(idx + 1); + model.textures.resize(idx + 1); + + material_out.emissiveTexture.index = idx; + model.textures[idx].source = idx; + model.images[idx].uri = mEmissiveId.asString(); + } + + material_out.alphaMode = getAlphaMode(); + material_out.alphaCutoff = mAlphaCutoff; + + mBaseColor.write(material_out.pbrMetallicRoughness.baseColorFactor); + mEmissiveColor.write(material_out.emissiveFactor); + + material_out.pbrMetallicRoughness.metallicFactor = mMetallicFactor; + material_out.pbrMetallicRoughness.roughnessFactor = mRoughnessFactor; + + material_out.doubleSided = mDoubleSided; +} + +void LLGLTFMaterial::writeOverridesToModel(tinygltf::Model & model, S32 mat_index, LLGLTFMaterial const * base_material) const +{ + if (model.materials.size() < mat_index+1) + { + model.materials.resize(mat_index + 1); + } + + tinygltf::Material& material_out = model.materials[mat_index]; + + // TODO - fix handling of resetting to null/default values + + // set base color texture + if (mBaseColorId.notNull() && mBaseColorId != base_material->mBaseColorId) + { + U32 idx = model.images.size(); + model.images.resize(idx + 1); + model.textures.resize(idx + 1); + + material_out.pbrMetallicRoughness.baseColorTexture.index = idx; + model.textures[idx].source = idx; + model.images[idx].uri = mBaseColorId.asString(); + } + + // set normal texture + if (mNormalId.notNull() && mNormalId != base_material->mNormalId) + { + U32 idx = model.images.size(); + model.images.resize(idx + 1); + model.textures.resize(idx + 1); + + material_out.normalTexture.index = idx; + model.textures[idx].source = idx; + model.images[idx].uri = mNormalId.asString(); + } + + // set metallic-roughness texture + if (mMetallicRoughnessId.notNull() && mMetallicRoughnessId != base_material->mMetallicRoughnessId) + { + U32 idx = model.images.size(); + model.images.resize(idx + 1); + model.textures.resize(idx + 1); + + material_out.pbrMetallicRoughness.metallicRoughnessTexture.index = idx; + model.textures[idx].source = idx; + model.images[idx].uri = mMetallicRoughnessId.asString(); + } + + // set emissive texture + if (mEmissiveId.notNull() && mEmissiveId != base_material->mEmissiveId) + { + U32 idx = model.images.size(); + model.images.resize(idx + 1); + model.textures.resize(idx + 1); + + material_out.emissiveTexture.index = idx; + model.textures[idx].source = idx; + model.images[idx].uri = mEmissiveId.asString(); + } + + if(mAlphaMode != base_material->mAlphaMode) + { + material_out.alphaMode = getAlphaMode(); + } + + if(mAlphaCutoff != base_material->mAlphaCutoff) + { + material_out.alphaCutoff = mAlphaCutoff; + } + + if(mBaseColor != base_material->mBaseColor) + { + mBaseColor.write(material_out.pbrMetallicRoughness.baseColorFactor); + } + + if(mEmissiveColor != base_material->mEmissiveColor) + { + mEmissiveColor.write(material_out.emissiveFactor); + } + + if(mMetallicFactor != base_material->mMetallicFactor) + { + material_out.pbrMetallicRoughness.metallicFactor = mMetallicFactor; + } + + if(mRoughnessFactor != base_material->mRoughnessFactor) + { + material_out.pbrMetallicRoughness.roughnessFactor = mRoughnessFactor; + } + + if(mDoubleSided != base_material->mDoubleSided) + { + material_out.doubleSided = mDoubleSided; + } +} diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index 36636c3b4e..e8d1d67f1b 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -32,6 +32,13 @@ #include "lluuid.h" #include "llmd5.h" +#include <string> + +namespace tinygltf +{ + class Model; +} + class LLGLTFMaterial : public LLRefCount { public: @@ -48,8 +55,8 @@ public: LLUUID mMetallicRoughnessId; LLUUID mEmissiveId; - LLColor4 mBaseColor = LLColor4(1,1,1,1); - LLColor3 mEmissiveColor = LLColor3(0,0,0); + LLColor4 mBaseColor = LLColor4(1, 1, 1, 1); + LLColor3 mEmissiveColor = LLColor3(0, 0, 0); F32 mMetallicFactor = 0.f; F32 mRoughnessFactor = 0.f; @@ -63,7 +70,7 @@ public: { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; LLMD5 md5; - md5.update((unsigned char*) this, sizeof(this)); + md5.update((unsigned char*)this, sizeof(this)); md5.finalize(); LLUUID id; md5.raw_digest(id.mData); @@ -88,7 +95,7 @@ public: } } - const char* getAlphaMode() + const char* getAlphaMode() const { switch (mAlphaMode) { @@ -97,7 +104,26 @@ public: default: return "OPAQUE"; } } -}; + // set the contents of this LLGLTFMaterial from the given json + // returns true if successful + // json - the json text to load from + // warn_msg - warning message from TinyGLTF if any + // error_msg - error_msg from TinyGLTF if any + bool fromJSON(const std::string& json, std::string& warn_msg, std::string& error_msg); + // get the contents of this LLGLTFMaterial as a json string + std::string asJSON(bool prettyprint = false) const; + + // initialize from given tinygltf::Model + // model - the model to reference + // mat_index - index of material in model's material array + void setFromModel(const tinygltf::Model& model, S32 mat_index); + + // write to given tinygltf::Model + void writeToModel(tinygltf::Model& model, S32 mat_index) const; + + // calculate the fields in this material that differ from a base material and write them out to a given tinygltf::Model + void writeOverridesToModel(tinygltf::Model & model, S32 mat_index, LLGLTFMaterial const * base_material) const; +}; diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 2dbff3ffd0..9ea6bfdb4e 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -86,13 +86,13 @@ void APIENTRY gl_debug_callback(GLenum source, const GLchar* message, GLvoid* userParam) { - /*if (severity != GL_DEBUG_SEVERITY_HIGH // && - severity != GL_DEBUG_SEVERITY_MEDIUM && - severity != GL_DEBUG_SEVERITY_LOW + if (severity != GL_DEBUG_SEVERITY_HIGH // && + //severity != GL_DEBUG_SEVERITY_MEDIUM && + //severity != GL_DEBUG_SEVERITY_LOW ) { //suppress out-of-spec messages sent by nvidia driver (mostly vertexbuffer hints) return; - }*/ + } if (severity == GL_DEBUG_SEVERITY_HIGH) { diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index fd69f43f87..3401da832e 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -118,6 +118,11 @@ public: mVector3s.push_back({ index, value }); } + void uniform3fv(S32 index, const F32* value) + { + mVector3s.push_back({ index, LLVector3(value) }); + } + void apply(LLGLSLShader* shader); diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 6e659641fe..409b03f425 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -974,11 +974,11 @@ void LLRender::syncLightState() shader->uniform4fv(LLShaderMgr::LIGHT_ATTENUATION, LL_NUM_LIGHT_UNITS, attenuation[0].mV); shader->uniform2fv(LLShaderMgr::LIGHT_DEFERRED_ATTENUATION, LL_NUM_LIGHT_UNITS, size[0].mV); shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, LL_NUM_LIGHT_UNITS, diffuse[0].mV); - shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV); + shader->uniform3fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV); shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_primary[0] ? 1 : 0); - shader->uniform4fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV); - shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); - shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV); + shader->uniform3fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV); + shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); + shader->uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV); } } diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index a363eac59e..7f7829c18e 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1357,6 +1357,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("specular"); mReservedUniforms.push_back("lightExp"); mReservedUniforms.push_back("waterFogColor"); + mReservedUniforms.push_back("waterFogColorLinear"); mReservedUniforms.push_back("waterFogDensity"); mReservedUniforms.push_back("waterFogKS"); mReservedUniforms.push_back("refScale"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index b803a8b129..6d2138f405 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -205,6 +205,7 @@ public: WATER_SPECULAR, // "specular" WATER_SPECULAR_EXP, // "lightExp" WATER_FOGCOLOR, // "waterFogColor" + WATER_FOGCOLOR_LINEAR, // "waterFogColorLinear" WATER_FOGDENSITY, // "waterFogDensity" WATER_FOGKS, // "waterFogKS" WATER_REFSCALE, // "refScale" diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index aadf895271..6beb874e8c 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -66,6 +66,7 @@ #include <d3d9.h> #include <dxgi1_4.h> +#include <timeapi.h> // Require DirectInput version 8 #define DIRECTINPUT_VERSION 0x0800 @@ -4827,6 +4828,14 @@ void LLWindowWin32::LLWindowWin32Thread::run() initDX(); + //as good a place as any to up the MM timer resolution (see ms_sleep) + //attempt to set timer resolution to 1ms + TIMECAPS tc; + if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) == TIMERR_NOERROR) + { + timeBeginPeriod(llclamp((U32) 1, tc.wPeriodMin, tc.wPeriodMax)); + } + while (! getQueue().done()) { LL_PROFILE_ZONE_SCOPED_CATEGORY_WIN32; diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index bfc41e3153..1882f75de9 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1701,13 +1701,10 @@ set(viewer_APPSETTINGS_FILES app_settings/cmd_line.xml app_settings/commands.xml app_settings/grass.xml - app_settings/high_graphics.xml app_settings/ignorable_dialogs.xml app_settings/key_bindings.xml app_settings/keywords_lsl_default.xml app_settings/logcontrol.xml - app_settings/low_graphics.xml - app_settings/mid_graphics.xml app_settings/settings.xml app_settings/settings_crash_behavior.xml app_settings/settings_files.xml @@ -1715,7 +1712,6 @@ set(viewer_APPSETTINGS_FILES app_settings/std_bump.ini app_settings/toolbars.xml app_settings/trees.xml - app_settings/ultra_graphics.xml app_settings/viewerart.xml ${CMAKE_SOURCE_DIR}/../etc/message.xml ${CMAKE_SOURCE_DIR}/../scripts/messages/message_template.msg diff --git a/indra/newview/app_settings/high_graphics.xml b/indra/newview/app_settings/high_graphics.xml deleted file mode 100644 index f64937f443..0000000000 --- a/indra/newview/app_settings/high_graphics.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<settings version = "101"> - <!--NO SHADERS--> - <RenderAvatarCloth value="FALSE"/> - <!--Default for now--> - <RenderAvatarLODFactor value="1.0"/> - <!--Default for now--> - <RenderAvatarPhysicsLODFactor value="0.9"/> - <!--Short Range--> - <RenderFarClip value="128"/> - <!--Default for now--> - <RenderFlexTimeFactor value="1"/> - <!--256... but they do not use this--> - <RenderGlowResolutionPow value="9"/> - <!--Low number--> - <RenderMaxPartCount value="4096"/> - <!--bump okay--> - <RenderObjectBump value="TRUE"/> - <!--NO SHADERS--> - <RenderReflectionDetail value="2"/> - <!--Simple--> - <RenderTerrainDetail value="1"/> - <!--Default for now--> - <RenderTerrainLODFactor value="2"/> - <!--Default for now--> - <RenderTreeLODFactor value="0.5"/> - <!--Avater Impostors and Visual Muting Limits--> - <RenderAvatarMaxNonImpostors value="20"/> - <RenderAvatarMaxComplexity value="350000"/> - <RenderAutoMuteSurfaceAreaLimit value="1250.0"/> - <!--Default for now--> - <RenderVolumeLODFactor value="1.125"/> - <!--NO SHADERS--> - <WindLightUseAtmosShaders value="TRUE"/> - <!--Deferred Shading--> - <RenderDeferred value="FALSE"/> - <!--SSAO Disabled--> - <RenderDeferredSSAO value="FALSE"/> - <!--Sun Shadows--> - <RenderShadowDetail value="0"/> -</settings> diff --git a/indra/newview/app_settings/low_graphics.xml b/indra/newview/app_settings/low_graphics.xml deleted file mode 100644 index b31a040d67..0000000000 --- a/indra/newview/app_settings/low_graphics.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<settings version = "101"> - <!--NO SHADERS--> - <RenderAvatarCloth value="FALSE"/> - <!--Default for now--> - <RenderAvatarLODFactor value="0.5"/> - <!--Default for now--> - <RenderAvatarPhysicsLODFactor value="0.0"/> - <!--Short Range--> - <RenderFarClip value="64"/> - <!--Default for now--> - <RenderFlexTimeFactor value="0.5"/> - <!--256... but they do not use this--> - <RenderGlowResolutionPow value="8"/> - <!--Low number--> - <RenderMaxPartCount value="1024"/> - <!--bump okay--> - <RenderObjectBump value="FALSE"/> - <!--NO SHADERS--> - <RenderReflectionDetail value="0"/> - <!--Simple--> - <RenderTerrainDetail value="0"/> - <!--Default for now--> - <RenderTerrainLODFactor value="1.0"/> - <!--Default for now--> - <RenderTreeLODFactor value="0.5"/> - <!--Avater Impostors and Visual Muting Limits--> - <RenderAvatarMaxNonImpostors value="12"/> - <RenderAvatarMaxComplexity value="80000"/> - <RenderAutoMuteSurfaceAreaLimit value="750.0"/> - <!--Default for now--> - <RenderVolumeLODFactor value="1.125"/> - <!--NO SHADERS--> - <WindLightUseAtmosShaders value="FALSE"/> - <!--No Deferred Shading--> - <RenderDeferred value="FALSE"/> - <!--SSAO Disabled--> - <RenderDeferredSSAO value="FALSE"/> - <!--No Shadows--> - <RenderShadowDetail value="0"/> -</settings> diff --git a/indra/newview/app_settings/mid_graphics.xml b/indra/newview/app_settings/mid_graphics.xml deleted file mode 100644 index 9c2c17fc60..0000000000 --- a/indra/newview/app_settings/mid_graphics.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<settings version = "101"> - <!--NO SHADERS--> - <RenderAvatarCloth value="FALSE"/> - <!--Default for now--> - <RenderAvatarLODFactor value="0.5"/> - <!--Default for now--> - <RenderAvatarPhysicsLODFactor value="0.75"/> - <!--Short Range--> - <RenderFarClip value="96"/> - <!--Default for now--> - <RenderFlexTimeFactor value="1"/> - <!--256... but they do not use this--> - <RenderGlowResolutionPow value="8"/> - <!--Low number--> - <RenderMaxPartCount value="2048"/> - <!--bump okay--> - <RenderObjectBump value="TRUE"/> - <!--NO SHADERS--> - <RenderReflectionDetail value="0"/> - <!--Simple--> - <RenderTerrainDetail value="1"/> - <!--Default for now--> - <RenderTerrainLODFactor value="1.0"/> - <!--Default for now--> - <RenderTreeLODFactor value="0.5"/> - <!--Avater Impostors and Visual Muting Limits--> - <RenderAvatarMaxNonImpostors value="18"/> - <RenderAvatarMaxComplexity value="150000"/> - <RenderAutoMuteSurfaceAreaLimit value="1000.0"/> - <!--Default for now--> - <RenderVolumeLODFactor value="1.125"/> - <!--NO SHADERS--> - <WindLightUseAtmosShaders value="FALSE"/> - <!--No Deferred Shading--> - <RenderDeferred value="FALSE"/> - <!--SSAO Disabled--> - <RenderDeferredSSAO value="FALSE"/> - <!--No Shadows--> - <RenderShadowDetail value="0"/> -</settings> diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index f183f49039..4171b52938 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10306,7 +10306,7 @@ <key>RenderReflectionDetail</key> <map> <key>Comment</key> - <string>Detail of reflection render pass.</string> + <string>DEPRECATED -- use RenderTransparentWater and RenderReflectionProbeDetail -- Detail of reflection render pass.</string> <key>Persist</key> <integer>1</integer> <key>Type</key> @@ -16136,6 +16136,61 @@ <key>Value</key> <integer>1</integer> </map> + <key>MaterialsNextOwnerCopy</key> + <map> + <key>Comment</key> + <string>Newly created GLTF material can be copied by next owner</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>MaterialsNextOwnerModify</key> + <map> + <key>Comment</key> + <string>Newly created GLTF material can be modified by next owner</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>MaterialsNextOwnerTransfer</key> + <map> + <key>Comment</key> + <string>Newly created GLTF material can be resold or given away by next owner</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>MaterialsEveryoneCopy</key> + <map> + <key>Comment</key> + <string>Everyone can copy the newly created GLTF material</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>MaterialsShareWithGroup</key> + <map> + <key>Comment</key> + <string>Newly created GLTF materials are shared with the currently active group</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> <key>DefaultUploadPermissionsConverted</key> <map> <key>Comment</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudShadowF.glsl deleted file mode 100644 index afcb309e33..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudShadowF.glsl +++ /dev/null @@ -1,126 +0,0 @@ -/** - * @file class3/deferred/cloudsF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D diffuseMap; - -VARYING vec4 pos; -VARYING float target_pos_x; -VARYING float vary_CloudDensity; -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; -VARYING vec2 vary_texcoord2; -VARYING vec2 vary_texcoord3; - -uniform sampler2D cloud_noise_texture; -uniform sampler2D cloud_noise_texture_next; -uniform float blend_factor; -uniform vec4 cloud_pos_density1; -uniform vec4 cloud_pos_density2; -uniform vec4 sunlight_color; -uniform float cloud_shadow; -uniform float cloud_scale; -uniform float cloud_variance; -uniform vec3 camPosLocal; -uniform vec3 sun_dir; -uniform float sun_size; -uniform float far_z; - -#if !defined(DEPTH_CLAMP) -VARYING vec4 post_pos; -#endif - -vec4 cloudNoise(vec2 uv) -{ - vec4 a = texture2D(cloud_noise_texture, uv); - vec4 b = texture2D(cloud_noise_texture_next, uv); - vec4 cloud_noise_sample = mix(a, b, blend_factor); - return normalize(cloud_noise_sample); -} - -void main() -{ - // Set variables - vec2 uv1 = vary_texcoord0.xy; - vec2 uv2 = vary_texcoord1.xy; - vec2 uv3 = vary_texcoord2.xy; - float cloudDensity = 2.0 * (cloud_shadow - 0.25); - - if (cloud_scale >= 0.0001) - { - vec2 uv4 = vary_texcoord3.xy; - - 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 * 0.2); //large texture, visible density - uv2 += cloud_pos_density1.xy; //large texture, self shadow - 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) * 4.0); - - 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 * 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 * cloud_pos_density1.z, 1.); - - // And smooth - alpha2 = 1. - alpha2; - alpha2 = 1. - alpha2 * alpha2; - - frag_color = vec4(alpha1, alpha1, alpha1, 1); - } - else - { - frag_color = vec4(1); - } - -#if !defined(DEPTH_CLAMP) - gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); -#endif - -} diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudShadowV.glsl deleted file mode 100644 index effb070f93..0000000000 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudShadowV.glsl +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @file cloudShadowV.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -uniform mat4 texture_matrix0; -uniform mat4 modelview_projection_matrix; -uniform float shadow_target_width; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; - -#if !defined(DEPTH_CLAMP) -VARYING float pos_zd2; -#endif - -VARYING vec4 pos; -VARYING float target_pos_x; -VARYING vec2 vary_texcoord0; -VARYING vec4 vertex_color; - -void passTextureIndex(); - -void main() -{ - //transform vertex - vec4 pre_pos = vec4(position.xyz, 1.0); - pos = modelview_projection_matrix * pre_pos; - target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; - -#if !defined(DEPTH_CLAMP) - pos_zd2 = pos.z * 0.5; - gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); -#else - gl_Position = pos; -#endif - - passTextureIndex(); - - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; - vertex_color = diffuse_color; -} diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index 348e0f5228..788ce4a47b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -34,15 +34,15 @@ out vec4 frag_data[3]; // The fragment shader for the sky ///////////////////////////////////////////////////////////////////////// -VARYING vec4 vary_CloudColorSun; -VARYING vec4 vary_CloudColorAmbient; +VARYING vec3 vary_CloudColorSun; +VARYING vec3 vary_CloudColorAmbient; VARYING float vary_CloudDensity; uniform sampler2D cloud_noise_texture; uniform sampler2D cloud_noise_texture_next; uniform float blend_factor; -uniform vec4 cloud_pos_density1; -uniform vec4 cloud_pos_density2; +uniform vec3 cloud_pos_density1; +uniform vec3 cloud_pos_density2; uniform float cloud_scale; uniform float cloud_variance; @@ -69,8 +69,8 @@ void main() vec2 uv1 = vary_texcoord0.xy; vec2 uv2 = vary_texcoord1.xy; - vec4 cloudColorSun = vary_CloudColorSun; - vec4 cloudColorAmbient = vary_CloudColorAmbient; + vec3 cloudColorSun = vary_CloudColorSun; + vec3 cloudColorAmbient = vary_CloudColorAmbient; float cloudDensity = vary_CloudDensity; vec2 uv3 = vary_texcoord2.xy; vec2 uv4 = vary_texcoord3.xy; @@ -115,7 +115,7 @@ void main() alpha2 = 1. - alpha2 * alpha2; // Combine - vec4 color; + vec3 color; color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); color.rgb= max(vec3(0), color.rgb); color.rgb *= 2.0; diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl index 8e0a001403..5ca210863e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl @@ -33,8 +33,8 @@ ATTRIBUTE vec2 texcoord0; /////////////////////////////////////////////////////////////////////////////// // Output parameters -VARYING vec4 vary_CloudColorSun; -VARYING vec4 vary_CloudColorAmbient; +VARYING vec3 vary_CloudColorSun; +VARYING vec3 vary_CloudColorAmbient; VARYING float vary_CloudDensity; VARYING vec2 vary_texcoord0; @@ -46,13 +46,13 @@ VARYING float altitude_blend_factor; // Inputs uniform vec3 camPosLocal; -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 moonlight_color; +uniform vec3 lightnorm; +uniform vec3 sunlight_color; +uniform vec3 moonlight_color; uniform int sun_up_factor; -uniform vec4 ambient_color; -uniform vec4 blue_horizon; -uniform vec4 blue_density; +uniform vec3 ambient_color; +uniform vec3 blue_horizon; +uniform vec3 blue_density; uniform float haze_horizon; uniform float haze_density; @@ -60,10 +60,10 @@ uniform float cloud_shadow; uniform float density_multiplier; uniform float max_y; -uniform vec4 glow; +uniform vec3 glow; uniform float sun_moon_glow_factor; -uniform vec4 cloud_color; +uniform vec3 cloud_color; uniform float cloud_scale; @@ -114,17 +114,17 @@ void main() float rel_pos_len = length(rel_pos); // Initialize temp variables - vec4 sunlight = sunlight_color; - vec4 light_atten; + vec3 sunlight = sunlight_color; + vec3 light_atten; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y); // Calculate relative weights - vec4 combined_haze = abs(blue_density) + vec4(abs(haze_density)); - vec4 blue_weight = blue_density / combined_haze; - vec4 haze_weight = haze_density / combined_haze; + vec3 combined_haze = abs(blue_density) + vec3(abs(haze_density)); + vec3 blue_weight = blue_density / combined_haze; + vec3 haze_weight = haze_density / combined_haze; // Compute sunlight from rel_pos & lightnorm (for long rays like sky) float off_axis = 1.0 / max(1e-6, max(0., rel_pos_norm.y) + lightnorm.y); @@ -155,14 +155,14 @@ void main() haze_glow = (sun_moon_glow_factor < 1.0) ? 0.0 : (haze_glow + 0.25); // Increase ambient when there are more clouds - vec4 tmpAmbient = ambient_color; + vec3 tmpAmbient = ambient_color; tmpAmbient += (1. - tmpAmbient) * cloud_shadow * 0.5; // Dim sunlight by cloud shadow percentage sunlight *= (1. - cloud_shadow); // Haze color below cloud - vec4 additiveColorBelowCloud = + vec3 additiveColorBelowCloud = (blue_horizon * blue_weight * (sunlight + tmpAmbient) + (haze_horizon * haze_weight) * (sunlight * haze_glow + tmpAmbient)); // CLOUDS @@ -178,7 +178,7 @@ void main() combined_haze = sqrt(combined_haze); // less atmos opacity (more transparency) below clouds vary_CloudColorSun *= combined_haze; vary_CloudColorAmbient *= combined_haze; - vec4 oHazeColorBelowCloud = additiveColorBelowCloud * (1. - combined_haze); + vec3 oHazeColorBelowCloud = additiveColorBelowCloud * (1. - combined_haze); // Make a nice cloud density based on the cloud_shadow value that was passed in. vary_CloudDensity = 2. * (cloud_shadow - 0.25); diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index a513d60388..b4044353b4 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -34,8 +34,7 @@ out vec4 frag_data[3]; #endif uniform vec4 color; -uniform vec4 sunlight_color; -uniform vec4 moonlight_color; +uniform vec3 moonlight_color; uniform vec3 moon_dir; uniform float moon_brightness; uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl index ecb0c43518..adc2db60b6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl @@ -35,7 +35,7 @@ out vec4 frag_data[3]; // The fragment shader for the sky ///////////////////////////////////////////////////////////////////////// -VARYING vec4 vary_HazeColor; +VARYING vec3 vary_HazeColor; /// Soft clips the light with a gamma correction vec3 scaleSoftClip(vec3 light); @@ -48,7 +48,7 @@ void main() // the fragment) if the sky wouldn't show up because the clouds // are fully opaque. - vec4 color; + vec3 color; color = vary_HazeColor; color.rgb *= 2.; diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 223143bc1b..ff53646fd4 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -32,18 +32,18 @@ ATTRIBUTE vec3 position; /////////////////////////////////////////////////////////////////////////////// // Output parameters -VARYING vec4 vary_HazeColor; +VARYING vec3 vary_HazeColor; // Inputs uniform vec3 camPosLocal; -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 moonlight_color; +uniform vec3 lightnorm; +uniform vec3 sunlight_color; +uniform vec3 moonlight_color; uniform int sun_up_factor; -uniform vec4 ambient_color; -uniform vec4 blue_horizon; -uniform vec4 blue_density; +uniform vec3 ambient_color; +uniform vec3 blue_horizon; +uniform vec3 blue_density; uniform float haze_horizon; uniform float haze_density; @@ -52,7 +52,7 @@ uniform float density_multiplier; uniform float distance_multiplier; uniform float max_y; -uniform vec4 glow; +uniform vec3 glow; uniform float sun_moon_glow_factor; // NOTE: Keep these in sync! @@ -85,17 +85,17 @@ void main() float rel_pos_len = length(rel_pos); // Initialize temp variables - vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; - vec4 light_atten; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec3 light_atten; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y); // Calculate relative weights - vec4 combined_haze = abs(blue_density) + vec4(abs(haze_density)); - vec4 blue_weight = blue_density / combined_haze; - vec4 haze_weight = haze_density / combined_haze; + vec3 combined_haze = abs(blue_density) + vec4(abs(haze_density)); + vec3 blue_weight = blue_density / combined_haze; + vec3 haze_weight = haze_density / combined_haze; // Compute sunlight from rel_pos & lightnorm (for long rays like sky) float off_axis = 1.0 / max(1e-6, max(0., rel_pos_norm.y) + lightnorm.y); @@ -123,21 +123,21 @@ void main() // For sun, add to glow. For moon, remove glow entirely. SL-13768 haze_glow = (sun_moon_glow_factor < 1.0) ? 0.0 : (haze_glow + 0.25); - vec4 color = + vec3 color = (blue_horizon * blue_weight * (sunlight + ambient_color) + (haze_horizon * haze_weight) * (sunlight * haze_glow + ambient_color)); // Final atmosphere additive color *= (1. - combined_haze); // Increase ambient when there are more clouds - vec4 tmpAmbient = ambient_color; - tmpAmbient += max(vec4(0), (1. - ambient_color)) * cloud_shadow * 0.5; + vec3 tmpAmbient = ambient_color; + tmpAmbient += max(vec3(0), (1. - ambient_color)) * cloud_shadow * 0.5; // Dim sunlight by cloud shadow percentage sunlight *= max(0.0, (1. - cloud_shadow)); // Haze color below cloud - vec4 additiveColorBelowCloud = + vec3 additiveColorBelowCloud = (blue_horizon * blue_weight * (sunlight + tmpAmbient) + (haze_horizon * haze_weight) * (sunlight * haze_glow + tmpAmbient)); // Attenuate cloud color by atmosphere diff --git a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl b/indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl deleted file mode 100644 index 332fb9d809..0000000000 --- a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowF.glsl +++ /dev/null @@ -1,126 +0,0 @@ -/** - * @file class1/windlight/cloudShadowF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2D diffuseMap; - -VARYING vec4 pos; -VARYING float target_pos_x; -VARYING float vary_CloudDensity; -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; -VARYING vec2 vary_texcoord2; -VARYING vec2 vary_texcoord3; - -uniform sampler2D cloud_noise_texture; -uniform sampler2D cloud_noise_texture_next; -uniform float blend_factor; -uniform vec4 cloud_pos_density1; -uniform vec4 cloud_pos_density2; -uniform vec4 sunlight_color; -uniform float cloud_shadow; -uniform float cloud_scale; -uniform float cloud_variance; -uniform vec3 camPosLocal; -uniform vec3 sun_dir; -uniform float sun_size; -uniform float far_z; - -#if !defined(DEPTH_CLAMP) -VARYING vec4 post_pos; -#endif - -vec4 cloudNoise(vec2 uv) -{ - vec4 a = texture2D(cloud_noise_texture, uv); - vec4 b = texture2D(cloud_noise_texture_next, uv); - vec4 cloud_noise_sample = mix(a, b, blend_factor); - return normalize(cloud_noise_sample); -} - -void main() -{ - if (cloud_scale >= 0.0001) - { - // Set variables - vec2 uv1 = vary_texcoord0.xy; - vec2 uv2 = vary_texcoord1.xy; - vec2 uv3 = vary_texcoord2.xy; - float cloudDensity = 2.0 * (cloud_shadow - 0.25); - - vec2 uv4 = vary_texcoord3.xy; - - 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 * 0.2); //large texture, visible density - uv2 += cloud_pos_density1.xy; //large texture, self shadow - 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) * 4.0); - - 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 * 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 * cloud_pos_density1.z, 1.); - - // And smooth - alpha2 = 1. - alpha2; - alpha2 = 1. - alpha2 * alpha2; - - frag_color = vec4(alpha1, alpha1, alpha1, 1); - } - else - { - frag_color = vec4(1); - } - -#if !defined(DEPTH_CLAMP) - gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); -#endif - -} diff --git a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl b/indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl deleted file mode 100644 index 09b6004481..0000000000 --- a/indra/newview/app_settings/shaders/class1/windlight/cloudShadowV.glsl +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @file class1\windlight\cloudShadowV.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -uniform mat4 texture_matrix0; -uniform mat4 modelview_projection_matrix; -uniform float shadow_target_width; - -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; - -#if !defined(DEPTH_CLAMP) -VARYING float pos_zd2; -#endif - -VARYING vec4 pos; -VARYING float target_pos_x; -VARYING vec2 vary_texcoord0; - -void passTextureIndex(); - -void main() -{ - //transform vertex - vec4 pre_pos = vec4(position.xyz, 1.0); - pos = modelview_projection_matrix * pre_pos; - target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; - -#if !defined(DEPTH_CLAMP) - pos_zd2 = pos.z * 0.5; - gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); -#else - gl_Position = pos; -#endif - - passTextureIndex(); - - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; -} diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 2425a2ad04..f03003f5e1 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -34,8 +34,7 @@ out vec4 frag_color; #endif uniform vec4 color; -uniform vec4 sunlight_color; -uniform vec4 moonlight_color; +uniform vec3 moonlight_color; uniform vec3 moon_dir; uniform float moon_brightness; uniform sampler2D diffuseMap; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index be605b6e60..e255c78b86 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -72,7 +72,7 @@ uniform vec3 light_diffuse[8]; void waterClip(vec3 pos); #ifdef WATER_FOG -vec4 applyWaterFogView(vec3 pos, vec4 color); +vec4 applyWaterFogViewLinear(vec3 pos, vec4 color); #endif vec3 srgb_to_linear(vec3 c); @@ -183,7 +183,10 @@ void main() frag *= screen_res; vec4 pos = vec4(vary_position, 1.0); +#ifndef IS_AVATAR_SKIN + // clip against water plane unless this is a legacy avatar skin waterClip(pos.xyz); +#endif vec3 norm = vary_norm; float shadow = 1.0f; @@ -293,12 +296,11 @@ void main() #endif // !defined(LOCAL_LIGHT_KILL) #ifdef WATER_FOG - color = applyWaterFogView(pos.xyz, color); + color = applyWaterFogViewLinear(pos.xyz, color); #endif // WATER_FOG #endif // #else // FOR_IMPOSTOR - //color.rgb = waterPlane.xyz * 0.5 + 0.5; frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl index 4379024680..668f70c3ab 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl @@ -32,13 +32,13 @@ uniform mat4 modelview_projection_matrix; // Inputs uniform vec3 camPosLocal; -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 moonlight_color; +uniform vec3 lightnorm; +uniform vec3 sunlight_color; +uniform vec3 moonlight_color; uniform int sun_up_factor; -uniform vec4 ambient_color; -uniform vec4 blue_horizon; -uniform vec4 blue_density; +uniform vec3 ambient_color; +uniform vec3 blue_horizon; +uniform vec3 blue_density; uniform float haze_horizon; uniform float haze_density; @@ -47,10 +47,10 @@ uniform float density_multiplier; uniform float distance_multiplier; uniform float max_y; -uniform vec4 glow; +uniform vec3 glow; uniform float sun_moon_glow_factor; -uniform vec4 cloud_color; +uniform vec3 cloud_color; #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; @@ -123,16 +123,16 @@ void main() float rel_pos_len = length(rel_pos); // Initialize temp variables - vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes - vec4 light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + vec3 light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y); // Calculate relative weights - vec4 combined_haze = abs(blue_density) + vec4(abs(haze_density)); - vec4 blue_weight = blue_density / combined_haze; - vec4 haze_weight = haze_density / combined_haze; + vec3 combined_haze = abs(blue_density) + vec3(abs(haze_density)); + vec3 blue_weight = blue_density / combined_haze; + vec3 haze_weight = haze_density / combined_haze; // Compute sunlight from rel_pos & lightnorm (for long rays like sky) float off_axis = 1.0 / max(1e-6, max(0, rel_pos_norm.y) + lightnorm.y); @@ -162,7 +162,7 @@ void main() haze_glow = (sun_moon_glow_factor < 1.0) ? 0.0 : (sun_moon_glow_factor * (haze_glow + 0.25)); // Haze color above cloud - vec4 color = blue_horizon * blue_weight * (sunlight + ambient_color) + vec3 color = blue_horizon * blue_weight * (sunlight + ambient_color) + haze_horizon * haze_weight * (sunlight * haze_glow + ambient_color); // Final atmosphere additive @@ -170,13 +170,13 @@ void main() // Increase ambient when there are more clouds // TODO 9/20: DJH what does this do? max(0,(1-ambient)) will change the color - vec4 ambient = ambient_color + max(vec4(0), (1. - ambient_color)) * cloud_shadow * 0.5; + vec3 ambient = ambient_color + max(vec3(0), (1. - ambient_color)) * cloud_shadow * 0.5; // Dim sunlight by cloud shadow percentage sunlight *= max(0.0, (1. - cloud_shadow)); // Haze color below cloud - vec4 add_below_cloud = blue_horizon * blue_weight * (sunlight + ambient) + vec3 add_below_cloud = blue_horizon * blue_weight * (sunlight + ambient) + haze_horizon * haze_weight * (sunlight * haze_glow + ambient); // Attenuate cloud color by atmosphere diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index 8937488484..c69eba93b6 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -23,17 +23,17 @@ * $/LicenseInfo$ */ -uniform vec4 lightnorm; -uniform vec4 sunlight_color; +uniform vec3 lightnorm; +uniform vec3 sunlight_color; uniform vec3 sunlight_linear; -uniform vec4 moonlight_color; +uniform vec3 moonlight_color; uniform vec3 moonlight_linear; uniform int sun_up_factor; -uniform vec4 ambient_color; +uniform vec3 ambient_color; uniform vec3 ambient_linear; -uniform vec4 blue_horizon; +uniform vec3 blue_horizon; uniform vec3 blue_horizon_linear; -uniform vec4 blue_density; +uniform vec3 blue_density; uniform vec3 blue_density_linear; uniform float haze_horizon; uniform float haze_density; @@ -42,7 +42,7 @@ uniform float cloud_shadow; uniform float density_multiplier; uniform float distance_multiplier; uniform float max_y; -uniform vec4 glow; +uniform vec3 glow; uniform float scene_light_strength; uniform mat3 ssao_effect_mat; uniform int no_atmo; @@ -63,17 +63,17 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou vec3 rel_pos_norm = normalize(rel_pos); float rel_pos_len = length(rel_pos); - vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; // sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes - vec4 light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + vec3 light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y); // I had thought blue_density and haze_density should have equal weighting, // but attenuation due to haze_density tends to seem too strong - vec4 combined_haze = blue_density + vec4(haze_density); - vec4 blue_weight = blue_density / combined_haze; - vec4 haze_weight = vec4(haze_density) / combined_haze; + vec3 combined_haze = blue_density + vec3(haze_density); + vec3 blue_weight = blue_density / combined_haze; + vec3 haze_weight = vec3(haze_density) / combined_haze; //(TERRAIN) compute sunlight from lightnorm y component. Factor is roughly cosecant(sun elevation) (for short rays like terrain) float above_horizon_factor = 1.0 / max(1e-6, lightnorm.y); @@ -111,10 +111,10 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou haze_glow *= sun_moon_glow_factor; - vec4 amb_color = ambient_color; + vec3 amb_color = ambient_color; // increase ambient when there are more clouds - vec4 tmpAmbient = amb_color + (vec4(1.) - amb_color) * cloud_shadow * 0.5; + vec3 tmpAmbient = amb_color + (vec3(1.) - amb_color) * cloud_shadow * 0.5; /* decrease value and saturation (that in HSV, not HSL) for occluded areas * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html @@ -127,7 +127,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou */ if (use_ao) { - tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); + tmpAmbient = mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor); } // Similar/Shared Algorithms: @@ -179,17 +179,17 @@ void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, ou vec3 rel_pos_norm = normalize(rel_pos); float rel_pos_len = length(rel_pos); - vec4 sunlight = (sun_up_factor == 1) ? vec4(sunlight_linear, 0.0) : vec4(moonlight_linear, 0.0); + vec3 sunlight = (sun_up_factor == 1) ? vec3(sunlight_linear, 0.0) : vec3(moonlight_linear, 0.0); // sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes - vec4 light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + vec3 light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y); // I had thought blue_density and haze_density should have equal weighting, // but attenuation due to haze_density tends to seem too strong - vec4 combined_haze = blue_density + vec4(haze_density); - vec4 blue_weight = blue_density / combined_haze; - vec4 haze_weight = vec4(haze_density) / combined_haze; + vec3 combined_haze = blue_density + vec3(haze_density); + vec3 blue_weight = blue_density / combined_haze; + vec3 haze_weight = vec3(haze_density) / combined_haze; //(TERRAIN) compute sunlight from lightnorm y component. Factor is roughly cosecant(sun elevation) (for short rays like terrain) float above_horizon_factor = 1.0 / max(1e-6, lightnorm.y); @@ -227,11 +227,11 @@ void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, ou haze_glow *= sun_moon_glow_factor; - //vec4 amb_color = vec4(ambient_linear, 0.0); - vec4 amb_color = ambient_color; + //vec3 amb_color = vec4(ambient_linear, 0.0); + vec3 amb_color = ambient_color; // increase ambient when there are more clouds - vec4 tmpAmbient = amb_color + (vec4(1.) - amb_color) * cloud_shadow * 0.5; + vec3 tmpAmbient = amb_color + (vec3(1.) - amb_color) * cloud_shadow * 0.5; // Similar/Shared Algorithms: // indra\llinventory\llsettingssky.cpp -- LLSettingsSky::calculateLightSettings() diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index fa928d993e..9c5a4903d0 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -35,15 +35,15 @@ out vec4 frag_color; // The fragment shader for the sky ///////////////////////////////////////////////////////////////////////// -VARYING vec4 vary_CloudColorSun; -VARYING vec4 vary_CloudColorAmbient; +VARYING vec3 vary_CloudColorSun; +VARYING vec3 vary_CloudColorAmbient; VARYING float vary_CloudDensity; uniform sampler2D cloud_noise_texture; uniform sampler2D cloud_noise_texture_next; uniform float blend_factor; -uniform vec4 cloud_pos_density1; -uniform vec4 cloud_pos_density2; +uniform vec3 cloud_pos_density1; +uniform vec3 cloud_pos_density2; uniform float cloud_scale; uniform float cloud_variance; @@ -70,8 +70,8 @@ void main() vec2 uv1 = vary_texcoord0.xy; vec2 uv2 = vary_texcoord1.xy; - vec4 cloudColorSun = vary_CloudColorSun; - vec4 cloudColorAmbient = vary_CloudColorAmbient; + vec3 cloudColorSun = vary_CloudColorSun; + vec3 cloudColorAmbient = vary_CloudColorAmbient; float cloudDensity = vary_CloudDensity; vec2 uv3 = vary_texcoord2.xy; vec2 uv4 = vary_texcoord3.xy; @@ -120,7 +120,7 @@ void main() alpha2 = 1. - alpha2 * alpha2; // Combine - vec4 color; + vec3 color; color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); color.rgb *= 2.; color.rgb = scaleSoftClip(color.rgb); diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl index 97ffa9feef..650009d393 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl @@ -33,8 +33,8 @@ ATTRIBUTE vec2 texcoord0; /////////////////////////////////////////////////////////////////////////////// // Output parameters -VARYING vec4 vary_CloudColorSun; -VARYING vec4 vary_CloudColorAmbient; +VARYING vec3 vary_CloudColorSun; +VARYING vec3 vary_CloudColorAmbient; VARYING float vary_CloudDensity; VARYING vec2 vary_texcoord0; @@ -46,13 +46,13 @@ VARYING float altitude_blend_factor; // Inputs uniform vec3 camPosLocal; -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 moonlight_color; +uniform vec3 lightnorm; +uniform vec3 sunlight_color; +uniform vec3 moonlight_color; uniform int sun_up_factor; -uniform vec4 ambient_color; -uniform vec4 blue_horizon; -uniform vec4 blue_density; +uniform vec3 ambient_color; +uniform vec3 blue_horizon; +uniform vec3 blue_density; uniform float haze_horizon; uniform float haze_density; @@ -60,10 +60,10 @@ uniform float cloud_shadow; uniform float density_multiplier; uniform float max_y; -uniform vec4 glow; +uniform vec3 glow; uniform float sun_moon_glow_factor; -uniform vec4 cloud_color; +uniform vec3 cloud_color; uniform float cloud_scale; @@ -114,17 +114,17 @@ void main() float rel_pos_len = length(rel_pos); // Initialize temp variables - vec4 sunlight = sunlight_color; - vec4 light_atten; + vec3 sunlight = sunlight_color; + vec3 light_atten; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y); // Calculate relative weights - vec4 combined_haze = abs(blue_density) + vec4(abs(haze_density)); - vec4 blue_weight = blue_density / combined_haze; - vec4 haze_weight = haze_density / combined_haze; + vec3 combined_haze = abs(blue_density) + vec3(abs(haze_density)); + vec3 blue_weight = blue_density / combined_haze; + vec3 haze_weight = haze_density / combined_haze; // Compute sunlight from rel_pos & lightnorm (for long rays like sky) float off_axis = 1.0 / max(1e-6, max(0., rel_pos_norm.y) + lightnorm.y); @@ -155,14 +155,14 @@ void main() haze_glow = (sun_moon_glow_factor < 1.0) ? 0.0 : (haze_glow + 0.25); // Increase ambient when there are more clouds - vec4 tmpAmbient = ambient_color; + vec3 tmpAmbient = ambient_color; tmpAmbient += (1. - tmpAmbient) * cloud_shadow * 0.5; // Dim sunlight by cloud shadow percentage sunlight *= (1. - cloud_shadow); // Haze color below cloud - vec4 additiveColorBelowCloud = + vec3 additiveColorBelowCloud = (blue_horizon * blue_weight * (sunlight + tmpAmbient) + (haze_horizon * haze_weight) * (sunlight * haze_glow + tmpAmbient)); // CLOUDS @@ -178,7 +178,7 @@ void main() combined_haze = sqrt(combined_haze); // less atmos opacity (more transparency) below clouds vary_CloudColorSun *= combined_haze; vary_CloudColorAmbient *= combined_haze; - vec4 oHazeColorBelowCloud = additiveColorBelowCloud * (1. - combined_haze); + vec3 oHazeColorBelowCloud = additiveColorBelowCloud * (1. - combined_haze); // Make a nice cloud density based on the cloud_shadow value that was passed in. vary_CloudDensity = 2. * (cloud_shadow - 0.25); diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl index 7146349453..7a229e0f5e 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl @@ -33,7 +33,7 @@ out vec4 frag_color; // The fragment shader for the sky ///////////////////////////////////////////////////////////////////////// -VARYING vec4 vary_HazeColor; +VARYING vec3 vary_HazeColor; /// Soft clips the light with a gamma correction vec3 scaleSoftClip(vec3 light); @@ -45,7 +45,7 @@ void main() // the fragment) if the sky wouldn't show up because the clouds // are fully opaque. - vec4 color; + vec3 color; color = vary_HazeColor; color.rgb *= 2.; /// Gamma correct for WL (soft clip effect). diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl index 3edc94f4ca..8f7726bb0b 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl @@ -32,18 +32,18 @@ ATTRIBUTE vec3 position; /////////////////////////////////////////////////////////////////////////////// // Output parameters -VARYING vec4 vary_HazeColor; +VARYING vec3 vary_HazeColor; // Inputs uniform vec3 camPosLocal; -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 moonlight_color; +uniform vec3 lightnorm; +uniform vec3 sunlight_color; +uniform vec3 moonlight_color; uniform int sun_up_factor; -uniform vec4 ambient_color; -uniform vec4 blue_horizon; -uniform vec4 blue_density; +uniform vec3 ambient_color; +uniform vec3 blue_horizon; +uniform vec3 blue_density; uniform float haze_horizon; uniform float haze_density; @@ -52,7 +52,7 @@ uniform float density_multiplier; uniform float distance_multiplier; uniform float max_y; -uniform vec4 glow; +uniform vec3 glow; uniform float sun_moon_glow_factor; void main() @@ -81,17 +81,17 @@ void main() float rel_pos_len = length(rel_pos); // Initialize temp variables - vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; - vec4 light_atten; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec3 light_atten; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y); // Calculate relative weights - vec4 combined_haze = abs(blue_density) + vec4(abs(haze_density)); - vec4 blue_weight = blue_density / combined_haze; - vec4 haze_weight = haze_density / combined_haze; + vec3 combined_haze = abs(blue_density) + vec3(abs(haze_density)); + vec3 blue_weight = blue_density / combined_haze; + vec3 haze_weight = haze_density / combined_haze; // Compute sunlight from rel_pos & lightnorm (for long rays like sky) float off_axis = 1.0 / max(1e-6, max(0., rel_pos_norm.y) + lightnorm.y); @@ -119,21 +119,21 @@ void main() // For sun, add to glow. For moon, remove glow entirely. SL-13768 haze_glow = (sun_moon_glow_factor < 1.0) ? 0.0 : (haze_glow + 0.25); - vec4 color = + vec3 color = (blue_horizon * blue_weight * (sunlight + ambient_color) + (haze_horizon * haze_weight) * (sunlight * haze_glow + ambient_color)); // Final atmosphere additive color *= (1. - combined_haze); // Increase ambient when there are more clouds - vec4 tmpAmbient = ambient_color; - tmpAmbient += max(vec4(0), (1. - ambient_color)) * cloud_shadow * 0.5; + vec3 tmpAmbient = ambient_color; + tmpAmbient += max(vec3(0), (1. - ambient_color)) * cloud_shadow * 0.5; // Dim sunlight by cloud shadow percentage sunlight *= max(0.0, (1. - cloud_shadow)); // Haze color below cloud - vec4 additiveColorBelowCloud = + vec3 additiveColorBelowCloud = (blue_horizon * blue_weight * (sunlight + tmpAmbient) + (haze_horizon * haze_weight) * (sunlight * haze_glow + tmpAmbient)); // Attenuate cloud color by atmosphere diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 925398671c..211e1f5d8d 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -114,8 +114,7 @@ bool shouldSampleProbe(int i, vec3 pos) void preProbeSample(vec3 pos) { // TODO: make some sort of structure that reduces the number of distance checks - - for (int i = 0; i < refmapCount; ++i) + for (int i = 1; i < refmapCount; ++i) { // found an influencing probe if (shouldSampleProbe(i, pos)) @@ -200,6 +199,12 @@ void preProbeSample(vec3 pos) } } } + + if (probeInfluences == 0) + { // probe at index 0 is a special fallback probe + probeIndex[0] = 0; + probeInfluences = 1; + } } // from https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-sphere-intersection @@ -316,7 +321,7 @@ vec3 boxIntersect(vec3 origin, vec3 dir, int i) // c - center of probe // r2 - radius of probe squared // i - index of probe -vec3 tapRefMap(vec3 pos, vec3 dir, out vec3 vi, out vec3 wi, float lod, vec3 c, float r2, int i) +vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out vec3 vi, out vec3 wi, float lod, vec3 c, int i) { //lod = max(lod, 1); // parallax adjustment @@ -326,10 +331,26 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out vec3 vi, out vec3 wi, float lod, vec3 c, if (refIndex[i].w < 0) { v = boxIntersect(pos, dir, i); + w = 1.0; } else { - v = sphereIntersect(pos, dir, c, r2); + float r = refSphere[i].w; // radius of sphere volume + float rr = r * r; // radius squared + + v = sphereIntersect(pos, dir, c, rr); + + float p = float(abs(refIndex[i].w)); // priority + + float r1 = r * 0.1; // 90% of radius (outer sphere to start interpolating down) + vec3 delta = pos.xyz - refSphere[i].xyz; + float d2 = max(dot(delta, delta), 0.001); + float r2 = r1 * r1; + + float atten = 1.0 - max(d2 - r2, 0.0) / max((rr - r2), 0.001); + + w = 1.0 / d2; + w *= atten; } vi = v; @@ -352,19 +373,32 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out vec3 vi, out vec3 wi, float lod, vec3 c, // c - center of probe // r2 - radius of probe squared // i - index of probe -vec3 tapIrradianceMap(vec3 pos, vec3 dir, vec3 c, float r2, int i) +vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, vec3 c, int i) { - //lod = max(lod, 1); // parallax adjustment - vec3 v; if (refIndex[i].w < 0) { v = boxIntersect(pos, dir, i); + w = 1.0; } else { - v = sphereIntersect(pos, dir, c, r2); + float r = refSphere[i].w; // radius of sphere volume + float p = float(abs(refIndex[i].w)); // priority + float rr = r * r; // radius squred + + v = sphereIntersect(pos, dir, c, rr); + + float r1 = r * 0.1; // 75% of radius (outer sphere to start interpolating down) + vec3 delta = pos.xyz - refSphere[i].xyz; + float d2 = dot(delta, delta); + float r2 = r1 * r1; + + w = 1.0 / d2; + + float atten = 1.0 - max(d2 - r2, 0.0) / (rr - r2); + w *= atten; } v -= c; @@ -387,26 +421,17 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, bool errorCorrect) { continue; } - float r = refSphere[i].w; // radius of sphere volume - float p = float(abs(refIndex[i].w)); // priority - - float rr = r*r; // radius squred - float r1 = r * 0.1; // 90% of radius (outer sphere to start interpolating down) - vec3 delta = pos.xyz-refSphere[i].xyz; - float d2 = dot(delta,delta); - float r2 = r1*r1; - - { - vec3 vi, wi; - float atten = 1.0 - max(d2 - r2, 0.0) / (rr - r2); - float w; - vec3 refcol; + float w; + vec3 vi, wi; + vec3 refcol; + + { if (errorCorrect && refIndex[i].w >= 0) { // error correction is on and this probe is a sphere //take a sample to get depth value, then error correct - refcol = tapRefMap(pos, dir, vi, wi, abs(lod + 2), refSphere[i].xyz, rr, i); + refcol = tapRefMap(pos, dir, w, vi, wi, abs(lod + 2), refSphere[i].xyz, i); //adjust lookup by distance result float d = length(vi - wi); @@ -420,48 +445,20 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, bool errorCorrect) // weight by vector correctness vec3 pi = normalize(wi - pos); - w = max(dot(pi, dir), 0.1); - w = pow(w, 32.0); + w *= max(dot(pi, dir), 0.1); + //w = pow(w, 32.0); } else { - w = 1.0 / d2; - refcol = tapRefMap(pos, dir, vi, wi, lod, refSphere[i].xyz, rr, i); + refcol = tapRefMap(pos, dir, w, vi, wi, lod, refSphere[i].xyz, i); } - w *= atten; - - //w *= p; // boost weight based on priority col += refcol.rgb*w; wsum += w; } } - if (probeInfluences < 1) - { //edge-of-scene probe or no probe influence, mix in with embiggened version of probes closest to camera - for (int idx = 0; idx < 8; ++idx) - { - if (refIndex[idx].w < 0) - { // don't fallback to box probes, they are *very* specific - continue; - } - int i = idx; - vec3 delta = pos.xyz-refSphere[i].xyz; - float d2 = dot(delta,delta); - - { - vec3 vi, wi; - vec3 refcol = tapRefMap(pos, dir, vi, wi, lod, refSphere[i].xyz, d2, i); - - float w = 1.0/d2; - w *= w; - col += refcol.rgb*w; - wsum += w; - } - } - } - if (wsum > 0.0) { col *= 1.0/wsum; @@ -487,52 +484,17 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir) { continue; } - float r = refSphere[i].w; // radius of sphere volume - float p = float(abs(refIndex[i].w)); // priority - - float rr = r*r; // radius squred - float r1 = r * 0.1; // 75% of radius (outer sphere to start interpolating down) - vec3 delta = pos.xyz-refSphere[i].xyz; - float d2 = dot(delta,delta); - float r2 = r1*r1; { - vec3 refcol = tapIrradianceMap(pos, dir, refSphere[i].xyz, rr, i); - - float w = 1.0/d2; + float w; + vec3 refcol = tapIrradianceMap(pos, dir, w, refSphere[i].xyz, i); - float atten = 1.0-max(d2-r2, 0.0)/(rr-r2); - w *= atten; - //w *= p; // boost weight based on priority col += refcol*w; wsum += w; } } - if (probeInfluences <= 1) - { //edge-of-scene probe or no probe influence, mix in with embiggened version of probes closest to camera - for (int idx = 0; idx < 8; ++idx) - { - if (refIndex[idx].w < 0) - { // don't fallback to box probes, they are *very* specific - continue; - } - int i = idx; - vec3 delta = pos.xyz-refSphere[i].xyz; - float d2 = dot(delta,delta); - - { - vec3 refcol = tapIrradianceMap(pos, dir, refSphere[i].xyz, d2, i); - - float w = 1.0/d2; - w *= w; - col += refcol*w; - wsum += w; - } - } - } - if (wsum > 0.0) { col *= 1.0/wsum; diff --git a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl index 819e6dcf15..a5e0adf8fa 100644 --- a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl @@ -26,10 +26,12 @@ out vec4 frag_color; uniform sampler2D diffuseMap; -uniform sampler2D bumpMap; +uniform sampler2D bumpMap; + +#ifdef TRANSPARENT_WATER uniform sampler2D screenTex; -uniform sampler2D refTex; uniform sampler2D screenDepth; +#endif uniform vec4 fogCol; uniform vec3 lightDir; @@ -43,6 +45,7 @@ uniform float kd; uniform vec4 waterPlane; uniform vec3 eyeVec; uniform vec4 waterFogColor; +uniform vec3 waterFogColorLinear; uniform float waterFogKS; uniform vec2 screenRes; @@ -57,8 +60,8 @@ vec4 applyWaterFogViewLinear(vec3 pos, vec4 color); void main() { vec4 color; - - //get detail normals + + //get detail normals vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; @@ -67,8 +70,12 @@ void main() //figure out distortion vector (ripply) vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; distort = distort+wavef.xy*refScale; - + +#ifdef TRANSPARENT_WATER vec4 fb = texture2D(screenTex, distort); - +#else + vec4 fb = vec4(waterFogColorLinear, 0.0); +#endif + frag_color = applyWaterFogViewLinear(vary_position, fb); } diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl index 9793a0e786..a6517be433 100644 --- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl @@ -55,8 +55,10 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, uniform sampler2D bumpMap; uniform sampler2D bumpMap2; uniform float blend_factor; +#ifdef TRANSPARENT_WATER uniform sampler2D screenTex; uniform sampler2D screenDepth; +#endif uniform sampler2D refTex; @@ -73,6 +75,7 @@ uniform float fresnelScale; uniform float fresnelOffset; uniform float blurMultiplier; uniform vec4 waterFogColor; +uniform vec3 waterFogColorLinear; //bigWave is (refCoord.w, view.w); @@ -174,6 +177,7 @@ void main() vec2 distort2 = distort + waver.xy * refScale / max(dmod * df1, 1.0); distort2 = clamp(distort2, vec2(0), vec2(0.99)); +#ifdef TRANSPARENT_WATER vec4 fb = texture2D(screenTex, distort2); float depth = texture2D(screenDepth, distort2).r; vec3 refPos = getPositionWithNDC(vec3(distort2*2.0-vec2(1.0), depth*2.0-1.0)); @@ -188,6 +192,9 @@ void main() } fb = applyWaterFogViewLinear(refPos, fb); +#else + vec4 fb = vec4(waterFogColorLinear.rgb, 0.0); +#endif vec3 sunlit; vec3 amblit; diff --git a/indra/newview/app_settings/ultra_graphics.xml b/indra/newview/app_settings/ultra_graphics.xml deleted file mode 100644 index 8462df207b..0000000000 --- a/indra/newview/app_settings/ultra_graphics.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<settings version = "101"> - <!--NO SHADERS--> - <RenderAvatarCloth value="TRUE"/> - <!--Default for now--> - <RenderAvatarLODFactor value="1.0"/> - <!--Default for now--> - <RenderAvatarPhysicsLODFactor value="1.0"/> - <!--Short Range--> - <RenderFarClip value="256"/> - <!--Default for now--> - <RenderFlexTimeFactor value="1"/> - <!--256... but they do not use this--> - <RenderGlowResolutionPow value="9"/> - <!--Low number--> - <RenderMaxPartCount value="4096"/> - <!--bump okay--> - <RenderObjectBump value="TRUE"/> - <!--NO SHADERS--> - <RenderReflectionDetail value="4"/> - <!--Simple--> - <RenderTerrainDetail value="1"/> - <!--Default for now--> - <RenderTerrainLODFactor value="2.0"/> - <!--Default for now--> - <RenderTreeLODFactor value="1.0"/> - <!--Avater Impostors and Visual Muting Limits (real defaults set - based on default graphics setting --> - <RenderAvatarMaxNonImpostors value="0"/> - <RenderAvatarMaxComplexity value="350000"/> - <RenderAutoMuteSurfaceAreaLimit value="1500.0"/> - <!--Default for now--> - <RenderVolumeLODFactor value="2.0"/> - <!--NO SHADERS--> - <WindLightUseAtmosShaders value="TRUE"/> - <!--Deferred Shading--> - <RenderDeferred value="TRUE"/> - <!--SSAO Enabled--> - <RenderDeferredSSAO value="TRUE"/> - <!--Full Shadows--> - <RenderShadowDetail value="2"/> -</settings> diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index ddd24b70c6..2cb48e51d0 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -46,11 +46,10 @@ RenderGround 1 1 RenderMaxPartCount 1 8192 RenderObjectBump 1 1 RenderLocalLights 1 1 -RenderReflectionDetail 1 4 +RenderTransparentWater 1 1 RenderReflectionProbeDetail 1 2 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 -RenderTransparentWater 1 1 RenderTreeLODFactor 1 1.0 RenderVBOEnable 1 1 RenderVBOMappingDisable 1 1 @@ -90,11 +89,10 @@ RenderFlexTimeFactor 1 0 RenderGlowResolutionPow 1 8 RenderLocalLights 1 0 RenderMaxPartCount 1 0 -RenderReflectionDetail 1 0 +RenderTransparentWater 1 0 RenderReflectionProbeDetail 1 -1 RenderTerrainDetail 1 0 RenderTerrainLODFactor 1 1 -RenderTransparentWater 1 0 RenderTreeLODFactor 1 0 RenderVolumeLODFactor 1 1.125 RenderDeferredSSAO 1 0 @@ -116,11 +114,10 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 8 RenderMaxPartCount 1 2048 RenderLocalLights 1 1 -RenderReflectionDetail 1 0 +RenderTransparentWater 1 0 RenderReflectionProbeDetail 1 -1 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 1.0 -RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.125 RenderDeferredSSAO 1 0 @@ -142,10 +139,9 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 RenderMaxPartCount 1 4096 RenderLocalLights 1 1 -RenderReflectionDetail 1 0 +RenderTransparentWater 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 -RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.125 RenderDeferredSSAO 1 0 @@ -168,10 +164,9 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 RenderMaxPartCount 1 4096 RenderLocalLights 1 1 -RenderReflectionDetail 1 0 +RenderTransparentWater 1 1 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 -RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.125 RenderDeferredSSAO 1 0 @@ -194,10 +189,9 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 RenderMaxPartCount 1 4096 RenderLocalLights 1 1 -RenderReflectionDetail 1 0 +RenderTransparentWater 1 1 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 -RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.125 RenderDeferredSSAO 1 1 @@ -220,7 +214,6 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 RenderMaxPartCount 1 4096 RenderLocalLights 1 1 -RenderReflectionDetail 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 @@ -245,7 +238,6 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 RenderLocalLights 1 1 RenderMaxPartCount 1 8192 -RenderReflectionDetail 1 4 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 @@ -283,7 +275,7 @@ RenderAvatarMaxComplexity 1 80000 RenderLocalLights 1 0 RenderMaxPartCount 1 1024 RenderTerrainDetail 1 0 -RenderReflectionDetail 0 0 +RenderTransparentWater 1 0 RenderDeferredSSAO 0 0 RenderShadowDetail 0 0 RenderReflectionProbeDetail 0 -1 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 98f498f59d..d40e7aff0b 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -46,7 +46,6 @@ RenderGround 1 1 RenderMaxPartCount 1 8192 RenderObjectBump 1 1 RenderLocalLights 1 1 -RenderReflectionDetail 1 4 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 @@ -88,7 +87,6 @@ RenderFlexTimeFactor 1 0 RenderGlowResolutionPow 1 8 RenderLocalLights 1 0 RenderMaxPartCount 1 0 -RenderReflectionDetail 1 0 RenderTerrainDetail 1 0 RenderTerrainLODFactor 1 1 RenderTransparentWater 1 0 @@ -114,7 +112,6 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 8 RenderMaxPartCount 1 2048 RenderLocalLights 1 1 -RenderReflectionDetail 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 1.0 RenderTransparentWater 1 1 @@ -140,7 +137,6 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 RenderMaxPartCount 1 4096 RenderLocalLights 1 1 -RenderReflectionDetail 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 @@ -166,7 +162,6 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 RenderMaxPartCount 1 4096 RenderLocalLights 1 1 -RenderReflectionDetail 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 @@ -192,7 +187,6 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 RenderMaxPartCount 1 4096 RenderLocalLights 1 1 -RenderReflectionDetail 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 @@ -218,7 +212,6 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 RenderMaxPartCount 1 4096 RenderLocalLights 1 1 -RenderReflectionDetail 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 @@ -243,7 +236,6 @@ RenderFlexTimeFactor 1 1.0 RenderGlowResolutionPow 1 9 RenderLocalLights 1 1 RenderMaxPartCount 1 8192 -RenderReflectionDetail 1 4 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 @@ -282,7 +274,6 @@ RenderAvatarMaxComplexity 1 80000 RenderLocalLights 1 0 RenderMaxPartCount 1 1024 RenderTerrainDetail 1 0 -RenderReflectionDetail 0 0 RenderDeferredSSAO 0 0 RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index e874cf02cb..130de92ade 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -338,9 +338,6 @@ LLFrameTimer gRestoreGLTimer; BOOL gRestoreGL = FALSE; bool gUseWireframe = FALSE; -//use for remember deferred mode in wireframe switch -bool gInitialDeferredModeForWireframe = FALSE; - LLMemoryInfo gSysMemory; U64Bytes gMemoryAllocated(0); // updated in display_stats() in llviewerdisplay.cpp @@ -2190,6 +2187,19 @@ bool LLAppViewer::initThreads() LLLFSThread::initClass(enable_threads && true); // TODO: fix crashes associated with this shutdo + //auto configure thread count + LLSD threadCounts = gSavedSettings.getLLSD("ThreadPoolSizes"); + + // get the number of concurrent threads that can run + S32 cores = std::thread::hardware_concurrency(); + + // The only configurable thread count right now is ImageDecode + // The viewer typically starts around 8 threads not including image decode, + // so try to leave at least one core free + S32 image_decode_count = llclamp(cores - 9, 1, 8); + threadCounts["ImageDecode"] = image_decode_count; + gSavedSettings.setLLSD("ThreadPoolSizes", threadCounts); + // Image decoding LLAppViewer::sImageDecodeThread = new LLImageDecodeThread(enable_threads && true); LLAppViewer::sTextureCache = new LLTextureCache(enable_threads && true); diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index f28a90c703..3888fa8ae3 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -392,7 +392,6 @@ extern BOOL gDisconnected; extern LLFrameTimer gRestoreGLTimer; extern BOOL gRestoreGL; extern bool gUseWireframe; -extern bool gInitialDeferredModeForWireframe; extern LLMemoryInfo gSysMemory; extern U64Bytes gMemoryAllocated; diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 0d9e83a976..01b2647eaa 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -147,6 +147,11 @@ extern BOOL gCubeSnapshot; void LLDrawPoolAlpha::renderPostDeferred(S32 pass) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; + + if ((!LLPipeline::sRenderTransparentWater || gCubeSnapshot) && getType() == LLDrawPool::POOL_ALPHA_PRE_WATER) + { // don't render alpha objects on the other side of the water plane if water is opaque + return; + } deferred_render = TRUE; F32 water_sign = 1.f; diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index fc8df01002..3f39716449 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -57,6 +57,8 @@ BOOL LLDrawPoolWater::sNeedsReflectionUpdate = TRUE; BOOL LLDrawPoolWater::sNeedsDistortionUpdate = TRUE; F32 LLDrawPoolWater::sWaterFogEnd = 0.f; +extern BOOL gCubeSnapshot; + LLDrawPoolWater::LLDrawPoolWater() : LLFacePool(POOL_WATER) { } @@ -124,15 +126,19 @@ S32 LLDrawPoolWater::getNumPostDeferredPasses() void LLDrawPoolWater::beginPostDeferredPass(S32 pass) { - // copy framebuffer contents so far to a texture to be used for - // reflections and refractions - LLRenderTarget& src = gPipeline.mRT->screen; - LLRenderTarget& dst = gPipeline.mWaterDis; - dst.copyContents(src, - 0, 0, src.getWidth(), src.getHeight(), - 0, 0, dst.getWidth(), dst.getHeight(), - GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, - GL_NEAREST); + LL_PROFILE_GPU_ZONE("water beginPostDeferredPass") + if (LLPipeline::sRenderTransparentWater && !gCubeSnapshot) + { + // copy framebuffer contents so far to a texture to be used for + // reflections and refractions + LLRenderTarget& src = gPipeline.mRT->screen; + LLRenderTarget& dst = gPipeline.mWaterDis; + dst.copyContents(src, + 0, 0, src.getWidth(), src.getHeight(), + 0, 0, dst.getWidth(), dst.getHeight(), + GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, + GL_NEAREST); + } } void LLDrawPoolWater::renderPostDeferred(S32 pass) @@ -151,6 +157,7 @@ S32 LLDrawPoolWater::getNumDeferredPasses() //=============================== void LLDrawPoolWater::renderDeferred(S32 pass) { +#if 0 LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER); if (!LLPipeline::sRenderTransparentWater) @@ -163,6 +170,7 @@ void LLDrawPoolWater::renderDeferred(S32 pass) deferred_render = TRUE; renderWater(); deferred_render = FALSE; +#endif } //========================================= @@ -508,6 +516,8 @@ void LLDrawPoolWater::renderWater() bool moon_up = environment.getIsMoonUp(); bool has_normal_mips = gSavedSettings.getBOOL("RenderWaterMipNormal"); bool underwater = LLViewerCamera::getInstance()->cameraUnderWater(); + LLColor4 fog_color = LLColor4(pwater->getWaterFogColor(), 0.f); + LLColor3 fog_color_linear = linearColor3(fog_color); if (sun_up) { @@ -543,7 +553,7 @@ void LLDrawPoolWater::renderWater() for( int edge = 0 ; edge < 2; edge++ ) { // select shader - if (underwater && LLPipeline::sWaterReflections) + if (underwater) { shader = deferred_render ? &gDeferredUnderWaterProgram : &gUnderWaterProgram; } @@ -619,7 +629,6 @@ void LLDrawPoolWater::renderWater() shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes); shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); - LLColor4 fog_color(pwater->getWaterFogColor(), 0.0f); F32 fog_density = pwater->getModifiedWaterFogDensity(underwater); if (screentex > -1) @@ -646,6 +655,7 @@ void LLDrawPoolWater::renderWater() shader->uniform4fv(LLShaderMgr::SPECULAR_COLOR, 1, specular.mV); shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, fog_color.mV); + shader->uniform3fv(LLShaderMgr::WATER_FOGCOLOR_LINEAR, 1, fog_color_linear.mV); shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV); shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp); @@ -670,7 +680,7 @@ void LLDrawPoolWater::renderWater() shader->uniform1i(LLShaderMgr::WATER_EDGE_FACTOR, edge ? 1 : 0); LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); + shader->uniform3fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); if (LLViewerCamera::getInstance()->cameraUnderWater()) diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 9873846669..7157214cbc 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -547,7 +547,7 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() F32 moon_brightness = (float)psky->getMoonBrightness(); moon_shader->uniform1f(LLShaderMgr::MOON_BRIGHTNESS, moon_brightness); - moon_shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, gSky.mVOSkyp->getMoon().getColor().mV); + moon_shader->uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, gSky.mVOSkyp->getMoon().getColor().mV); moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); //moon_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); moon_shader->uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, psky->getMoonDirection().mV); // shader: moon_dir diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index ae43203fa1..91006c9116 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1749,7 +1749,7 @@ void LLEnvironment::updateGLVariablesForSettings(LLShaderUniforms* uniforms, con break; } //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << vect4 << LL_ENDL; - shader->uniform4fv(it.second.getShaderKey(), vect4 ); + shader->uniform3fv(it.second.getShaderKey(), LLVector3(vect4.mV) ); break; } diff --git a/indra/newview/llfloaterperms.cpp b/indra/newview/llfloaterperms.cpp index 649a107d74..fb55c6c6c4 100644 --- a/indra/newview/llfloaterperms.cpp +++ b/indra/newview/llfloaterperms.cpp @@ -123,6 +123,7 @@ const std::string LLFloaterPermsDefault::sCategoryNames[CAT_LAST] = "Gestures", "Wearables", "Settings" + "Materials" }; BOOL LLFloaterPermsDefault::postBuild() diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 01ebdf6830..6153d71098 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1194,14 +1194,6 @@ void LLFloaterPreference::refreshEnabledState() void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() { - LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections"); - LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText"); - - // Reflections - BOOL reflections = LLCubeMap::sUseCubeMaps; - ctrl_reflections->setEnabled(reflections); - reflections_text->setEnabled(reflections); - // WindLight LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail"); LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText"); @@ -1282,8 +1274,6 @@ void LLAvatarComplexityControls::setIndirectMaxArc() void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings() { - LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections"); - LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText"); LLComboBox* ctrl_shadows = getChild<LLComboBox>("ShadowDetail"); LLTextBox* shadows_text = getChild<LLTextBox>("RenderShadowDetailText"); LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO"); @@ -1291,25 +1281,17 @@ void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings() // disabled deferred SSAO if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO")) { - ctrl_ssao->setEnabled(FALSE); + ctrl_ssao->setEnabled(FALSE); ctrl_ssao->setValue(FALSE); } // disabled deferred shadows - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail")) - { - ctrl_shadows->setEnabled(FALSE); - ctrl_shadows->setValue(0); - shadows_text->setEnabled(FALSE); - } - - // disabled reflections - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail")) - { - ctrl_reflections->setEnabled(FALSE); - ctrl_reflections->setValue(FALSE); - reflections_text->setEnabled(FALSE); - } + if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail")) + { + ctrl_shadows->setEnabled(FALSE); + ctrl_shadows->setValue(0); + shadows_text->setEnabled(FALSE); + } } void LLFloaterPreference::refresh() diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index 5cbf853179..a433644e0e 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -28,13 +28,47 @@ #include "llgltfmateriallist.h" #include "llassetstorage.h" +#include "lldispatcher.h" #include "llfilesystem.h" #include "llsdserialize.h" #include "lltinygltfhelper.h" +#include "llviewergenericmessage.h" #include "tinygltf/tiny_gltf.h" #include <strstream> +namespace +{ + class LLGLTFOverrideDispatchHandler : public LLDispatchHandler + { + public: + LLGLTFOverrideDispatchHandler() = default; + ~LLGLTFOverrideDispatchHandler() override = default; + + bool operator()(const LLDispatcher* dispatcher, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override + { + for (std::string const & s : strings) { + LL_DEBUGS() << "received override: " << s << LL_ENDL; + +#if 0 + // for now messages are coming in llsd + LLSD override_data; + std::istringstream input(s); + LLSDSerialize::deserialize(override_data, input, s.length()); + LL_DEBUGS() << "deserialized override: " << override_data << LL_ENDL; +#else + std::string warn_msg, error_msg; + LLGLTFMaterial override_data; + override_data.fromJSON(s, warn_msg, error_msg); +#endif + } + + return true; + } + }; + LLGLTFOverrideDispatchHandler handle_gltf_override_message; +} + LLGLTFMaterialList gGLTFMaterialList; LLGLTFMaterial* LLGLTFMaterialList::getMaterial(const LLUUID& id) @@ -83,18 +117,9 @@ LLGLTFMaterial* LLGLTFMaterialList::getMaterial(const LLUUID& id) { std::string data = asset["data"]; - tinygltf::TinyGLTF gltf; - tinygltf::TinyGLTF loader; - std::string error_msg; - std::string warn_msg; - - tinygltf::Model model_in; + std::string warn_msg, error_msg; - if (loader.LoadASCIIFromString(&model_in, &error_msg, &warn_msg, data.c_str(), data.length(), "")) - { - LLTinyGLTFHelper::setFromModel(mat, model_in, 0); - } - else + if (!mat->fromJSON(data, warn_msg, error_msg)) { LL_WARNS() << "Failed to decode material asset: " << LL_ENDL; LL_WARNS() << warn_msg << LL_ENDL; @@ -128,3 +153,8 @@ void LLGLTFMaterialList::removeMaterial(const LLUUID& id) mList.erase(id); } +// static +void LLGLTFMaterialList::registerCallbacks() +{ + gGenericDispatcher.addHandler("GLTF", &handle_gltf_override_message); +} diff --git a/indra/newview/llgltfmateriallist.h b/indra/newview/llgltfmateriallist.h index 49760504e6..4aed4b009d 100644 --- a/indra/newview/llgltfmateriallist.h +++ b/indra/newview/llgltfmateriallist.h @@ -44,6 +44,8 @@ public: void addMaterial(const LLUUID& id, LLGLTFMaterial* material); void removeMaterial(const LLUUID& id); + static void registerCallbacks(); + }; extern LLGLTFMaterialList gGLTFMaterialList; diff --git a/indra/newview/llhudobject.cpp b/indra/newview/llhudobject.cpp index 45fa09e1a1..fe6793ce73 100644 --- a/indra/newview/llhudobject.cpp +++ b/indra/newview/llhudobject.cpp @@ -267,6 +267,13 @@ void LLHUDObject::updateAll() // static void LLHUDObject::renderAll() { + LLGLSUIDefault gls_ui; + + gGL.color4f(1, 1, 1, 1); + + gUIProgram.bind(); + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + LLHUDObject *hud_objp; hud_object_list_t::iterator object_it; @@ -285,6 +292,7 @@ void LLHUDObject::renderAll() } LLVertexBuffer::unbind(); + gUIProgram.unbind(); } // static diff --git a/indra/newview/lllocalgltfmaterials.cpp b/indra/newview/lllocalgltfmaterials.cpp index 1f16549a47..fe2b7ac816 100644 --- a/indra/newview/lllocalgltfmaterials.cpp +++ b/indra/newview/lllocalgltfmaterials.cpp @@ -270,7 +270,7 @@ bool LLLocalGLTFMaterial::loadMaterial(LLPointer<LLGLTFMaterial> mat, S32 index) } // sets everything, but textures will have inaccurate ids - LLTinyGLTFHelper::setFromModel(mat, model_in, index); + mat->setFromModel(model_in, index); std::string folder = gDirUtilp->getDirName(filename_lc); tinygltf::Material material_in = model_in.materials[index]; diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 27b5d508e0..735b4af689 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -935,13 +935,33 @@ bool LLMaterialEditor::saveIfNeeded() tid.generate(); // timestamp-based randomization + uniquification LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); std::string res_desc = buildMaterialDescription(); - U32 next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Uploads"); + U32 next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Materials"); LLUUID parent = gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_MATERIAL); const U8 subtype = NO_INV_SUBTYPE; // TODO maybe use AT_SETTINGS and LLSettingsType::ST_MATERIAL ? create_inventory_item(gAgent.getID(), gAgent.getSessionID(), parent, tid, mMaterialName, res_desc, LLAssetType::AT_MATERIAL, LLInventoryType::IT_MATERIAL, subtype, next_owner_perm, - new LLBoostFuncInventoryCallback([output = buffer](LLUUID const& inv_item_id) { + new LLBoostFuncInventoryCallback([output = buffer](LLUUID const& inv_item_id) + { + LLViewerInventoryItem* item = gInventory.getItem(inv_item_id); + if (item) + { + // create_inventory_item doesn't allow presetting some permissions, fix it now + LLPermissions perm = item->getPermissions(); + if (perm.getMaskEveryone() != LLFloaterPerms::getEveryonePerms("Materials") + || perm.getMaskGroup() != LLFloaterPerms::getGroupPerms("Materials")) + { + perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Materials")); + perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Materials")); + + item->setPermissions(perm); + + item->updateServer(FALSE); + gInventory.updateItem(item); + gInventory.notifyObservers(); + } + } + // from reference in LLSettingsVOBase::createInventoryItem()/updateInventoryItem() LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>( @@ -966,7 +986,7 @@ bool LLMaterialEditor::saveIfNeeded() } LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); } - }) + }) ); // We do not update floater with uploaded asset yet, so just close it. @@ -1379,6 +1399,16 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 ind } } +void LLMaterialEditor::loadLiveMaterial(LLGLTFMaterial * material, bool make_copy) +{ + if (!material) + { + return; + } + LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor"); + me->loadMaterial(material, make_copy); +} + void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std::string &filename_lc, S32 index) { if (model_in.materials.size() <= index) @@ -1483,6 +1513,61 @@ void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std:: applyToSelection(); } +void LLMaterialEditor::loadMaterial(LLGLTFMaterial * material, bool make_copy) +{ + setBaseColorId(material->mBaseColorId); + setMetallicRoughnessId(material->mMetallicRoughnessId); + setEmissiveId(material->mEmissiveId); + setNormalId(material->mNormalId); + + setAlphaMode(material->getAlphaMode()); + setAlphaCutoff(material->mAlphaCutoff); + + setBaseColor(material->mBaseColor); + setEmissiveColor(material->mEmissiveColor); + + setMetalnessFactor(material->mMetallicFactor); + setRoughnessFactor(material->mRoughnessFactor); + + setDoubleSided(material->mDoubleSided); + + if (make_copy) + { + setTitle(LLTrans::getString("New Material")); + } + else + { + setTitle(getString("material_override_title")); + // TODO: Save whole selection + + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + LLViewerObject* object = selection->getFirstNode()->getObject(); + if (object) + { + const S32 num_tes = llmin((S32)object->getNumTEs(), (S32)object->getNumFaces()); // avatars have TEs but no faces + for (S32 face = 0; face < num_tes; ++face) + { + LLTextureEntry *te = object->getTE(face); + if (te->isSelected()) + { + // TEMP + setOverrideTarget(object->getLocalID(), face); + break; + } + } + } + } + + // Todo: At the moment it always makes a 'copy' + // Will need a way to expand existing material + // once overrides are done + + setHasUnsavedChanges(make_copy); + + openFloater(); + setFocus(TRUE); +} + bool LLMaterialEditor::setFromGltfModel(const tinygltf::Model& model, S32 index, bool set_textures) { if (model.materials.size() > index) @@ -1788,10 +1873,10 @@ void LLMaterialEditor::importMaterial() true); } -class LLRemderMaterialFunctor : public LLSelectedTEFunctor +class LLRenderMaterialFunctor : public LLSelectedTEFunctor { public: - LLRemderMaterialFunctor(const LLUUID &id) + LLRenderMaterialFunctor(const LLUUID &id) : mMatId(id) { } @@ -1810,16 +1895,59 @@ private: LLUUID mMatId; }; +class LLRenderMaterialOverrideFunctor : public LLSelectedTEFunctor +{ +public: + LLRenderMaterialOverrideFunctor(LLMaterialEditor * me, std::string const & url) + : mEditor(me), mCapUrl(url) + { + + } + + bool apply(LLViewerObject* objectp, S32 te) override + { + if (objectp && objectp->permModify() && objectp->getVolume()) + { + //LLVOVolume* vobjp = (LLVOVolume*)objectp; + S32 local_id = objectp->getLocalID(); + + LLSD overrides = llsd::map( + "local_id", local_id, + "side", te, + "overrides", LLSD::emptyMap() + ); + LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLMaterialEditor::modifyMaterialCoro, mEditor, mCapUrl, overrides)); + } + return true; + } + +private: + LLMaterialEditor * mEditor; + std::string mCapUrl; +}; + void LLMaterialEditor::applyToSelection() { - // Placehodler. Will be removed once override systems gets finished. - LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial(); - getGLTFMaterial(mat); - const LLUUID placeholder("984e183e-7811-4b05-a502-d79c6f978a98"); - gGLTFMaterialList.addMaterial(placeholder, mat); - LLRemderMaterialFunctor mat_func(placeholder); - LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); - selected_objects->applyToTEs(&mat_func); + std::string url = gAgent.getRegionCapability("ModifyMaterialParams"); + if (!url.empty()) + { + LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); + LLRenderMaterialOverrideFunctor override_func(this, url); + selected_objects->applyToTEs(&override_func); + } + else + { + LL_WARNS() << "not connected to materials capable region, missing ModifyMaterialParams cap" << LL_ENDL; + + // Fallback local preview. Will be removed once override systems is finished and new cap is deployed everywhere. + LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial(); + getGLTFMaterial(mat); + static const LLUUID placeholder("984e183e-7811-4b05-a502-d79c6f978a98"); + gGLTFMaterialList.addMaterial(placeholder, mat); + LLRenderMaterialFunctor mat_func(placeholder); + LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); + selected_objects->applyToTEs(&mat_func); + } } void LLMaterialEditor::getGLTFMaterial(LLGLTFMaterial* mat) @@ -2212,3 +2340,31 @@ void LLMaterialEditor::loadDefaults() model_in.materials.resize(1); setFromGltfModel(model_in, 0, true); } + +void LLMaterialEditor::modifyMaterialCoro(std::string cap_url, LLSD overrides) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("modifyMaterialCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpHeaders::ptr_t httpHeaders; + + httpOpts->setFollowRedirects(true); + + LL_DEBUGS() << "Applying override via ModifyMaterialParams cap: " << overrides << LL_ENDL; + + LLSD result = httpAdapter->postAndSuspend(httpRequest, cap_url, overrides, httpOpts, httpHeaders); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS() << "Failed to modify material." << LL_ENDL; + } + else if (!result["success"].asBoolean()) + { + LL_WARNS() << "Failed to modify material: " << result["message"] << LL_ENDL; + } +} diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index d329222648..9bc6be4b92 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -104,6 +104,7 @@ public: // @index if -1 and file contains more than one material, // will promt to select specific one static void loadMaterialFromFile(const std::string& filename, S32 index = -1); + static void loadLiveMaterial(LLGLTFMaterial * material, bool make_copy); static void onLoadComplete(const LLUUID& asset_uuid, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status); @@ -215,8 +216,14 @@ public: // initialize the UI from a default GLTF material void loadDefaults(); + + void modifyMaterialCoro(std::string cap_url, LLSD overrides); + private: void loadMaterial(const tinygltf::Model &model, const std::string &filename_lc, S32 index); + // if make_copy is set, will make a copy for saving, + // otherwise will edit existing material + void loadMaterial(LLGLTFMaterial * material, bool make_copy); friend class LLMaterialFilePicker; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index a4a91baad8..fd8bf044f8 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -46,6 +46,7 @@ #include "llcombobox.h" #include "lldrawpoolbump.h" #include "llface.h" +#include "llgltfmateriallist.h" #include "llinventoryfunctions.h" #include "llinventorymodel.h" // gInventory #include "llinventorymodelbackgroundfetch.h" @@ -53,6 +54,7 @@ #include "llfloaterreg.h" #include "lllineeditor.h" #include "llmaterialmgr.h" +#include "llmaterialeditor.h" #include "llmediactrl.h" #include "llmediaentry.h" #include "llmenubutton.h" @@ -91,6 +93,7 @@ #include "llsdserialize.h" #include "llinventorymodel.h" +using namespace std::literals; // // Constant definitions for comboboxes @@ -119,10 +122,23 @@ std::string USE_TEXTURE; LLRender::eTexIndex LLPanelFace::getTextureChannelToEdit() { - LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); - LLRender::eTexIndex channel_to_edit = (mComboMatMedia && mComboMatMedia->getCurrentIndex() == MATMEDIA_MATERIAL) ? - (radio_mat_type ? (LLRender::eTexIndex)radio_mat_type->getSelectedIndex() : LLRender::DIFFUSE_MAP) : LLRender::DIFFUSE_MAP; + + LLRender::eTexIndex channel_to_edit = LLRender::DIFFUSE_MAP; + if (mComboMatMedia) + { + U32 matmedia_selection = mComboMatMedia->getCurrentIndex(); + if (matmedia_selection == MATMEDIA_MATERIAL) + { + LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); + channel_to_edit = (LLRender::eTexIndex)radio_mat_type->getSelectedIndex(); + } + if (matmedia_selection == MATMEDIA_PBR) + { + LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_pbr_type"); + channel_to_edit = (LLRender::eTexIndex)radio_mat_type->getSelectedIndex(); + } + } channel_to_edit = (channel_to_edit == LLRender::NORMAL_MAP) ? (getCurrentNormalMap().isNull() ? LLRender::DIFFUSE_MAP : channel_to_edit) : channel_to_edit; channel_to_edit = (channel_to_edit == LLRender::SPECULAR_MAP) ? (getCurrentSpecularMap().isNull() ? LLRender::DIFFUSE_MAP : channel_to_edit) : channel_to_edit; @@ -221,6 +237,9 @@ BOOL LLPanelFace::postBuild() pbr_ctrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); pbr_ctrl->setBakeTextureEnabled(false); pbr_ctrl->setInventoryPickType(LLTextureCtrl::PICK_MATERIAL); + + // TODO - design real UI for activating live editing + pbr_ctrl->setRightMouseUpCallback(boost::bind(&LLPanelFace::onPbrStartEditing, this)); } mTextureCtrl = getChild<LLTextureCtrl>("texture control"); @@ -517,20 +536,42 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor { BOOL valid; F32 value; - - LLRadioGroup * radio_mat_type = mPanel->getChild<LLRadioGroup>("radio_material_type"); std::string prefix; - switch (radio_mat_type->getSelectedIndex()) + U32 materials_media = mPanel->getChild<LLComboBox>("combobox matmedia")->getCurrentIndex(); + + if (MATMEDIA_PBR == materials_media) { - case MATTYPE_DIFFUSE: - prefix = "Tex"; - break; - case MATTYPE_NORMAL: - prefix = "bumpy"; - break; - case MATTYPE_SPECULAR: - prefix = "shiny"; - break; + LLRadioGroup * radio_pbr_type = mPanel->getChild<LLRadioGroup>("radio_pbr_type"); + switch (radio_pbr_type->getSelectedIndex()) + { + case PBRTYPE_BASE_COLOR: + prefix = "Tex"; + break; + case PBRTYPE_NORMAL: + prefix = "bumpy"; + break; + case PBRTYPE_METALLIC: + prefix = "shiny"; + break; + } + } + else + { + // Effectively the same as MATMEDIA_PBR sans using different radio, + // separate for the sake of clarity + LLRadioGroup * radio_mat_type = mPanel->getChild<LLRadioGroup>("radio_material_type"); + switch (radio_mat_type->getSelectedIndex()) + { + case MATTYPE_DIFFUSE: + prefix = "Tex"; + break; + case MATTYPE_NORMAL: + prefix = "bumpy"; + break; + case MATTYPE_SPECULAR: + prefix = "shiny"; + break; + } } LLSpinCtrl * ctrlTexScaleS = mPanel->getChild<LLSpinCtrl>(prefix + "ScaleU"); @@ -3468,11 +3509,20 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) LLPanelFace* self = (LLPanelFace*) userdata; LLUICtrl* repeats_ctrl = self->getChild<LLUICtrl>("rptctrl"); - LLRadioGroup* radio_mat_type = self->getChild<LLRadioGroup>("radio_material_type"); U32 materials_media = self->mComboMatMedia->getCurrentIndex(); + U32 material_type = 0; + if (materials_media == MATMEDIA_PBR) + { + LLRadioGroup* radio_mat_type = self->getChild<LLRadioGroup>("radio_pbr_type"); + material_type = radio_mat_type->getSelectedIndex(); + } + if (materials_media == MATMEDIA_MATERIAL) + { + LLRadioGroup* radio_mat_type = self->getChild<LLRadioGroup>("radio_material_type"); + material_type = radio_mat_type->getSelectedIndex(); + } - U32 material_type = (materials_media == MATMEDIA_MATERIAL) ? radio_mat_type->getSelectedIndex() : 0; F32 repeats_per_meter = repeats_ctrl->getValue().asReal(); F32 obj_scale_s = 1.0f; @@ -4530,6 +4580,26 @@ void LLPanelFace::onPbrSelectionChanged(LLInventoryItem* itemp) } } +void LLPanelFace::onPbrStartEditing() { + LL_DEBUGS() << "begin live editing material" << LL_ENDL; + + LLMaterialEditor *editor = + dynamic_cast<LLMaterialEditor *>(LLFloaterReg::showInstance("material_editor", LLSD(LLUUID::null), TAKE_FOCUS_YES)); + if (editor) + { + bool identical; + LLUUID material_id; + LLSelectedTE::getPbrMaterialId(material_id, identical); + + LL_DEBUGS() << "loading material live editor with asset " << material_id << LL_ENDL; + + LLGLTFMaterial* material = gGLTFMaterialList.getMaterial(material_id); + editor->setTitle("Editing material on selection"s); + editor->setAssetId(material_id); + editor->setFromGLTFMaterial(material); + } +} + bool LLPanelFace::isIdenticalPlanarTexgen() { LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 725cfb0f5f..cc46116545 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -438,6 +438,7 @@ private: */ void onTextureSelectionChanged(LLInventoryItem* itemp); void onPbrSelectionChanged(LLInventoryItem* itemp); + void onPbrStartEditing(); LLMenuButton* mMenuClipboardColor; LLMenuButton* mMenuClipboardTexture; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 8f1ee8f70b..19f0a8d089 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -41,10 +41,13 @@ extern BOOL gTeleportDisplay; LLReflectionMapManager::LLReflectionMapManager() { - for (int i = 0; i < LL_MAX_REFLECTION_PROBE_COUNT; ++i) + for (int i = 1; i < LL_MAX_REFLECTION_PROBE_COUNT; ++i) { mCubeFree[i] = true; } + + // cube index 0 is reserved for the fallback probe + mCubeFree[0] = false; } struct CompareReflectionMapDistance @@ -102,6 +105,15 @@ void LLReflectionMapManager::update() } + if (mDefaultProbe.isNull()) + { + mDefaultProbe = addProbe(); + mDefaultProbe->mDistance = -4096.f; // hack to make sure the default probe is always first in sort order + mDefaultProbe->mRadius = 4096.f; + } + + mDefaultProbe->mOrigin.load3(LLViewerCamera::getInstance()->getOrigin().mV); + LLVector4a camera_pos; camera_pos.load3(LLViewerCamera::instance().getOrigin().mV); @@ -174,8 +186,11 @@ void LLReflectionMapManager::update() closestDynamic = probe; } - d.setSub(camera_pos, probe->mOrigin); - probe->mDistance = d.getLength3().getF32()-probe->mRadius; + if (probe != mDefaultProbe) + { + d.setSub(camera_pos, probe->mOrigin); + probe->mDistance = d.getLength3().getF32() - probe->mRadius; + } } if (realtime && closestDynamic != nullptr) @@ -196,7 +211,8 @@ void LLReflectionMapManager::update() if (probe->mCubeIndex == -1) { probe->mCubeArray = mTexture; - probe->mCubeIndex = allocateCubeIndex(); + + probe->mCubeIndex = probe == mDefaultProbe ? 0 : allocateCubeIndex(); } probe->autoAdjustOrigin(); @@ -346,6 +362,8 @@ void LLReflectionMapManager::deleteProbe(U32 i) LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; LLReflectionMap* probe = mProbes[i]; + llassert(probe != mDefaultProbe); + if (probe->mCubeIndex != -1) { // mark the cube index used by this probe as being free mCubeFree[probe->mCubeIndex] = true; @@ -429,7 +447,6 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) { LL_PROFILE_GPU_ZONE("probe mip"); mMipChain[i].bindTarget(); - if (i == 0) { @@ -607,6 +624,10 @@ void LLReflectionMapManager::shift(const LLVector4a& offset) void LLReflectionMapManager::updateNeighbors(LLReflectionMap* probe) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + if (mDefaultProbe == probe) + { + return; + } //remove from existing neighbors { @@ -627,7 +648,7 @@ void LLReflectionMapManager::updateNeighbors(LLReflectionMap* probe) LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmun - search"); for (auto& other : mProbes) { - if (other != probe) + if (other != mDefaultProbe && other != probe) { if (probe->intersects(other)) { diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index 4dcd822677..14b762998a 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -155,6 +155,8 @@ private: LLReflectionMap* mUpdatingProbe = nullptr; U32 mUpdatingFace = 0; + LLPointer<LLReflectionMap> mDefaultProbe; // default reflection probe to fall back to for pixels with no probe influences (should always be at cube index 0) + // number of reflection probes to use for rendering (based on saved setting RenderReflectionProbeCount) U32 mReflectionProbeCount; }; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index fdd988ddc0..f9b7c749b3 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -667,17 +667,17 @@ void LLSettingsVOSky::updateSettings() void LLSettingsVOSky::applySpecial(void *ptarget, bool force) { LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; - LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); + LLVector3 light_direction = LLVector3(LLEnvironment::instance().getClampedLightNorm().mV); LLShaderUniforms* shader = &((LLShaderUniforms*)ptarget)[LLGLSLShader::SG_DEFAULT]; { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, light_direction); + shader->uniform3fv(LLViewerShaderMgr::LIGHTNORM, light_direction); shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, LLViewerCamera::getInstance()->getOrigin()); } shader = &((LLShaderUniforms*)ptarget)[LLGLSLShader::SG_SKY]; { - shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, light_direction); + shader->uniform3fv(LLViewerShaderMgr::LIGHTNORM, light_direction); // Legacy? SETTING_CLOUD_SCROLL_RATE("cloud_scroll_rate") LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); @@ -690,26 +690,26 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force) // * indra\newview\app_settings\shaders\class1\deferred\cloudsV.glsl cloud_scroll[0] = -cloud_scroll[0]; vect_c_p_d1 += cloud_scroll; - shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, vect_c_p_d1); + shader->uniform3fv(LLShaderMgr::CLOUD_POS_DENSITY1, LLVector3(vect_c_p_d1.mV)); LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LLVector4 sunDiffuse = LLVector4(psky->getSunlightColor().mV); - LLVector4 moonDiffuse = LLVector4(psky->getMoonlightColor().mV); + // TODO -- make these getters return vec3s + LLVector3 sunDiffuse = LLVector3(psky->getSunlightColor().mV); + LLVector3 moonDiffuse = LLVector3(psky->getMoonlightColor().mV); - shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, sunDiffuse); - shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, moonDiffuse); + shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, sunDiffuse); + shader->uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, moonDiffuse); - LLVector4 cloud_color(LLVector3(psky->getCloudColor().mV), 1.0); - shader->uniform4fv(LLShaderMgr::CLOUD_COLOR, cloud_color); + shader->uniform3fv(LLShaderMgr::CLOUD_COLOR, LLVector3(psky->getCloudColor().mV)); } shader = &((LLShaderUniforms*)ptarget)[LLGLSLShader::SG_ANY]; shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength); - LLColor4 ambient(getTotalAmbient()); + LLColor3 ambient(getTotalAmbient()); - shader->uniform4fv(LLShaderMgr::AMBIENT, LLVector4(ambient.mV)); + shader->uniform3fv(LLShaderMgr::AMBIENT, LLVector3(ambient.mV)); shader->uniform3fv(LLShaderMgr::AMBIENT_LINEAR, linearColor3v(getAmbientColor()/3.f)); // note magic number 3.f comes from SLIDER_SCALE_SUN_AMBIENT shader->uniform3fv(LLShaderMgr::SUNLIGHT_LINEAR, linearColor3v(getSunlightColor())); shader->uniform3fv(LLShaderMgr::MOONLIGHT_LINEAR,linearColor3v(getMoonlightColor())); @@ -965,14 +965,16 @@ void LLSettingsVOWater::applySpecial(void *ptarget, bool force) F32 waterFogDensity = env.getCurrentWater()->getModifiedWaterFogDensity(underwater); shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, waterFogDensity); - LLColor4 fog_color(env.getCurrentWater()->getWaterFogColor(), 0.0f); + LLColor4 fog_color(env.getCurrentWater()->getWaterFogColor()); shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, fog_color.mV); + shader->uniform3fv(LLShaderMgr::WATER_FOGCOLOR_LINEAR, linearColor3(fog_color).mV); + F32 blend_factor = env.getCurrentWater()->getBlendFactor(); shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); // update to normal lightnorm, water shader itself will use rotated lightnorm as necessary - shader->uniform4fv(LLShaderMgr::LIGHTNORM, light_direction.mV); + shader->uniform3fv(LLShaderMgr::LIGHTNORM, light_direction.mV); } } diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 6aca701fe2..548f6fd6d2 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -60,6 +60,7 @@ #include "llfloatergridstatus.h" #include "llfloaterimsession.h" #include "lllocationhistory.h" +#include "llgltfmateriallist.h" #include "llimageworker.h" #include "llloginflags.h" @@ -1285,9 +1286,6 @@ bool idle_startup() // Initialize classes w/graphics stuff. // LLViewerStatsRecorder::instance(); // Since textures work in threads - gTextureList.doPrefetchImages(); - display_startup(); - LLSurface::initClasses(); display_startup(); @@ -1432,6 +1430,12 @@ bool idle_startup() if (STATE_SEED_CAP_GRANTED == LLStartUp::getStartupState()) { display_startup(); + + // These textures are not warrantied to be cached, so needs + // to hapen with caps granted + gTextureList.doPrefetchImages(); + + display_startup(); update_texture_fetch(); display_startup(); @@ -1473,6 +1477,9 @@ bool idle_startup() gXferManager->registerCallbacks(gMessageSystem); display_startup(); + LLGLTFMaterialList::registerCallbacks(); + display_startup(); + LLStartUp::initNameCache(); display_startup(); diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 987918fc1d..7cccd6f5ac 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -1291,10 +1291,14 @@ bool LLTextureFetchWorker::doWork(S32 param) if ( use_http && mCanUseHTTP && mUrl.empty())//get http url. { LLViewerRegion* region = NULL; - if (mHost.isInvalid()) - region = gAgent.getRegion(); - else - region = LLWorld::getInstance()->getRegion(mHost); + if (mHost.isInvalid()) + { + region = gAgent.getRegion(); + } + else if (LLWorld::instanceExists()) + { + region = LLWorld::getInstance()->getRegion(mHost); + } if (region) { diff --git a/indra/newview/lltinygltfhelper.cpp b/indra/newview/lltinygltfhelper.cpp index c3dc10c2a0..c80e87652a 100644 --- a/indra/newview/lltinygltfhelper.cpp +++ b/indra/newview/lltinygltfhelper.cpp @@ -122,71 +122,6 @@ void LLTinyGLTFHelper::initFetchedTextures(tinygltf::Material& material, } } -void LLTinyGLTFHelper::setFromModel(LLGLTFMaterial* mat, tinygltf::Model& model, S32 mat_index) -{ - if (model.materials.size() <= mat_index) - { - return; - } - - tinygltf::Material& material_in = model.materials[mat_index]; - - // get base color texture - S32 tex_index = material_in.pbrMetallicRoughness.baseColorTexture.index; - if (tex_index >= 0) - { - mat->mBaseColorId.set(model.images[tex_index].uri); - } - else - { - mat->mBaseColorId.setNull(); - } - - // get normal map - tex_index = material_in.normalTexture.index; - if (tex_index >= 0) - { - mat->mNormalId.set(model.images[tex_index].uri); - } - else - { - mat->mNormalId.setNull(); - } - - // get metallic-roughness texture - tex_index = material_in.pbrMetallicRoughness.metallicRoughnessTexture.index; - if (tex_index >= 0) - { - mat->mMetallicRoughnessId.set(model.images[tex_index].uri); - } - else - { - mat->mMetallicRoughnessId.setNull(); - } - - // get emissive texture - tex_index = material_in.emissiveTexture.index; - if (tex_index >= 0) - { - mat->mEmissiveId.set(model.images[tex_index].uri); - } - else - { - mat->mEmissiveId.setNull(); - } - - mat->setAlphaMode(material_in.alphaMode); - mat->mAlphaCutoff = llclamp((F32)material_in.alphaCutoff, 0.f, 1.f); - - mat->mBaseColor= getColor(material_in.pbrMetallicRoughness.baseColorFactor); - mat->mEmissiveColor = getColor(material_in.emissiveFactor); - - mat->mMetallicFactor = llclamp((F32)material_in.pbrMetallicRoughness.metallicFactor, 0.f, 1.f); - mat->mRoughnessFactor = llclamp((F32)material_in.pbrMetallicRoughness.roughnessFactor, 0.f, 1.f); - - mat->mDoubleSided = material_in.doubleSided; -} - LLColor4 LLTinyGLTFHelper::getColor(const std::vector<double>& in) { LLColor4 out; diff --git a/indra/newview/lltinygltfhelper.h b/indra/newview/lltinygltfhelper.h index afe4517417..9c2e5afc17 100644 --- a/indra/newview/lltinygltfhelper.h +++ b/indra/newview/lltinygltfhelper.h @@ -35,7 +35,6 @@ class LLViewerFetchedTexture; namespace LLTinyGLTFHelper { - void setFromModel(LLGLTFMaterial* mat, tinygltf::Model& model, S32 index); LLColor4 getColor(const std::vector<double>& in); const tinygltf::Image* getImageFromTextureIndex(const tinygltf::Model& model, S32 texture_index); LLImageRaw* getTexture(const std::string& folder, const tinygltf::Model& model, S32 texture_index, std::string& name); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index b3bc831670..46e25b18b7 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -772,7 +772,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("display - 3") LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery"); - gPipeline.generateWaterReflection(*LLViewerCamera::getInstance()); gPipeline.generateHighlight(*LLViewerCamera::getInstance()); gPipeline.renderPhysicsDisplay(); } @@ -861,7 +860,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { glClearColor(0.5f, 0.5f, 0.5f, 0.f); glClear(GL_COLOR_BUFFER_BIT); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } LLAppViewer::instance()->pingMainloopTimeout("Display:RenderStart"); @@ -914,7 +912,15 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (LLPipeline::sRenderDeferred) { gPipeline.mRT->deferredScreen.bindTarget(); - glClearColor(1, 0, 1, 1); + if (gUseWireframe) + { + F32 g = 0.5f; + glClearColor(g, g, g, 1.f); + } + else + { + glClearColor(1, 0, 1, 1); + } gPipeline.mRT->deferredScreen.clear(); } else @@ -1103,6 +1109,7 @@ void display_cube_face() gPipeline.updateCull(*LLViewerCamera::getInstance(), result); gGL.setColorMask(true, true); + glClearColor(0, 0, 0, 0); gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); @@ -1133,7 +1140,14 @@ void display_cube_face() gGL.setColorMask(true, true); gPipeline.mRT->deferredScreen.bindTarget(); - glClearColor(1, 0, 1, 1); + if (gUseWireframe) + { + glClearColor(0.5f, 0.5f, 0.5f, 1.f); + } + else + { + glClearColor(1, 0, 1, 1); + } gPipeline.mRT->deferredScreen.clear(); gGL.setColorMask(true, false); @@ -1239,7 +1253,7 @@ void render_hud_attachments() gPipeline.stateSort(hud_cam, result); - gPipeline.renderGeom(hud_cam); + gPipeline.renderGeomPostDeferred(hud_cam); LLSpatialGroup::sNoDelete = FALSE; //gPipeline.clearReferences(); @@ -1421,9 +1435,8 @@ void render_ui(F32 zoom_factor, int subfield) if (render_ui) { LL_PROFILE_ZONE_NAMED_CATEGORY_UI("UI 2D"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_UI_2D); + LLHUDObject::renderAll(); render_ui_2d(); - LLGLState::checkStates(); - gGL.flush(); } gViewerWindow->setup2DRender(); diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 2265379ce4..b4feafb7ff 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -999,6 +999,21 @@ void create_notecard_cb(const LLUUID& inv_item) } } +void create_gltf_material_cb(const LLUUID& inv_item) +{ + if (!inv_item.isNull()) + { + LLViewerInventoryItem* item = gInventory.getItem(inv_item); + if (item) + { + set_default_permissions(item, "Materials"); + + gInventory.updateItem(item); + gInventory.notifyObservers(); + } + } +} + LLInventoryCallbackManager gInventoryCallbacks; void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id, @@ -1623,6 +1638,13 @@ void create_new_item(const std::string& name, next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Notecards"); break; } + + case LLInventoryType::IT_MATERIAL: + { + cb = new LLBoostFuncInventoryCallback(create_gltf_material_cb); + next_owner_perm = LLFloaterPerms::getNextOwnerPerms("Materials"); + break; + } default: break; } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 1842c434e7..8a92d9062f 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -92,6 +92,7 @@ #include "llpanelblockedlist.h" #include "llpanelmaininventory.h" #include "llmarketplacefunctions.h" +#include "llmaterialeditor.h" #include "llmenuoptionpathfindingrebakenavmesh.h" #include "llmoveview.h" #include "llnavigationbar.h" @@ -1210,6 +1211,7 @@ class LLAdvancedCheckFrameTest : public view_listener_t /////////////////////////// // SELECTED TEXTURE INFO // +// /////////////////////////// @@ -1231,24 +1233,6 @@ class LLAdvancedToggleWireframe : public view_listener_t bool handleEvent(const LLSD& userdata) { gUseWireframe = !(gUseWireframe); - gWindowResized = TRUE; - - LLPipeline::updateRenderDeferred(); - - if (gUseWireframe) - { - gInitialDeferredModeForWireframe = LLPipeline::sRenderDeferred; - } - - gPipeline.resetVertexBuffers(); - - if (!gUseWireframe && !gInitialDeferredModeForWireframe && LLPipeline::sRenderDeferred != bool(gInitialDeferredModeForWireframe) && gPipeline.isInit()) - { - LLPipeline::refreshCachedSettings(); - gPipeline.releaseGLBuffers(); - gPipeline.createGLBuffers(); - LLViewerShaderMgr::instance()->setShaders(); - } return true; } @@ -1258,8 +1242,7 @@ class LLAdvancedCheckWireframe : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = gUseWireframe; - return new_value; + return gUseWireframe; } }; @@ -2799,6 +2782,50 @@ void handle_object_open() LLFloaterReg::showInstance("openobject"); } +bool enable_object_edit_gltf_material() +{ + struct LLSelectedTEGetmatId : public LLSelectedTEGetFunctor<LLUUID> + { + LLSelectedTEGetmatId() : mCanModify(true) {} + LLUUID get(LLViewerObject* object, S32 te_index) + { + mCanModify &= (bool)object->permModify(); + // Todo: probabnly should compare material + // pointers instead + return object->getRenderMaterialID(te_index); + } + bool mCanModify; + } func; + LLUUID mat_id; + bool identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat_id); + LL_INFOS() << " Placeholder " << identical << " " << mat_id << LL_ENDL; + // Todo: this is a placeholder for overrides, + // it will have to make sure all selection is identical + return func.mCanModify; +} + +bool enable_object_save_gltf_material() +{ + struct LLSelectedTEGetmatId : public LLSelectedTEGetFunctor<LLUUID> + { + LLSelectedTEGetmatId() : mCanCopy(true) {} + LLUUID get(LLViewerObject* object, S32 te_index) + { + mCanCopy &= (bool)object->permCopy(); + // permTransfer probably should be passed to editor instead + mCanCopy &= (bool)object->permTransfer(); + return object->getRenderMaterialID(te_index); + } + bool mCanCopy; + } func; + LLUUID mat_id; + bool identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat_id); + LL_INFOS() << " Placeholder " << identical << " " << mat_id << LL_ENDL; + // Todo: this is a placeholder for overrides, + // it will have to make sure all selection is identical + return func.mCanCopy; +} + bool enable_object_open() { // Look for contents in root object, which is all the LLFloaterOpenObject @@ -2864,37 +2891,42 @@ class LLObjectBuild : public view_listener_t } }; -void handle_object_edit() +void update_camera() { - LLViewerParcelMgr::getInstance()->deselectLand(); + LLViewerParcelMgr::getInstance()->deselectLand(); - if (gAgentCamera.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit()) - { - LLFloaterTools::sPreviousFocusOnAvatar = true; - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + if (gAgentCamera.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit()) + { + LLFloaterTools::sPreviousFocusOnAvatar = true; + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + + if (selection->getSelectType() == SELECT_TYPE_HUD || !gSavedSettings.getBOOL("EditCameraMovement")) + { + // always freeze camera in space, even if camera doesn't move + // so, for example, follow cam scripts can't affect you when in build mode + gAgentCamera.setFocusGlobal(gAgentCamera.calcFocusPositionTargetGlobal(), LLUUID::null); + gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); + } + else + { + gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); + LLViewerObject* selected_objectp = selection->getFirstRootObject(); + if (selected_objectp) + { + // zoom in on object center instead of where we clicked, as we need to see the manipulator handles + gAgentCamera.setFocusGlobal(selected_objectp->getPositionGlobal(), selected_objectp->getID()); + gAgentCamera.cameraZoomIn(0.666f); + gAgentCamera.cameraOrbitOver(30.f * DEG_TO_RAD); + gViewerWindow->moveCursorToCenter(); + } + } + } +} + +void handle_object_edit() +{ + update_camera(); - if (selection->getSelectType() == SELECT_TYPE_HUD || !gSavedSettings.getBOOL("EditCameraMovement")) - { - // always freeze camera in space, even if camera doesn't move - // so, for example, follow cam scripts can't affect you when in build mode - gAgentCamera.setFocusGlobal(gAgentCamera.calcFocusPositionTargetGlobal(), LLUUID::null); - gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); - } - else - { - gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); - LLViewerObject* selected_objectp = selection->getFirstRootObject(); - if (selected_objectp) - { - // zoom in on object center instead of where we clicked, as we need to see the manipulator handles - gAgentCamera.setFocusGlobal(selected_objectp->getPositionGlobal(), selected_objectp->getID()); - gAgentCamera.cameraZoomIn(0.666f); - gAgentCamera.cameraOrbitOver( 30.f * DEG_TO_RAD ); - gViewerWindow->moveCursorToCenter(); - } - } - } - LLFloaterReg::showInstance("build"); LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); @@ -2908,6 +2940,54 @@ void handle_object_edit() return; } +void load_life_gltf_material(bool copy) +{ + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + // All materials are supposed to be identical, so pcik any node + LLViewerObject* object = selection->getFirstNode()->getObject(); + if (!object) + { + return; + } + + // This functionality is a plcaholder for overrides + // so id doesn't load object by id, but instead gets material directly + LLGLTFMaterial * mat = NULL; + + const S32 num_tes = llmin((S32)object->getNumTEs(), (S32)object->getNumFaces()); // avatars have TEs but no faces + for (S32 face = 0; face < num_tes; ++face) + { + LLTextureEntry *te = object->getTE(face); + if (te->isSelected()) + { + mat = te->getGLTFMaterial(); + break; + } + } + + if (mat == NULL) + { + return; + } + + update_camera(); + + LLMaterialEditor::loadLiveMaterial(mat, copy); + + LLViewerJoystick::getInstance()->moveObjects(true); + LLViewerJoystick::getInstance()->setNeedsReset(true); +} + +void handle_object_edit_gltf_material() +{ + load_life_gltf_material(false); +} + +void handle_object_save_gltf_material() +{ + load_life_gltf_material(true); +} + void handle_attachment_edit(const LLUUID& inv_item_id) { if (isAgentAvatarValid()) @@ -9578,10 +9658,15 @@ void initialize_menus() commit.add("Object.Buy", boost::bind(&handle_buy)); commit.add("Object.Edit", boost::bind(&handle_object_edit)); + commit.add("Object.Edit", boost::bind(&handle_object_edit)); + commit.add("Object.EditGLTFMaterial", boost::bind(&handle_object_edit_gltf_material)); + commit.add("Object.SaveGLTFMaterial", boost::bind(&handle_object_save_gltf_material)); commit.add("Object.Inspect", boost::bind(&handle_object_inspect)); commit.add("Object.Open", boost::bind(&handle_object_open)); commit.add("Object.Take", boost::bind(&handle_take)); commit.add("Object.ShowInspector", boost::bind(&handle_object_show_inspector)); + enable.add("Object.EnableEditGLTFMaterial", boost::bind(&enable_object_edit_gltf_material)); + enable.add("Object.EnableSaveGLTFMaterial", boost::bind(&enable_object_save_gltf_material)); enable.add("Object.EnableOpen", boost::bind(&enable_object_open)); enable.add("Object.EnableTouch", boost::bind(&enable_object_touch, _1)); enable.add("Object.EnableDelete", boost::bind(&enable_object_delete)); diff --git a/indra/newview/llviewermenu.h b/indra/newview/llviewermenu.h index a90b32c984..0673652e61 100644 --- a/indra/newview/llviewermenu.h +++ b/indra/newview/llviewermenu.h @@ -90,6 +90,8 @@ void handle_gestures(void*); void handle_sit_down(void*); void handle_object_build(void*); void handle_object_touch(); +bool enable_object_edit_gltf_material(); +bool enable_object_save_gltf_material(); bool enable_object_open(); void handle_object_open(); @@ -108,6 +110,8 @@ void handle_zoom_to_object(LLUUID object_id); void handle_object_return(); void handle_object_delete(); void handle_object_edit(); +void handle_object_edit_gltf_material(); +void handle_object_save_gltf_material(); void handle_attachment_edit(const LLUUID& inv_item_id); void handle_attachment_touch(const LLUUID& inv_item_id); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 628d0ecc6a..31752a5a8b 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1235,6 +1235,7 @@ U32 LLViewerRegion::getNumOfVisibleGroups() const void LLViewerRegion::updateReflectionProbes() { +#if 1 const F32 probe_spacing = 32.f; const F32 probe_radius = sqrtf((probe_spacing * 0.5f) * (probe_spacing * 0.5f) * 3.f); const F32 hover_height = 2.f; @@ -1270,6 +1271,7 @@ void LLViewerRegion::updateReflectionProbes() mReflectionMaps[idx]->mRadius = probe_radius; } } +#endif } void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry) @@ -3080,6 +3082,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("MapLayer"); capabilityNames.append("MapLayerGod"); capabilityNames.append("MeshUploadFlag"); + capabilityNames.append("ModifyMaterialParams"); capabilityNames.append("NavMeshGenerationStatus"); capabilityNames.append("NewFileAgentInventory"); capabilityNames.append("ObjectAnimation"); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 3517bbe49a..6ba31b25ff 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -440,16 +440,9 @@ void LLViewerShaderMgr::setShaders() } static LLCachedControl<U32> max_texture_index(gSavedSettings, "RenderMaxTextureIndex", 16); - LLGLSLShader::sIndexedTextureChannels = llmax(llmin(gGLManager.mNumTextureImageUnits, (S32) max_texture_index), 1); - - //NEVER use more than 16 texture channels (work around for prevalent driver bug) - LLGLSLShader::sIndexedTextureChannels = llmin(LLGLSLShader::sIndexedTextureChannels, 16); - - if (gGLManager.mGLSLVersionMajor < 1 || - (gGLManager.mGLSLVersionMajor == 1 && gGLManager.mGLSLVersionMinor <= 20)) - { //NEVER use indexed texture rendering when GLSL version is 1.20 or earlier - LLGLSLShader::sIndexedTextureChannels = 1; - } + + // when using indexed texture rendering, leave 8 texture units available for shadow and reflection maps + LLGLSLShader::sIndexedTextureChannels = llmax(llmin(gGLManager.mNumTextureImageUnits-8, (S32) max_texture_index), 1); reentrance = true; @@ -463,7 +456,6 @@ void LLViewerShaderMgr::setShaders() initAttribsAndUniforms(); gPipeline.releaseGLBuffers(); - LLPipeline::sWaterReflections = LLPipeline::sRenderTransparentWater; LLPipeline::sRenderGlow = gSavedSettings.getBOOL("RenderGlow"); LLPipeline::updateRenderDeferred(); @@ -900,7 +892,7 @@ std::string LLViewerShaderMgr::loadBasicShaders() if (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 30) { //use indexed texture rendering for GLSL >= 1.30 - ch = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); + ch = llmax(LLGLSLShader::sIndexedTextureChannels, 1); } bool has_reflection_probes = gSavedSettings.getS32("RenderReflectionProbeDetail") >= 0 && gGLManager.mGLVersion > 3.99f; @@ -1029,6 +1021,11 @@ BOOL LLViewerShaderMgr::loadShadersWater() gWaterProgram.mShaderFiles.clear(); gWaterProgram.mShaderFiles.push_back(make_pair("environment/waterV.glsl", GL_VERTEX_SHADER)); gWaterProgram.mShaderFiles.push_back(make_pair("environment/waterF.glsl", GL_FRAGMENT_SHADER)); + gWaterProgram.clearPermutations(); + if (LLPipeline::sRenderTransparentWater) + { + gWaterProgram.addPermutation("TRANSPARENT_WATER", "1"); + } gWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; gWaterProgram.mShaderLevel = mShaderLevel[SHADER_WATER]; success = gWaterProgram.createShader(NULL, NULL); @@ -1050,6 +1047,11 @@ BOOL LLViewerShaderMgr::loadShadersWater() gWaterEdgeProgram.mShaderFiles.push_back(make_pair("environment/waterV.glsl", GL_VERTEX_SHADER)); gWaterEdgeProgram.mShaderFiles.push_back(make_pair("environment/waterF.glsl", GL_FRAGMENT_SHADER)); gWaterEdgeProgram.addPermutation("WATER_EDGE", "1"); + gWaterEdgeProgram.clearPermutations(); + if (LLPipeline::sRenderTransparentWater) + { + gWaterEdgeProgram.addPermutation("TRANSPARENT_WATER", "1"); + } gWaterEdgeProgram.mShaderGroup = LLGLSLShader::SG_WATER; gWaterEdgeProgram.mShaderLevel = mShaderLevel[SHADER_WATER]; success = gWaterEdgeProgram.createShader(NULL, NULL); @@ -1067,6 +1069,11 @@ BOOL LLViewerShaderMgr::loadShadersWater() gUnderWaterProgram.mShaderFiles.push_back(make_pair("environment/underWaterF.glsl", GL_FRAGMENT_SHADER)); gUnderWaterProgram.mShaderLevel = mShaderLevel[SHADER_WATER]; gUnderWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; + gUnderWaterProgram.clearPermutations(); + if (LLPipeline::sRenderTransparentWater) + { + gUnderWaterProgram.addPermutation("TRANSPARENT_WATER", "1"); + } success = gUnderWaterProgram.createShader(NULL, NULL); llassert(success); } @@ -1925,15 +1932,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() shader->mFeatures.hasShadows = use_sun_shadow; shader->mFeatures.hasReflectionProbes = true; shader->mFeatures.hasWaterFog = true; - - if (mShaderLevel[SHADER_DEFERRED] < 1) - { - shader->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; - } - else - { //shave off some texture units for shadow maps - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1); - } + shader->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; shader->mShaderFiles.clear(); shader->mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER)); @@ -2002,15 +2001,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() shader->mFeatures.encodesNormal = true; shader->mFeatures.hasShadows = use_sun_shadow; shader->mFeatures.hasReflectionProbes = true; - - if (mShaderLevel[SHADER_DEFERRED] < 1) - { - shader->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; - } - else - { //shave off some texture units for shadow maps - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1); - } + shader->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; shader->mShaderFiles.clear(); shader->mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER)); @@ -2074,15 +2065,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() shader[i]->mFeatures.hasTransport = true; shader[i]->mFeatures.hasShadows = use_sun_shadow; shader[i]->mFeatures.hasReflectionProbes = true; - - if (mShaderLevel[SHADER_DEFERRED] < 1) - { - shader[i]->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; - } - else - { //shave off some texture units for shadow maps - shader[i]->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels - 6, 1); - } + shader[i]->mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; shader[i]->mShaderGroup = LLGLSLShader::SG_WATER; shader[i]->mShaderFiles.clear(); shader[i]->mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER)); @@ -2236,7 +2219,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightShinyProgram.mFeatures.hasGamma = true; gDeferredFullbrightShinyProgram.mFeatures.hasTransport = true; gDeferredFullbrightShinyProgram.mFeatures.hasSrgb = true; - gDeferredFullbrightShinyProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels-2; + gDeferredFullbrightShinyProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightShinyProgram.mShaderFiles.clear(); gDeferredFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyV.glsl", GL_VERTEX_SHADER)); gDeferredFullbrightShinyProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER)); diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 6cf9665e3e..590f24d359 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -1913,8 +1913,7 @@ bool LLViewerFetchedTexture::updateFetch() static LLCachedControl<bool> textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled", false); static LLCachedControl<F32> sCameraMotionThreshold(gSavedSettings,"TextureCameraMotionThreshold", 0.2); static LLCachedControl<S32> sCameraMotionBoost(gSavedSettings,"TextureCameraMotionBoost", 3); - if(textures_decode_disabled || - (gUseWireframe && mBoostLevel < LLGLTexture::BOOST_AVATAR_BAKED_SELF)) // don't fetch the surface textures in wireframe mode + if(textures_decode_disabled) // don't fetch the surface textures in wireframe mode { return false; } diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 7445475360..55a735e906 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -50,6 +50,7 @@ #include "llviewercontrol.h" #include "llviewertexture.h" #include "llviewermedia.h" +#include "llviewernetwork.h" #include "llviewerregion.h" #include "llviewerstats.h" #include "pipeline.h" @@ -155,12 +156,6 @@ void LLViewerTextureList::doPreloadImages() image->setAddressMode(LLTexUnit::TAM_WRAP); mImagePreloads.insert(image); } - image = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL, FTT_DEFAULT, MIPMAP_YES, LLViewerFetchedTexture::BOOST_UI); - if (image) - { - image->setAddressMode(LLTexUnit::TAM_WRAP); - mImagePreloads.insert(image); - } image = LLViewerTextureManager::getFetchedTextureFromFile("transparent.j2c", FTT_LOCAL_FILE, MIPMAP_YES, LLViewerFetchedTexture::BOOST_UI, LLViewerTexture::FETCHED_TEXTURE, 0, 0, IMG_TRANSPARENT); if (image) @@ -193,13 +188,31 @@ void LLViewerTextureList::doPreloadImages() static std::string get_texture_list_name() { - return gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "texture_list_" + gSavedSettings.getString("LoginLocation") + "." + gDirUtilp->getUserName() + ".xml"); + if (LLGridManager::getInstance()->isInProductionGrid()) + { + return gDirUtilp->getExpandedFilename(LL_PATH_CACHE, + "texture_list_" + gSavedSettings.getString("LoginLocation") + "." + gDirUtilp->getUserName() + ".xml"); + } + else + { + const std::string& grid_id_str = LLGridManager::getInstance()->getGridId(); + const std::string& grid_id_lower = utf8str_tolower(grid_id_str); + return gDirUtilp->getExpandedFilename(LL_PATH_CACHE, + "texture_list_" + gSavedSettings.getString("LoginLocation") + "." + gDirUtilp->getUserName() + "." + grid_id_lower + ".xml"); + } } void LLViewerTextureList::doPrefetchImages() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + LLViewerFetchedTexture* imagep = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL, FTT_DEFAULT, MIPMAP_YES, LLViewerFetchedTexture::BOOST_UI); + if (imagep) + { + imagep->setAddressMode(LLTexUnit::TAM_WRAP); + mImagePreloads.insert(imagep); + } + if (LLAppViewer::instance()->getPurgeCache()) { // cache was purged, no point diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index b921225e39..454574f7d6 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -127,7 +127,9 @@ public: S32 getNumImages() { return mImageList.size(); } + // Local UI images void doPreloadImages(); + // Network images. Needs caps and cache to work void doPrefetchImages(); void clearFetchingRequests(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 8ef65b665d..5c5a5ba0d1 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5162,7 +5162,7 @@ BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_ LLRenderTarget scratch_space; U32 color_fmt = GL_RGBA; const bool use_depth_buffer = true; - const bool use_stencil_buffer = true; + const bool use_stencil_buffer = false; if (scratch_space.allocate(image_width, image_height, color_fmt, use_depth_buffer, use_stencil_buffer)) { if (gPipeline.allocateScreenBuffer(image_width, image_height)) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index bbe6814ce1..2a06331b63 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -6464,11 +6464,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace buffer_index = -1; } - static LLCachedControl<U32> max_texture_index(gSavedSettings, "RenderMaxTextureIndex", 16); - texture_index_channels = llmin(texture_index_channels, (S32) max_texture_index); - - //NEVER use more than 16 texture index channels (workaround for prevalent driver bug) - texture_index_channels = llmin(texture_index_channels, 16); + texture_index_channels = LLGLSLShader::sIndexedTextureChannels; bool flexi = false; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2f4ab3ac45..0c27296440 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -203,7 +203,6 @@ F32 LLPipeline::RenderEdgeNormCutoff; LLVector3 LLPipeline::RenderShadowGaussian; F32 LLPipeline::RenderShadowBlurDistFactor; bool LLPipeline::RenderDeferredAtmospheric; -S32 LLPipeline::RenderReflectionDetail; F32 LLPipeline::RenderHighlightFadeTime; LLVector3 LLPipeline::RenderShadowClipPlanes; LLVector3 LLPipeline::RenderShadowOrthoClipPlanes; @@ -316,7 +315,6 @@ bool LLPipeline::sNoAlpha = false; bool LLPipeline::sUseTriStrips = true; bool LLPipeline::sUseFarClip = true; bool LLPipeline::sShadowRender = false; -bool LLPipeline::sWaterReflections = false; bool LLPipeline::sRenderGlow = false; bool LLPipeline::sReflectionRender = false; bool LLPipeline::sDistortionRender = false; @@ -570,7 +568,6 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("RenderShadowGaussian"); connectRefreshCachedSettingsSafe("RenderShadowBlurDistFactor"); connectRefreshCachedSettingsSafe("RenderDeferredAtmospheric"); - connectRefreshCachedSettingsSafe("RenderReflectionDetail"); connectRefreshCachedSettingsSafe("RenderHighlightFadeTime"); connectRefreshCachedSettingsSafe("RenderShadowClipPlanes"); connectRefreshCachedSettingsSafe("RenderShadowOrthoClipPlanes"); @@ -1072,7 +1069,6 @@ void LLPipeline::refreshCachedSettings() RenderShadowGaussian = gSavedSettings.getVector3("RenderShadowGaussian"); RenderShadowBlurDistFactor = gSavedSettings.getF32("RenderShadowBlurDistFactor"); RenderDeferredAtmospheric = gSavedSettings.getBOOL("RenderDeferredAtmospheric"); - RenderReflectionDetail = gSavedSettings.getS32("RenderReflectionDetail"); RenderHighlightFadeTime = gSavedSettings.getF32("RenderHighlightFadeTime"); RenderShadowClipPlanes = gSavedSettings.getVector3("RenderShadowClipPlanes"); RenderShadowOrthoClipPlanes = gSavedSettings.getVector3("RenderShadowOrthoClipPlanes"); @@ -1193,10 +1189,9 @@ void LLPipeline::createGLBuffers() assertInitialized(); updateRenderDeferred(); - if (LLPipeline::sWaterReflections) + if (LLPipeline::sRenderTransparentWater) { //water reflection texture U32 res = (U32) llmax(gSavedSettings.getS32("RenderWaterRefResolution"), 512); - mWaterRef.allocate(res,res,GL_RGBA,TRUE,FALSE); mWaterDis.allocate(res,res,GL_RGBA,TRUE,FALSE,LLTexUnit::TT_TEXTURE); } @@ -2427,17 +2422,6 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* pla stop_glerror(); } - if (hasRenderType(LLPipeline::RENDER_TYPE_GROUND) && - !gPipeline.canUseWindLightShaders() && - gSky.mVOGroundp.notNull() && - gSky.mVOGroundp->mDrawable.notNull() && - !LLPipeline::sWaterReflections) - { - gSky.mVOGroundp->mDrawable->setVisible(camera); - sCull->pushDrawable(gSky.mVOGroundp->mDrawable); - } - - if (hasRenderType(LLPipeline::RENDER_TYPE_WL_SKY) && gPipeline.canUseWindLightShaders() && gSky.mVOWLSkyp.notNull() && @@ -4026,7 +4010,6 @@ void render_hud_elements() LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; //LL_RECORD_BLOCK_TIME(FTM_RENDER_UI); gPipeline.disableLights(); - LLGLDisable fog(GL_FOG); LLGLSUIDefault gls_ui; //LLGLEnable stencil(GL_STENCIL_TEST); @@ -4054,9 +4037,6 @@ void render_hud_elements() } LLViewerParcelMgr::getInstance()->render(); LLViewerParcelMgr::getInstance()->renderParcelCollision(); - - // Render name tags. - LLHUDObject::renderAll(); } else if (gForceRenderLandFence) { @@ -4069,7 +4049,6 @@ void render_hud_elements() } gUIProgram.unbind(); - gGL.flush(); } void LLPipeline::renderHighlights() @@ -4562,6 +4541,11 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY); LL_PROFILE_GPU_ZONE("renderGeomDeferred"); + if (gUseWireframe) + { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } + bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion; { @@ -4668,6 +4652,11 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) gGL.setColorMask(true, false); } // Tracy ZoneScoped + + if (gUseWireframe) + { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } } void LLPipeline::renderGeomPostDeferred(LLCamera& camera) @@ -4675,6 +4664,11 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_POST_DEFERRED_POOLS); LL_PROFILE_GPU_ZONE("renderGeomPostDeferred"); + if (gUseWireframe) + { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } + U32 cur_type = 0; LLGLEnable cull(GL_CULL_FACE); @@ -4754,6 +4748,10 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) renderDebug(); } + if (gUseWireframe) + { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } } void LLPipeline::renderGeomShadow(LLCamera& camera) @@ -7549,11 +7547,6 @@ void LLPipeline::renderFinalize() assertInitialized(); - if (gUseWireframe) - { - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - LLVector2 tc1(0, 0); LLVector2 tc2((F32) mRT->screen.getWidth() * 2, (F32) mRT->screen.getHeight() * 2); @@ -8484,8 +8477,8 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); } - shader.uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); - shader.uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); + shader.uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); + shader.uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); LLEnvironment& environment = LLEnvironment::instance(); LLSettingsSky::ptr_t sky = environment.getCurrentSky(); @@ -8735,7 +8728,7 @@ void LLPipeline::renderDeferredLighting() LLEnvironment &environment = LLEnvironment::instance(); soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); - soften_shader.uniform4fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); + soften_shader.uniform3fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); if (!LLPipeline::sUnderWaterRender && LLPipeline::sRenderPBR) { @@ -9347,350 +9340,6 @@ inline float sgn(float a) return (0.0F); } -void LLPipeline::generateWaterReflection(LLCamera& camera_in) -{ -#if 0 - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - LL_PROFILE_GPU_ZONE("generateWaterReflection"); - - if (!assertInitialized() || gCubeSnapshot) - { - return; - } - - if (LLPipeline::sWaterReflections && LLDrawPoolWater::sNeedsReflectionUpdate) - { - //disable occlusion culling for reflection/refraction passes (save setting to restore later) - S32 occlude = LLPipeline::sUseOcclusion; - LLPipeline::sUseOcclusion = 0; - - bool skip_avatar_update = false; - if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson) - { - skip_avatar_update = true; - } - - LLCamera camera = camera_in; - camera.setFar(camera_in.getFar() * 0.75f); - - bool camera_is_underwater = LLViewerCamera::getInstance()->cameraUnderWater(); - - LLPipeline::sReflectionRender = true; - - gPipeline.pushRenderTypeMask(); - - glh::matrix4f saved_modelview = get_current_modelview(); - glh::matrix4f saved_projection = get_current_projection(); - glh::matrix4f mat; - -#if 1 // relies on forward rendering, which is deprecated -- TODO - make a deferred implementation of transparent/reflective water - S32 reflection_detail = RenderReflectionDetail; -#else - S32 reflection_detail = WATER_REFLECT_NONE_WATER_TRANSPARENT; -#endif - - F32 water_height = gAgent.getRegion()->getWaterHeight(); - F32 camera_height = camera_in.getOrigin().mV[VZ]; - F32 distance_to_water = (water_height < camera_height) ? (camera_height - water_height) : (water_height - camera_height); - - LLVector3 reflection_offset = LLVector3(0, 0, distance_to_water * 2.0f); - LLVector3 camera_look_at = camera_in.getAtAxis(); - LLVector3 reflection_look_at = LLVector3(camera_look_at.mV[VX], camera_look_at.mV[VY], -camera_look_at.mV[VZ]); - LLVector3 reflect_origin = camera_in.getOrigin() - reflection_offset; - LLVector3 reflect_interest_point = reflect_origin + (reflection_look_at * 5.0f); - - camera.setOriginAndLookAt(reflect_origin, LLVector3::z_axis, reflect_interest_point); - - //plane params - LLPlane plane; - LLVector3 pnorm; - - if (camera_is_underwater) - { - //camera is below water, cull above water - pnorm.setVec(0, 0, 1); - } - else - { - //camera is above water, cull below water - pnorm = LLVector3(0, 0, -1); - } - - plane.setVec(LLVector3(0, 0, water_height), pnorm); - - if (!camera_is_underwater) - { - //generate planar reflection map - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER0; - - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - - mat.set_scale(glh::vec3f(1, 1, -1)); - mat.set_translate(glh::vec3f(0,0,water_height*2.f)); - mat = saved_modelview * mat; - - - mReflectionModelView = mat; - - set_current_modelview(mat); - gGL.loadMatrix(mat.m); - - LLViewerCamera::updateFrustumPlanes(camera, FALSE, TRUE); - - glh::vec3f origin(0, 0, 0); - glh::matrix4f inv_mat = mat.inverse(); - inv_mat.mult_matrix_vec(origin); - - camera.setOrigin(origin.v); - - glCullFace(GL_FRONT); - - if (LLDrawPoolWater::sNeedsReflectionUpdate) - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - glClearColor(0,0,0,0); - mWaterRef.bindTarget(); - - gGL.setColorMask(true, true); - mWaterRef.clear(); - gGL.setColorMask(true, false); - mWaterRef.getViewport(gGLViewport); - - //initial sky pass (no user clip plane) - //mask out everything but the sky - gPipeline.pushRenderTypeMask(); - { - if (reflection_detail >= WATER_REFLECT_MINIMAL) - { - gPipeline.andRenderTypeMask( - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::END_RENDER_TYPES); - } - else - { - gPipeline.andRenderTypeMask( - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::END_RENDER_TYPES); - } - - updateCull(camera, mSky); - stateSort(camera, mSky); - renderGeom(camera, TRUE); - } - gPipeline.popRenderTypeMask(); - - if (reflection_detail >= WATER_REFLECT_NONE_WATER_TRANSPARENT) - { - gPipeline.pushRenderTypeMask(); - { - clearRenderTypeMask( - LLPipeline::RENDER_TYPE_WATER, - LLPipeline::RENDER_TYPE_VOIDWATER, - LLPipeline::RENDER_TYPE_GROUND, - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::END_RENDER_TYPES); - - if (reflection_detail > WATER_REFLECT_MINIMAL) - { //mask out selected geometry based on reflection detail - if (reflection_detail < WATER_REFLECT_EVERYTHING) - { - clearRenderTypeMask(LLPipeline::RENDER_TYPE_PARTICLES, END_RENDER_TYPES); - if (reflection_detail < WATER_REFLECT_AVATARS) - { - clearRenderTypeMask( - LLPipeline::RENDER_TYPE_AVATAR, - LLPipeline::RENDER_TYPE_CONTROL_AV, - END_RENDER_TYPES); - if (reflection_detail < WATER_REFLECT_STATIC_OBJECTS) - { - clearRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME, END_RENDER_TYPES); - } - } - } - - LLGLUserClipPlane clip_plane(plane, mReflectionModelView, saved_projection); - LLGLDisable cull(GL_CULL_FACE); - updateCull(camera, mReflectedObjects, &plane); - stateSort(camera, mReflectedObjects); - renderGeom(camera); - } - } - gPipeline.popRenderTypeMask(); - } - - mWaterRef.flush(); - } - - glCullFace(GL_BACK); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - - set_current_modelview(saved_modelview); - } - - camera.setOrigin(camera_in.getOrigin()); - //render distortion map - static bool last_update = true; - if (last_update) - { - gPipeline.pushRenderTypeMask(); - - camera.setFar(camera_in.getFar()); - clearRenderTypeMask( - LLPipeline::RENDER_TYPE_WATER, - LLPipeline::RENDER_TYPE_VOIDWATER, - LLPipeline::RENDER_TYPE_GROUND, - END_RENDER_TYPES); - - // intentionally inverted so that distortion map contents (objects under the water when we're above it) - // will properly include water fog effects - LLPipeline::sUnderWaterRender = !camera_is_underwater; - - if (LLPipeline::sUnderWaterRender) - { - clearRenderTypeMask( - LLPipeline::RENDER_TYPE_GROUND, - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_CLOUDS, - LLPipeline::RENDER_TYPE_WL_SKY, - END_RENDER_TYPES); - } - LLViewerCamera::updateFrustumPlanes(camera); - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - if (LLPipeline::sUnderWaterRender || LLDrawPoolWater::sNeedsDistortionUpdate) - { - LLPipeline::sDistortionRender = true; - - LLColor3 col = LLEnvironment::instance().getCurrentWater()->getWaterFogColor(); - glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); - - // HACK FIX -- pretend underwater camera is the world camera to fix weird visibility artifacts - // during distortion render (doesn't break main render because the camera is the same perspective - // as world camera and occlusion culling is disabled for this pass) - //LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER1; - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; - - mWaterDis.bindTarget(); - mWaterDis.getViewport(gGLViewport); - - gGL.setColorMask(true, true); - mWaterDis.clear(); - gGL.setColorMask(true, false); - - F32 water_dist = water_height; - - //clip out geometry on the same side of water as the camera w/ enough margin to not include the water geo itself, - // but not so much as to clip out parts of avatars that should be seen under the water in the distortion map - LLPlane plane; - - if (camera_is_underwater) - { - //nudge clip plane below water to avoid visible holes in objects intersecting water surface - water_dist /= LLPipeline::sDistortionWaterClipPlaneMargin; - //camera is below water, clip plane points up - pnorm.setVec(0, 0, -1); - } - else - { - //nudge clip plane above water to avoid visible holes in objects intersecting water surface - water_dist *= LLPipeline::sDistortionWaterClipPlaneMargin; - //camera is above water, clip plane points down - pnorm = LLVector3(0, 0, 1); - } - - plane.setVec(LLVector3(0, 0, water_dist), pnorm); - - LLGLUserClipPlane clip_plane(plane, saved_modelview, saved_projection); - - gGL.setColorMask(true, true); - mWaterDis.clear(); - gGL.setColorMask(true, false); - -#if 0 // DEPRECATED - requires forward rendering, TODO - make a deferred implementation - if (reflection_detail >= WATER_REFLECT_NONE_WATER_TRANSPARENT) - { - updateCull(camera, mRefractedObjects, &plane); - stateSort(camera, mRefractedObjects); - renderGeom(camera); - } -#endif - - - gUIProgram.bind(); - - LLWorld::getInstance()->renderPropertyLines(); - - gUIProgram.unbind(); - - mWaterDis.flush(); - } - - LLPipeline::sDistortionRender = false; - - gPipeline.popRenderTypeMask(); - } - last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate; - - gPipeline.popRenderTypeMask(); - - LLPipeline::sUnderWaterRender = false; - LLPipeline::sReflectionRender = false; - - LLDrawPoolWater::sNeedsReflectionUpdate = FALSE; - LLDrawPoolWater::sNeedsDistortionUpdate = FALSE; - - if (!LLRenderTarget::sUseFBO) - { - glClear(GL_DEPTH_BUFFER_BIT); - } - glClearColor(0.f, 0.f, 0.f, 0.f); - gViewerWindow->setup3DViewport(); - - LLGLState::checkStates(); - - if (!skip_avatar_update) - { - gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode()); - } - - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; - - // restore occlusion culling - LLPipeline::sUseOcclusion = occlude; - } - else - { - // Initial sky pass is still needed even if water reflection is not rendering - bool camera_is_underwater = LLViewerCamera::getInstance()->cameraUnderWater(); - if (!camera_is_underwater) - { - gPipeline.pushRenderTypeMask(); - { - gPipeline.andRenderTypeMask( - LLPipeline::RENDER_TYPE_SKY, - LLPipeline::RENDER_TYPE_WL_SKY, - LLPipeline::END_RENDER_TYPES); - - LLCamera camera = camera_in; - camera.setFar(camera_in.getFar() * 0.75f); - - updateCull(camera, mSky); - stateSort(camera, mSky); - renderGeom(camera, TRUE); - } - gPipeline.popRenderTypeMask(); - } - } -#endif -} - glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up) { glh::matrix4f ret; diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 2c9b264fe6..59858cfcfc 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -309,7 +309,6 @@ public: void renderDeferredLighting(); void postDeferredGammaCorrect(LLRenderTarget* screen_target); - void generateWaterReflection(LLCamera& camera); void generateSunShadow(LLCamera& camera); LLRenderTarget* getSunShadowTarget(U32 i); LLRenderTarget* getSpotShadowTarget(U32 i); @@ -634,7 +633,6 @@ public: static bool sUseTriStrips; static bool sUseFarClip; static bool sShadowRender; - static bool sWaterReflections; static bool sDynamicLOD; static bool sPickAvatar; static bool sReflectionRender; @@ -1015,7 +1013,6 @@ public: static LLVector3 RenderShadowGaussian; static F32 RenderShadowBlurDistFactor; static bool RenderDeferredAtmospheric; - static S32 RenderReflectionDetail; static F32 RenderHighlightFadeTime; static LLVector3 RenderShadowClipPlanes; static LLVector3 RenderShadowOrthoClipPlanes; diff --git a/indra/newview/skins/default/xui/en/floater_material_editor.xml b/indra/newview/skins/default/xui/en/floater_material_editor.xml index 3314d49ac3..434123faf0 100644 --- a/indra/newview/skins/default/xui/en/floater_material_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_material_editor.xml @@ -15,6 +15,7 @@ <string name="upload_fee_string">L$[FEE] upload fee</string> <string name="material_selection_title">Material selection</string> <string name="material_selection_text">Select material:</string> + <string name="material_override_title">Material override</string> <scroll_container name="materials_scroll" diff --git a/indra/newview/skins/default/xui/en/floater_perms_default.xml b/indra/newview/skins/default/xui/en/floater_perms_default.xml index 49dc719a24..9ca61671e1 100644 --- a/indra/newview/skins/default/xui/en/floater_perms_default.xml +++ b/indra/newview/skins/default/xui/en/floater_perms_default.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <floater legacy_header_height="18" - height="250" + height="266" layout="topleft" name="perms default" help_topic="perms_default" @@ -10,7 +10,7 @@ width="700"> <panel follows="left|top|right|bottom" - height="200" + height="216" label="Default Permissions" layout="topleft" left="10" @@ -549,6 +549,70 @@ left_pad="0" top_delta="0" width="100" /> + <text + name="label_14" + type="string" + length="1" + follows="left|top" + height="16" + layout="topleft" + left="0" + tool_tip="Set default permissions for when GLTF Materials are created" + width="100"> + Materials + </text> + <icon + follows="left|top" + height="16" + image_name="Inv_Material" + layout="topleft" + left_pad="2" + width="18"/> + <check_box + control_name="MaterialsNextOwnerCopy" + height="16" + layout="topleft" + name="env_material_c" + left_pad="45" + top_delta="0" + width="100"> + <check_box.commit_callback + function="PermsDefault.Copy" + parameter="Materials" /> + </check_box> + <check_box + control_name="MaterialsNextOwnerModify" + height="16" + layout="topleft" + name="env_materials_m" + left_pad="0" + top_delta="0" + width="100" /> + <check_box + enabled_control="MaterialsNextOwnerCopy" + control_name="MaterialsNextOwnerTransfer" + height="16" + layout="topleft" + name="env_materials_t" + left_pad="0" + top_delta="0" + width="100" /> + <check_box + control_name="MaterialsShareWithGroup" + height="16" + layout="topleft" + name="env_materials_s" + left_pad="0" + top_delta="0" + width="120" /> + <check_box + control_name="MaterialsEveryoneCopy" + height="16" + layout="topleft" + name="env_materials_e" + left_pad="0" + top_delta="0" + width="100" /> </panel> <button height="20" diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index 6ff27ad50b..4a08cc5285 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -550,57 +550,6 @@ top_delta="16" width="300" /> - <text - type="string" - length="1" - follows="left|top" - height="16" - layout="topleft" - name="ReflectionsText" - text_readonly_color="LabelDisabledColor" - top_delta="16" - left="420" - width="128"> - Water Reflections: - </text> - <combo_box - control_name="RenderReflectionDetail" - height="18" - layout="topleft" - left_delta="170" - top_delta="0" - name="Reflections" - width="150"> - <combo_box.item - label="None; opaque" - name="0" - value="-2"/> - <combo_box.item - label="None; transparent" - name="0" - value="-1"/> - <combo_box.item - label="Minimal" - name="0" - value="0"/> - <combo_box.item - label="Terrain and trees" - name="1" - value="1"/> - <combo_box.item - label="All static objects" - name="2" - value="2"/> - <combo_box.item - label="All avatars and objects" - name="3" - value="3"/> - <combo_box.item - label="Everything" - name="4" - value="4"/> - </combo_box> - <slider control_name="WLSkyDetail" decimal_digits="0" diff --git a/indra/newview/skins/default/xui/en/menu_object.xml b/indra/newview/skins/default/xui/en/menu_object.xml index ce34508303..6d37c15815 100644 --- a/indra/newview/skins/default/xui/en/menu_object.xml +++ b/indra/newview/skins/default/xui/en/menu_object.xml @@ -22,6 +22,22 @@ function="EnableEdit"/> </menu_item_call> <menu_item_call + label="Edit PBR Material" + name="EditGLTFMaterial"> + <menu_item_call.on_click + function="Object.EditGLTFMaterial" /> + <menu_item_call.on_enable + function="Object.EnableEditGLTFMaterial"/> + </menu_item_call> + <menu_item_call + label="Save material to inventory" + name="SaveGLTFMaterial"> + <menu_item_call.on_click + function="Object.SaveGLTFMaterial" /> + <menu_item_call.on_enable + function="Object.EnableSaveGLTFMaterial"/> + </menu_item_call> + <menu_item_call label="Build" name="Build"> <menu_item_call.on_click |