diff options
author | Graham Linden <graham@lindenlab.com> | 2018-06-13 00:51:39 +0100 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2018-06-13 00:51:39 +0100 |
commit | 34865c4bb5cd12219606f44748159fe7cbeea264 (patch) | |
tree | 909e247267325a55a468635ecfc7957cefc23868 /indra | |
parent | e2adba65debbd1550a9eaead2a00e1426e8855a8 (diff) |
Mods to hook up water settings to water normals for rendering with support for current to next blending.
Modify LLSettingsFoo::buildDefaultFoo to use a static and avoid re-validation of default sky/water/daycycle settings.
Remove all references to gSun/MoonTextureId globals (they should come from sky settings now).
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llinventory/llsettingsbase.h | 2 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.cpp | 1 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.cpp | 8 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.h | 2 | ||||
-rw-r--r-- | indra/llinventory/llsettingswater.cpp | 16 | ||||
-rw-r--r-- | indra/llinventory/llsettingswater.h | 18 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.cpp | 1 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.h | 1 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/waterF.glsl | 27 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/environment/waterF.glsl | 26 | ||||
-rw-r--r-- | indra/newview/llappviewer.h | 2 | ||||
-rw-r--r-- | indra/newview/lldrawpoolwater.cpp | 105 | ||||
-rw-r--r-- | indra/newview/lldrawpoolwater.h | 11 | ||||
-rw-r--r-- | indra/newview/llsettingsvo.cpp | 76 | ||||
-rw-r--r-- | indra/newview/llstartup.cpp | 22 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llvosky.cpp | 10 | ||||
-rw-r--r-- | indra/newview/llvosky.h | 6 |
18 files changed, 218 insertions, 118 deletions
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index f0d104ff53..f2fa78e41f 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -112,7 +112,7 @@ public: } - inline void replaceSettings(LLSD settings) + virtual void replaceSettings(LLSD settings) { mSettings = settings; mBlendedFactor = 0.0; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 009d7b06f2..51bc6b0e54 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -37,6 +37,7 @@ #include "llsettingswater.h" #include "llframetimer.h" + //========================================================================= namespace { diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index db574f2eec..c25f9a5b2c 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -382,8 +382,16 @@ LLSettingsSky::LLSettingsSky(): { } +void LLSettingsSky::replaceSettings(LLSD settings) +{ + LLSettingsBase::replaceSettings(settings); + +} + void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) { + llassert(getSettingsType() == end->getSettingsType()); + LLSettingsSky::ptr_t other = PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(end); LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index a557080744..e6783f6694 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -103,6 +103,8 @@ public: // Settings status virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE; + virtual void replaceSettings(LLSD settings) SETTINGS_OVERRIDE; + static LLSD defaults(); F32 getPlanetRadius() const; diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index ba147baed7..16281e23cc 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -47,6 +47,7 @@ const std::string LLSettingsWater::SETTING_FOG_DENSITY("water_fog_density"); const std::string LLSettingsWater::SETTING_FOG_MOD("underwater_fog_mod"); const std::string LLSettingsWater::SETTING_FRESNEL_OFFSET("fresnel_offset"); const std::string LLSettingsWater::SETTING_FRESNEL_SCALE("fresnel_scale"); +const std::string LLSettingsWater::SETTING_TRANSPARENT_TEXTURE("transparent_texture"); const std::string LLSettingsWater::SETTING_NORMAL_MAP("normal_map"); const std::string LLSettingsWater::SETTING_NORMAL_SCALE("normal_scale"); const std::string LLSettingsWater::SETTING_SCALE_ABOVE("scale_above"); @@ -69,6 +70,8 @@ const std::string LLSettingsWater::SETTING_LEGACY_WAVE2_DIR("wave2Dir"); // *LAPRAS* Change when Agni static const LLUUID DEFAULT_ASSET_ID("ce4cfe94-700a-292c-7c22-a2d9201bd661"); +static const LLUUID DEFAULT_TRANSPARENT_WATER_TEXTURE("2bfd3884-7e27-69b9-ba3a-3e673f680004"); +static const LLUUID DEFAULT_OPAQUE_WATER_TEXTURE("43c32285-d658-1793-c123-bf86315de055"); //========================================================================= LLSettingsWater::LLSettingsWater(const LLSD &data) : @@ -95,7 +98,8 @@ LLSD LLSettingsWater::defaults() dfltsetting[SETTING_FOG_MOD] = LLSD::Real(0.25f); dfltsetting[SETTING_FRESNEL_OFFSET] = LLSD::Real(0.5f); dfltsetting[SETTING_FRESNEL_SCALE] = LLSD::Real(0.3999); - dfltsetting[SETTING_NORMAL_MAP] = LLSD::UUID(DEFAULT_WATER_NORMAL); + dfltsetting[SETTING_TRANSPARENT_TEXTURE] = GetDefaultTransparentTextureAssetId(); + dfltsetting[SETTING_NORMAL_MAP] = GetDefaultWaterNormalAssetId(); dfltsetting[SETTING_NORMAL_SCALE] = LLVector3(2.0f, 2.0f, 2.0f).getValue(); dfltsetting[SETTING_SCALE_ABOVE] = LLSD::Real(0.0299f); dfltsetting[SETTING_SCALE_BELOW] = LLSD::Real(0.2000f); @@ -171,6 +175,7 @@ void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf) replaceSettings(blenddata); setBlendFactor(blendf); mNextNormalMapID = other->getNormalMapID(); + mNextTransparentTextureID = other->getTransparentTextureID(); } LLSettingsWater::validation_list_t LLSettingsWater::getValidationList() const @@ -234,3 +239,12 @@ LLUUID LLSettingsWater::GetDefaultWaterNormalAssetId() return DEFAULT_WATER_NORMAL; } +LLUUID LLSettingsWater::GetDefaultTransparentTextureAssetId() +{ + return DEFAULT_TRANSPARENT_WATER_TEXTURE; +} + +LLUUID LLSettingsWater::GetDefaultOpaqueTextureAssetId() +{ + return DEFAULT_OPAQUE_WATER_TEXTURE; +} diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index 19761f6f07..9d006d492d 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -39,6 +39,7 @@ public: static const std::string SETTING_FOG_MOD; static const std::string SETTING_FRESNEL_OFFSET; static const std::string SETTING_FRESNEL_SCALE; + static const std::string SETTING_TRANSPARENT_TEXTURE; static const std::string SETTING_NORMAL_MAP; static const std::string SETTING_NORMAL_SCALE; static const std::string SETTING_SCALE_ABOVE; @@ -124,6 +125,16 @@ public: setValue(SETTING_FRESNEL_SCALE, val); } + LLUUID getTransparentTextureID() const + { + return mSettings[SETTING_TRANSPARENT_TEXTURE].asUUID(); + } + + void setTransparentTextureID(LLUUID val) + { + setValue(SETTING_TRANSPARENT_TEXTURE, val); + } + LLUUID getNormalMapID() const { return mSettings[SETTING_NORMAL_MAP].asUUID(); @@ -203,6 +214,10 @@ public: return mNextNormalMapID; } + LLUUID getNextTransparentTextureID() const + { + return mNextTransparentTextureID; + } virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE; static validation_list_t validationList(); @@ -213,6 +228,8 @@ public: static LLUUID GetDefaultAssetId(); static LLUUID GetDefaultWaterNormalAssetId(); + static LLUUID GetDefaultTransparentTextureAssetId(); + static LLUUID GetDefaultOpaqueTextureAssetId(); protected: static const std::string SETTING_LEGACY_BLUR_MULTIPILER; @@ -234,6 +251,7 @@ protected: F32 mWaterFogKS; private: + LLUUID mNextTransparentTextureID; LLUUID mNextNormalMapID; }; diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 037786ec49..0e79430468 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1147,6 +1147,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("altDiffuseMap"); mReservedUniforms.push_back("specularMap"); mReservedUniforms.push_back("bumpMap"); + mReservedUniforms.push_back("bumpMap2"); mReservedUniforms.push_back("environmentMap"); mReservedUniforms.push_back("cloud_noise_texture"); mReservedUniforms.push_back("cloud_noise_texture_next"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 53d59dbbf8..342f5d5507 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -77,6 +77,7 @@ public: ALTERNATE_DIFFUSE_MAP, SPECULAR_MAP, BUMP_MAP, + BUMP_MAP2, ENVIRONMENT_MAP, CLOUD_NOISE_MAP, CLOUD_NOISE_MAP_NEXT, diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index b321eb508b..98c5030a04 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -37,6 +37,8 @@ vec3 scaleSoftClip(vec3 inColor); vec3 atmosTransport(vec3 inColor); uniform sampler2D bumpMap; +uniform sampler2D bumpMap2; +uniform float blend_factor; uniform sampler2D screenTex; uniform sampler2D refTex; uniform sampler2DRectShadow shadowMap0; @@ -72,6 +74,15 @@ VARYING vec4 vary_position; vec3 srgb_to_linear(vec3 cs); vec2 encode_normal(vec3 n); +vec3 BlendNormal(vec3 bump1, vec3 bump2) +{ + //vec3 normal = bump1.xyz * vec3( 2.0, 2.0, 2.0) - vec3(1.0, 1.0, 0.0); + //vec3 normal2 = bump2.xyz * vec3(-2.0, -2.0, 2.0) + vec3(1.0, 1.0, -1.0); + //vec3 n = normalize(normal * dot(normal, normal2) - (normal2 * normal.z)); + vec3 n = normalize(mix(bump1, bump2, blend_factor)); + return n; +} + void main() { vec4 color; @@ -81,9 +92,19 @@ void main() vec3 viewVec = normalize(view.xyz); //get wave 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; + vec3 wave1_a = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2_a = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; + vec3 wave3_a = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; + + + vec3 wave1_b = texture2D(bumpMap2, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2_b = texture2D(bumpMap2, littleWave.xy).xyz*2.0-1.0; + vec3 wave3_b = texture2D(bumpMap2, littleWave.zw).xyz*2.0-1.0; + + vec3 wave1 = BlendNormal(wave1_a, wave1_b); + vec3 wave2 = BlendNormal(wave2_a, wave2_b); + vec3 wave3 = BlendNormal(wave3_a, wave3_b); + //get base fresnel components vec3 df = vec3( diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl index 79bffab745..37f109c637 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -33,6 +33,8 @@ vec3 scaleSoftClip(vec3 inColor); vec3 atmosTransport(vec3 inColor); uniform sampler2D bumpMap; +uniform sampler2D bumpMap2; +uniform float blend_factor; uniform sampler2D screenTex; uniform sampler2D refTex; @@ -55,6 +57,15 @@ VARYING vec4 refCoord; VARYING vec4 littleWave; VARYING vec4 view; +vec3 BlendNormal(vec3 bump1, vec3 bump2) +{ + //vec3 normal = bump1.xyz * vec3( 2.0, 2.0, 2.0) - vec3(1.0, 1.0, 0.0); + //vec3 normal2 = bump2.xyz * vec3(-2.0, -2.0, 2.0) + vec3(1.0, 1.0, -1.0); + //vec3 n = normalize(normal * dot(normal, normal2) - (normal2 * normal.z)); + vec3 n = normalize(mix(bump1, bump2, blend_factor)); + return n; +} + void main() { vec4 color; @@ -65,9 +76,18 @@ void main() vec3 viewVec = normalize(view.xyz); //get wave 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; + vec3 wave1_a = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2_a = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; + vec3 wave3_a = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; + + vec3 wave1_b = texture2D(bumpMap2, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2_b = texture2D(bumpMap2, littleWave.xy).xyz*2.0-1.0; + vec3 wave3_b = texture2D(bumpMap2, littleWave.zw).xyz*2.0-1.0; + + vec3 wave1 = BlendNormal(wave1_a, wave1_b); + vec3 wave2 = BlendNormal(wave2_a, wave2_b); + vec3 wave3 = BlendNormal(wave3_a, wave3_b); + //get base fresnel components vec3 df = vec3( diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index e607b4a994..51d2d98485 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -390,8 +390,6 @@ extern LLVector3 gRelativeWindVec; extern U32 gPacketsIn; extern BOOL gPrintMessagesThisFrame; -extern LLUUID gSunTextureID; -extern LLUUID gMoonTextureID; extern LLUUID gBlackSquareID; extern BOOL gRandomizeFramerate; diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 1ecf0ab8f9..6e3145ee06 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -50,9 +50,6 @@ #include "llsettingssky.h" #include "llsettingswater.h" -const LLUUID TRANSPARENT_WATER_TEXTURE("2bfd3884-7e27-69b9-ba3a-3e673f680004"); -const LLUUID OPAQUE_WATER_TEXTURE("43c32285-d658-1793-c123-bf86315de055"); - static float sTime; BOOL deferred_render = FALSE; @@ -60,33 +57,51 @@ BOOL deferred_render = FALSE; BOOL LLDrawPoolWater::sSkipScreenCopy = FALSE; BOOL LLDrawPoolWater::sNeedsReflectionUpdate = TRUE; BOOL LLDrawPoolWater::sNeedsDistortionUpdate = TRUE; -//LLColor4 LLDrawPoolWater::sWaterFogColor = LLColor4(0.2f, 0.5f, 0.5f, 0.f); F32 LLDrawPoolWater::sWaterFogEnd = 0.f; -//LLVector3 LLDrawPoolWater::sLightDir; - -LLDrawPoolWater::LLDrawPoolWater() : - LLFacePool(POOL_WATER) +LLDrawPoolWater::LLDrawPoolWater() : LLFacePool(POOL_WATER) { - mWaterImagep = LLViewerTextureManager::getFetchedTexture(TRANSPARENT_WATER_TEXTURE); - llassert(mWaterImagep); - mWaterImagep->setNoDelete(); - mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE); - llassert(mOpaqueWaterImagep); - mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL); - mWaterNormp->setNoDelete(); - - restoreGL(); } LLDrawPoolWater::~LLDrawPoolWater() { } +void LLDrawPoolWater::setTransparentTextures(const LLUUID& transparentTextureId, const LLUUID& nextTransparentTextureId) +{ + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + mWaterImagep[0] = LLViewerTextureManager::getFetchedTexture(!transparentTextureId.isNull() ? transparentTextureId : pwater->GetDefaultTransparentTextureAssetId()); + mWaterImagep[1] = LLViewerTextureManager::getFetchedTexture(!nextTransparentTextureId.isNull() ? nextTransparentTextureId : (!transparentTextureId.isNull() ? transparentTextureId : pwater->GetDefaultTransparentTextureAssetId())); + mWaterImagep[0]->addTextureStats(1024.f*1024.f); + mWaterImagep[1]->addTextureStats(1024.f*1024.f); +} + +void LLDrawPoolWater::setOpaqueTexture() +{ + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(pwater->GetDefaultOpaqueTextureAssetId()); + mOpaqueWaterImagep->addTextureStats(1024.f*1024.f); +} + +void LLDrawPoolWater::setNormalMaps(const LLUUID& normalMapId, const LLUUID& nextNormalMapId) +{ + LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + mWaterNormp[0] = LLViewerTextureManager::getFetchedTexture(!normalMapId.isNull() ? normalMapId : pwater->GetDefaultWaterNormalAssetId()); + mWaterNormp[1] = LLViewerTextureManager::getFetchedTexture(!nextNormalMapId.isNull() ? nextNormalMapId : (!normalMapId.isNull() ? normalMapId : pwater->GetDefaultWaterNormalAssetId())); + mWaterNormp[0]->addTextureStats(1024.f*1024.f); + mWaterNormp[1]->addTextureStats(1024.f*1024.f); +} + //static void LLDrawPoolWater::restoreGL() { - + /*LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); + if (pwater) + { + setTransparentTextures(pwater->getTransparentTextureID(), pwater->getNextTransparentTextureID()); + setOpaqueTexture(pwater->GetDefaultOpaqueTextureAssetId()); + setNormalMaps(pwater->getNormalMapID(), pwater->getNextNormalMapID()); + }*/ } LLDrawPool *LLDrawPoolWater::instancePool() @@ -98,12 +113,7 @@ LLDrawPool *LLDrawPoolWater::instancePool() void LLDrawPoolWater::prerender() { - mVertexShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ? - LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0; - - // got rid of modulation by light color since it got a little too - // green at sunset and sl-57047 (underwater turns black at 8:00) - + mVertexShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ? LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0; } S32 LLDrawPoolWater::getNumPasses() @@ -194,10 +204,13 @@ void LLDrawPoolWater::render(S32 pass) LLGLDisable cullFace(GL_CULL_FACE); // Set up second pass first - mWaterImagep->addTextureStats(1024.f*1024.f); gGL.getTexUnit(1)->activate(); gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->bind(mWaterImagep) ; + gGL.getTexUnit(1)->bind(mWaterImagep[0]) ; + + gGL.getTexUnit(2)->activate(); + gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(2)->bind(mWaterImagep[1]) ; LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); F32 up_dot = camera_up * LLVector3::z_axis; @@ -254,6 +267,14 @@ void LLDrawPoolWater::render(S32 pass) gGL.getTexUnit(1)->activate(); gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->disable(); + + glDisable(GL_TEXTURE_GEN_S); //texture unit 1 + glDisable(GL_TEXTURE_GEN_T); //texture unit 1 + + gGL.getTexUnit(1)->activate(); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->disable(); + glDisable(GL_TEXTURE_GEN_S); //texture unit 1 glDisable(GL_TEXTURE_GEN_T); //texture unit 1 @@ -353,8 +374,6 @@ void LLDrawPoolWater::renderOpaqueLegacyWater() gPipeline.disableLights(); - mOpaqueWaterImagep->addTextureStats(1024.f*1024.f); - // Activate the texture binding and bind one // texture since all images will have the same texture gGL.getTexUnit(0)->activate(); @@ -568,23 +587,23 @@ void LLDrawPoolWater::shade() //bind normal map S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP); - // change mWaterNormp if needed - if (mWaterNormp->getID() != pwater->getNormalMapID()) - { - mWaterNormp = LLViewerTextureManager::getFetchedTexture(pwater->getNormalMapID()); - } + if (mWaterNormp[0] && mWaterNormp[1]) + { + gGL.getTexUnit(bumpTex)->bind(mWaterNormp[0]) ; + gGL.getTexUnit(bumpTex + 1)->bind(mWaterNormp[1]) ; - mWaterNormp->addTextureStats(1024.f*1024.f); - gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ; - if (gSavedSettings.getBOOL("RenderWaterMipNormal")) - { - mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - } - else - { - mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT); + if (gSavedSettings.getBOOL("RenderWaterMipNormal")) + { + mWaterNormp[0]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + mWaterNormp[1]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + } + else + { + mWaterNormp[0]->setFilteringOption(LLTexUnit::TFO_POINT); + mWaterNormp[1]->setFilteringOption(LLTexUnit::TFO_POINT); + } } - + S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX); if (screentex > -1) diff --git a/indra/newview/lldrawpoolwater.h b/indra/newview/lldrawpoolwater.h index 5df84bc8f0..3c1587885e 100644 --- a/indra/newview/lldrawpoolwater.h +++ b/indra/newview/lldrawpoolwater.h @@ -37,9 +37,10 @@ class LLWaterSurface; class LLDrawPoolWater: public LLFacePool { protected: - LLPointer<LLViewerTexture> mWaterImagep; - LLPointer<LLViewerTexture> mOpaqueWaterImagep; - LLPointer<LLViewerTexture> mWaterNormp; + LLPointer<LLViewerTexture> mWaterImagep[2]; + LLPointer<LLViewerTexture> mWaterNormp[2]; + + LLPointer<LLViewerTexture> mOpaqueWaterImagep; public: static BOOL sSkipScreenCopy; @@ -81,6 +82,10 @@ public: void renderReflection(LLFace* face); void shade(); + void setTransparentTextures(const LLUUID& transparentTextureId, const LLUUID& nextTransparentTextureId); + void setOpaqueTexture(); + void setNormalMaps(const LLUUID& normalMapId, const LLUUID& nextNormalMapId); + protected: void renderOpaqueLegacyWater(); }; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 2ffb1c1bce..deaaffb1f5 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -57,6 +57,7 @@ #include "llinventorymodel.h" #include "llassetstorage.h" #include "llvfile.h" +#include "lldrawpoolwater.h" #include <boost/algorithm/string/replace.hpp> @@ -415,18 +416,24 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPresetFile(const std::strin LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky() { - LLSD settings = LLSettingsSky::defaults(); - settings[SETTING_NAME] = std::string("_default_"); + static LLSD default_settings; - LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); - LLSD results = LLSettingsBase::settingValidation(settings, validations); - if (!results["success"].asBoolean()) + if (!default_settings.size()) { - LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; - LLSettingsSky::ptr_t(); + default_settings = LLSettingsSky::defaults(); + + default_settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList(); + LLSD results = LLSettingsBase::settingValidation(default_settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL; + LLSettingsSky::ptr_t(); + } } - LLSettingsSky::ptr_t skyp = std::make_shared<LLSettingsVOSky>(settings); + LLSettingsSky::ptr_t skyp = std::make_shared<LLSettingsVOSky>(default_settings); return skyp; } @@ -662,18 +669,24 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPresetFile(const std::s LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater() { - LLSD settings = LLSettingsWater::defaults(); - settings[SETTING_NAME] = std::string("_default_"); + static LLSD default_settings; - LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); - LLSD results = LLSettingsWater::settingValidation(settings, validations); - if (!results["success"].asBoolean()) + if (!default_settings.size()) { - LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; - return LLSettingsWater::ptr_t(); + default_settings = LLSettingsWater::defaults(); + + default_settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList(); + LLSD results = LLSettingsWater::settingValidation(default_settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Water setting validation failed!: " << results << LL_ENDL; + return LLSettingsWater::ptr_t(); + } } - LLSettingsWater::ptr_t waterp = std::make_shared<LLSettingsVOWater>(settings); + LLSettingsWater::ptr_t waterp = std::make_shared<LLSettingsVOWater>(default_settings); return waterp; } @@ -726,6 +739,9 @@ void LLSettingsVOWater::applySpecial(void *ptarget) shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, getWaterPlane().mV); shader->uniform1f(LLShaderMgr::WATER_FOGKS, getWaterFogKS()); + F32 blend_factor = LLEnvironment::instance().getCurrentWater()->getBlendFactor(); + shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); + LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm(); shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV); shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV); @@ -768,6 +784,13 @@ void LLSettingsVOWater::updateSettings() mWaterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP); } + + LLDrawPoolWater* pwaterpool = (LLDrawPoolWater*)gPipeline.getPool(LLDrawPool::POOL_WATER); + if (pwaterpool) + { + pwaterpool->setTransparentTextures(getTransparentTextureID(), getNextTransparentTextureID()); + pwaterpool->setNormalMaps(getNormalMapID(), getNextNormalMapID()); + } } LLSettingsWater::parammapping_t LLSettingsVOWater::getParameterMap() const @@ -966,18 +989,23 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID ®io LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle() { - LLSD settings = LLSettingsDay::defaults(); - settings[SETTING_NAME] = std::string("_default_"); + static LLSD default_settings; - LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); - LLSD results = LLSettingsDay::settingValidation(settings, validations); - if (!results["success"].asBoolean()) + if (!default_settings.size()) { - LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; - LLSettingsDay::ptr_t(); + default_settings = LLSettingsDay::defaults(); + default_settings[SETTING_NAME] = std::string("_default_"); + + LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList(); + LLSD results = LLSettingsDay::settingValidation(default_settings, validations); + if (!results["success"].asBoolean()) + { + LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL; + LLSettingsDay::ptr_t(); + } } - LLSettingsDay::ptr_t dayp = std::make_shared<LLSettingsVODay>(settings); + LLSettingsDay::ptr_t dayp = std::make_shared<LLSettingsVODay>(default_settings); dayp->initialize(); return dayp; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 7430a2578f..b190635fe0 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -3499,28 +3499,6 @@ bool process_login_success_response() } } -// LAPRAS -#if 0 - LLSD global_textures = response["global-textures"][0]; - if(global_textures.size()) - { - // Extract sun and moon texture IDs. These are used - // in the LLVOSky constructor, but I can't figure out - // how to pass them in. JC - LLUUID id = global_textures["sun_texture_id"]; - if(id.notNull()) - { - gSunTextureID = id; - } - - id = global_textures["moon_texture_id"]; - if(id.notNull()) - { - gMoonTextureID = id; - } - } -#endif - // set the location of the Agent Appearance service, from which we can request // avatar baked textures if they are supported by the current region std::string agent_appearance_url = response["agent_appearance_service"]; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index ebbf331d30..269df35773 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1051,6 +1051,7 @@ BOOL LLViewerShaderMgr::loadShadersWater() gWaterProgram.mShaderFiles.clear(); gWaterProgram.mShaderFiles.push_back(make_pair("environment/waterV.glsl", GL_VERTEX_SHADER_ARB)); gWaterProgram.mShaderFiles.push_back(make_pair("environment/waterF.glsl", GL_FRAGMENT_SHADER_ARB)); + gWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; gWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_WATER]; success = gWaterProgram.createShader(NULL, NULL); } @@ -1852,6 +1853,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; + gDeferredWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; success = gDeferredWaterProgram.createShader(NULL, NULL); } diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index e8ca286074..c73b5041c0 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -74,11 +74,6 @@ static const LLVector2 TEX11 = LLVector2(1.f, 1.f); static const F32 LIGHT_DIRECTION_THRESHOLD = (F32) cosf(DEG_TO_RAD * 1.f); static const F32 COLOR_CHANGE_THRESHOLD = 0.01f; -// LAPRAS -// Exported globals -//LLUUID gSunTextureID = IMG_SUN; -//LLUUID gMoonTextureID = IMG_MOON; - /*************************************** SkyTex ***************************************/ @@ -388,11 +383,6 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mSun.setIntensity(SUN_INTENSITY); mMoon.setIntensity(0.1f * SUN_INTENSITY); - //mSunTexturep = LLViewerTextureManager::getFetchedTexture(gSunTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); - //mSunTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - //mMoonTexturep = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); - //mMoonTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - mBloomTexturep = LLViewerTextureManager::getFetchedTexture(IMG_BLOOM1); mBloomTexturep->setNoDelete() ; mBloomTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index d7f7700dd0..5294addcec 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -42,12 +42,6 @@ const F32 HEAVENLY_BODY_DIST = HORIZON_DIST - 10.f; const F32 HEAVENLY_BODY_FACTOR = 0.1f; const F32 HEAVENLY_BODY_SCALE = HEAVENLY_BODY_DIST * HEAVENLY_BODY_FACTOR; -// HACK: Allow server to change sun and moon IDs. -// I can't figure out how to pass the appropriate -// information into the LLVOSky constructor. JC -//extern LLUUID gSunTextureID; -//extern LLUUID gMoonTextureID; - class LLFace; class LLHaze; |