Skip to content

Commit 2ca193c

Browse files
Rye CogtailRyeMutt
authored andcommitted
Improve FXAA quality and performance when GL version is greater then 4
Adds gather4 support under GLSL 4.0+
1 parent cbca178 commit 2ca193c

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

indra/llrender/llshadermgr.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,6 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev
595595
extra_code_text[extra_code_count++] = strdup("precision highp float;\n");
596596
}
597597
}
598-
599-
extra_code_text[extra_code_count++] = strdup("#define FXAA_GLSL_130 1\n");
600598
}
601599

602600
// Use alpha float to store bit flags

indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ A. Or use FXAA_GREEN_AS_LUMA.
256256
#define FXAA_GLSL_130 0
257257
#endif
258258
/*--------------------------------------------------------------------------*/
259+
#ifndef FXAA_GLSL_400
260+
#define FXAA_GLSL_400 0
261+
#endif
262+
/*--------------------------------------------------------------------------*/
259263
#ifndef FXAA_HLSL_3
260264
#define FXAA_HLSL_3 0
261265
#endif
@@ -342,8 +346,8 @@ A. Or use FXAA_GREEN_AS_LUMA.
342346
// 1 = API supports gather4 on alpha channel.
343347
// 0 = API does not support gather4 on alpha channel.
344348
//
345-
#if (FXAA_GLSL_130 == 0)
346-
#define FXAA_GATHER4_ALPHA 0
349+
#if (FXAA_GLSL_400 == 1)
350+
#define FXAA_GATHER4_ALPHA 1
347351
#endif
348352
#if (FXAA_HLSL_5 == 1)
349353
#define FXAA_GATHER4_ALPHA 1
@@ -652,7 +656,7 @@ NOTE the other tuning knobs are now in the shader function inputs!
652656
API PORTING
653657
654658
============================================================================*/
655-
#if (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)
659+
#if (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1) || (FXAA_GLSL_400 == 1)
656660
#define FxaaBool bool
657661
#define FxaaDiscard discard
658662
#define FxaaFloat float
@@ -714,6 +718,16 @@ NOTE the other tuning knobs are now in the shader function inputs!
714718
#endif
715719
#endif
716720
/*--------------------------------------------------------------------------*/
721+
#if (FXAA_GLSL_400 == 1)
722+
// Requires "#version 400" or better
723+
#define FxaaTexTop(t, p) textureLod(t, p, 0.0)
724+
#define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)
725+
#define FxaaTexAlpha4(t, p) textureGather(t, p, 3)
726+
#define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)
727+
#define FxaaTexGreen4(t, p) textureGather(t, p, 1)
728+
#define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)
729+
#endif
730+
/*--------------------------------------------------------------------------*/
717731
#if (FXAA_HLSL_3 == 1) || (FXAA_360 == 1) || (FXAA_PS3 == 1)
718732
#define FxaaInt2 float2
719733
#define FxaaTex sampler2D

indra/newview/llviewershadermgr.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,16 @@ bool LLViewerShaderMgr::loadShadersDeferred()
23452345
gFXAAProgram.mShaderFiles.clear();
23462346
gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER));
23472347
gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/fxaaF.glsl", GL_FRAGMENT_SHADER));
2348+
2349+
if (gGLManager.mGLVersion > 3.9)
2350+
{
2351+
gFXAAProgram.addPermutation("FXAA_GLSL_400", "1");
2352+
}
2353+
else
2354+
{
2355+
gFXAAProgram.addPermutation("FXAA_GLSL_130", "1");
2356+
}
2357+
23482358
gFXAAProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
23492359
success = gFXAAProgram.createShader();
23502360
llassert(success);

0 commit comments

Comments
 (0)