Skip to content

Commit

Permalink
Merge branch 'release/2024.12-ForeverFPS' into geenz/negative-fresnel…
Browse files Browse the repository at this point in the history
…-fix
  • Loading branch information
Geenz committed Feb 8, 2025
2 parents 222a388 + 3a251b1 commit 2a2add7
Show file tree
Hide file tree
Showing 35 changed files with 559 additions and 74 deletions.
1 change: 1 addition & 0 deletions indra/llrender/llfontgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ F32 LLFontGL::sVertDPI = 96.f;
F32 LLFontGL::sHorizDPI = 96.f;
F32 LLFontGL::sScaleX = 1.f;
F32 LLFontGL::sScaleY = 1.f;
S32 LLFontGL::sResolutionGeneration = 0;
bool LLFontGL::sDisplayFont = true ;
std::string LLFontGL::sAppDir;

Expand Down
1 change: 1 addition & 0 deletions indra/llrender/llfontgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class LLFontGL
static F32 sHorizDPI;
static F32 sScaleX;
static F32 sScaleY;
static S32 sResolutionGeneration;
static bool sDisplayFont ;
static std::string sAppDir; // For loading fonts

Expand Down
4 changes: 3 additions & 1 deletion indra/llrender/llfontvertexbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ S32 LLFontVertexBuffer::render(
|| mLastScaleY != LLFontGL::sScaleY
|| mLastVertDPI != LLFontGL::sVertDPI
|| mLastHorizDPI != LLFontGL::sHorizDPI
|| mLastOrigin != LLFontGL::sCurOrigin)
|| mLastOrigin != LLFontGL::sCurOrigin
|| mLastResGeneration != LLFontGL::sResolutionGeneration)
{
genBuffers(fontp, text, begin_offset, x, y, color, halign, valign,
style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color);
Expand Down Expand Up @@ -201,6 +202,7 @@ void LLFontVertexBuffer::genBuffers(
mLastVertDPI = LLFontGL::sVertDPI;
mLastHorizDPI = LLFontGL::sHorizDPI;
mLastOrigin = LLFontGL::sCurOrigin;
mLastResGeneration = LLFontGL::sResolutionGeneration;

if (right_x)
{
Expand Down
1 change: 1 addition & 0 deletions indra/llrender/llfontvertexbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class LLFontVertexBuffer
F32 mLastScaleY = 1.f;
F32 mLastVertDPI = 0.f;
F32 mLastHorizDPI = 0.f;
S32 mLastResGeneration = 0;
LLCoordGL mLastOrigin;

static bool sEnableBufferCollection;
Expand Down
1 change: 1 addition & 0 deletions indra/llrender/llshadermgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,7 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("screenTex");
mReservedUniforms.push_back("screenDepth");
mReservedUniforms.push_back("refTex");
mReservedUniforms.push_back("exclusionTex");
mReservedUniforms.push_back("eyeVec");
mReservedUniforms.push_back("time");
mReservedUniforms.push_back("waveDir1");
Expand Down
3 changes: 3 additions & 0 deletions indra/llrender/llshadermgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class LLShaderMgr
LLShaderMgr();
virtual ~LLShaderMgr();

// Note: although you can use statically hashed strings to just bind a random uniform, it's generally preferably that you use this.
// Always document what the actual shader uniform is next to the shader uniform in this struct.
// clang-format off
typedef enum
{ // Shader uniform name, set in LLShaderMgr::initAttribsAndUniforms()
Expand Down Expand Up @@ -234,6 +236,7 @@ class LLShaderMgr
WATER_SCREENTEX, // "screenTex"
WATER_SCREENDEPTH, // "screenDepth"
WATER_REFTEX, // "refTex"
WATER_EXCLUSIONTEX, // "exclusionTex"
WATER_EYEVEC, // "eyeVec"
WATER_TIME, // "time"
WATER_WAVE_DIR1, // "waveDir1"
Expand Down
40 changes: 35 additions & 5 deletions indra/llui/llfolderview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "llfolderview.h"
#include "llfolderviewmodel.h"
#include "llcallbacklist.h"
#include "llclipboard.h" // *TODO: remove this once hack below gone.
#include "llkeyboard.h"
#include "lllineeditor.h"
Expand Down Expand Up @@ -274,7 +275,11 @@ LLFolderView::~LLFolderView( void )
mRenamer = NULL;
mStatusTextBox = NULL;

if (mPopupMenuHandle.get()) mPopupMenuHandle.get()->die();
if (mPopupMenuHandle.get())
{
mPopupMenuHandle.get()->die();
gIdleCallbacks.deleteFunction(onIdleUpdateMenu, this);
}
mPopupMenuHandle.markDead();

mAutoOpenItems.removeAllNodes();
Expand Down Expand Up @@ -1095,7 +1100,10 @@ bool LLFolderView::handleKeyHere( KEY key, MASK mask )
LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
if (menu && menu->isOpen())
{
LLMenuGL::sMenuContainer->hideMenus();
if (LLMenuGL::sMenuContainer->hideMenus())
{
gIdleCallbacks.deleteFunction(onIdleUpdateMenu, this);
}
}

switch( key )
Expand Down Expand Up @@ -1340,7 +1348,10 @@ bool LLFolderView::handleUnicodeCharHere(llwchar uni_char)
LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
if (menu && menu->isOpen())
{
LLMenuGL::sMenuContainer->hideMenus();
if (LLMenuGL::sMenuContainer->hideMenus())
{
gIdleCallbacks.deleteFunction(onIdleUpdateMenu, this);
}
}

//do text search
Expand Down Expand Up @@ -1612,7 +1623,11 @@ void LLFolderView::deleteAllChildren()
{
LLUI::getInstance()->removePopup(mRenamer);
}
if (mPopupMenuHandle.get()) mPopupMenuHandle.get()->die();
if (mPopupMenuHandle.get())
{
mPopupMenuHandle.get()->die();
gIdleCallbacks.deleteFunction(onIdleUpdateMenu, this);
}
mPopupMenuHandle.markDead();
mScrollContainer = NULL;
mRenameItem = NULL;
Expand Down Expand Up @@ -1979,9 +1994,24 @@ void LLFolderView::updateMenu()
LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
if (menu && menu->getVisible())
{
updateMenuOptions(menu);
// When fetching folders in bulk or in parts, each callback
// cause updateMenu individually, so make sure it gets called
// only once per frame, after callbacks are done.
// gIdleCallbacks has built in dupplicate protection.
gIdleCallbacks.addFunction(onIdleUpdateMenu, this);
}
}

void LLFolderView::onIdleUpdateMenu(void* user_data)
{
LLFolderView* self = (LLFolderView*)user_data;
LLMenuGL* menu = (LLMenuGL*)self->mPopupMenuHandle.get();
if (menu)
{
self->updateMenuOptions(menu);
menu->needsArrange(); // update menu height if needed
}
gIdleCallbacks.deleteFunction(onIdleUpdateMenu, NULL);
}

bool LLFolderView::isFolderSelected()
Expand Down
1 change: 1 addition & 0 deletions indra/llui/llfolderview.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class LLFolderView : public LLFolderViewFolder, public LLEditMenuHandler
private:
void updateMenuOptions(LLMenuGL* menu);
void updateRenamerPosition();
static void onIdleUpdateMenu(void* user_data);

protected:
LLScrollContainer* mScrollContainer; // NULL if this is not a child of a scroll container.
Expand Down
2 changes: 2 additions & 0 deletions indra/newview/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ set(viewer_SOURCE_FILES
lldrawpooltree.cpp
lldrawpoolwater.cpp
lldrawpoolwlsky.cpp
lldrawpoolwaterexclusion.cpp
lldynamictexture.cpp
llemote.cpp
llenvironment.cpp
Expand Down Expand Up @@ -823,6 +824,7 @@ set(viewer_HEADER_FILES
lldrawpooltree.h
lldrawpoolwater.h
lldrawpoolwlsky.h
lldrawpoolwaterexclusion.h
lldynamictexture.h
llemote.h
llenvironment.h
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* @file simpleColorF.glsl
*
* $LicenseInfo:firstyear=2025&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, 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$
*/

out vec4 frag_color;

in vec4 vertex_color;
in vec4 vertex_position;

uniform vec4 waterPlane;
uniform float waterSign;

void waterClip(vec3 pos)
{
// TODO: make this less branchy
if (waterSign > 0)
{
if ((dot(pos.xyz, waterPlane.xyz) + waterPlane.w) < 0.0)
{
discard;
}
}
else
{
if ((dot(pos.xyz, waterPlane.xyz) + waterPlane.w) > 0.0)
{
discard;
}
}
}

void main()
{

frag_color = vertex_color;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @file simpleNoAtmosV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, 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 modelview_matrix;
uniform mat4 modelview_projection_matrix;

uniform vec4 color;

in vec3 position;

out vec4 vertex_color;
out vec4 vertex_position;

void main()
{
//transform vertex
vec4 pos = (modelview_matrix * vec4(position.xyz, 1.0));
vertex_position = modelview_projection_matrix * vec4(position.xyz, 1.0);
gl_Position = vertex_position;
vertex_color = color;
}
14 changes: 14 additions & 0 deletions indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,25 @@ vec4 getWaterFogView(vec3 pos);

uniform int above_water;

uniform sampler2D exclusionTex;

void main()
{
vec2 tc = vary_fragcoord.xy/vary_fragcoord.w*0.5+0.5;
float depth = getDepth(tc.xy);
float mask = texture(exclusionTex, tc.xy).r;

if (above_water > 0)
{
// Just discard if we're in the exclusion mask.
// The previous invisiprim hack we're replacing would also crank up water fog desntiy.
// But doing that makes exclusion surfaces very slow as we'd need to render even more into the mask.
// - Geenz 2025-02-06
if (mask < 1)
{
discard;
}

// we want to depth test when the camera is above water, but some GPUs have a hard time
// with depth testing against render targets that are bound for sampling in the same shader
// so we do it manually here
Expand All @@ -51,12 +63,14 @@ void main()
{
discard;
}

}

vec4 pos = getPositionWithDepth(tc, depth);

vec4 fogged = getWaterFogView(pos.xyz);
fogged.a = max(pow(fogged.a, 1.7), 0);

frag_color = max(fogged, vec4(0)); //output linear since local lights will be added to this shader's results

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
out vec4 frag_color;

uniform sampler2D bumpMap;
uniform sampler2D exclusionTex;

#ifdef TRANSPARENT_WATER
uniform sampler2D screenTex;
Expand Down Expand Up @@ -59,6 +60,9 @@ void mirrorClip(vec3 position);
void main()
{
mirrorClip(vary_position);
vec2 screen_tc = (refCoord.xy/refCoord.z) * 0.5 + 0.5;
float water_mask = texture(exclusionTex, screen_tc).r;

vec4 color;

//get detail normals
Expand All @@ -68,8 +72,8 @@ void main()
vec3 wavef = normalize(wave1+wave2+wave3);

//figure out distortion vector (ripply)
vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5;
distort = distort+wavef.xy*refScale;
vec2 distort = screen_tc;
distort = mix(distort, distort+wavef.xy*refScale, water_mask);

#ifdef TRANSPARENT_WATER
vec4 fb = texture(screenTex, distort);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ uniform sampler2D screenTex;
uniform sampler2D depthMap;
#endif

uniform sampler2D refTex;
uniform sampler2D exclusionTex;

uniform float sunAngle;
uniform float sunAngle2;
Expand Down Expand Up @@ -252,6 +252,8 @@ void main()

float shadow = 1.0f;

float water_mask = texture(exclusionTex, distort).r;

#ifdef HAS_SUN_SHADOW
shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, distort);
#endif
Expand All @@ -266,9 +268,8 @@ void main()
vec3 refPos = getPositionWithNDC(vec3(distort*2.0-vec2(1.0), depth*2.0-1.0));

// Calculate some distance fade in the water to better assist with refraction blending and reducing the refraction texture's "disconnect".
fade = max(0,min(1, (pos.z - refPos.z) / 10));
fade = max(0,min(1, (pos.z - refPos.z) / 10)) * water_mask;
distort2 = mix(distort, distort2, min(1, fade * 10));

depth = texture(depthMap, distort2).r;

refPos = getPositionWithNDC(vec3(distort2 * 2.0 - vec2(1.0), depth * 2.0 - 1.0));
Expand All @@ -282,6 +283,9 @@ void main()

#else
vec4 fb = applyWaterFogViewLinear(viewVec*2048.0, vec4(1.0));

if (water_mask < 1)
discard;
#endif

float metallic = 1.0;
Expand Down Expand Up @@ -333,6 +337,7 @@ void main()
color = mix(fb.rgb, color, fade);

float spec = min(max(max(punctual.r, punctual.g), punctual.b), 0.05);
frag_color = min(vec4(1),max(vec4(color.rgb, spec), vec4(0)));

frag_color = min(vec4(1),max(vec4(color.rgb, spec * water_mask), vec4(0)));
}

Loading

0 comments on commit 2a2add7

Please sign in to comment.