mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-10-14 11:28:11 +00:00
[client] egl: rework post process filters and add AMD FXR
This commit is contained in:
32
client/renderers/EGL/shader/compat.h
Normal file
32
client/renderers/EGL/shader/compat.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#if __VERSION__ == 300
|
||||
vec4 textureGather(sampler2D tex, vec2 uv, int comp)
|
||||
{
|
||||
vec4 c0 = textureOffset(tex, uv, ivec2(0,1));
|
||||
vec4 c1 = textureOffset(tex, uv, ivec2(1,1));
|
||||
vec4 c2 = textureOffset(tex, uv, ivec2(1,0));
|
||||
vec4 c3 = textureOffset(tex, uv, ivec2(0,0));
|
||||
return vec4(c0[comp], c1[comp], c2[comp],c3[comp]);
|
||||
}
|
||||
#elif __VERSION__ < 300
|
||||
vec4 textureGather(sampler2D tex, vec2 uv, int comp)
|
||||
{
|
||||
vec4 c3 = texture2D(tex, uv);
|
||||
return vec4(c3[comp], c3[comp], c3[comp],c3[comp]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __VERSION__ < 310
|
||||
uint bitfieldExtract(uint val, int off, int size)
|
||||
{
|
||||
uint mask = uint((1 << size) - 1);
|
||||
return uint(val >> off) & mask;
|
||||
}
|
||||
|
||||
uint bitfieldInsert(uint a, uint b, int c, int d)
|
||||
{
|
||||
uint mask = ~(0xffffffffu << d) << c;
|
||||
mask = ~mask;
|
||||
a &= mask;
|
||||
return a | (b << c);
|
||||
}
|
||||
#endif
|
@@ -3,11 +3,11 @@
|
||||
layout(location = 0) in vec2 vertex;
|
||||
out highp vec2 uv;
|
||||
|
||||
uniform highp vec2 size;
|
||||
uniform highp vec2 desktopSize;
|
||||
uniform mat3x2 transform;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(transform * vec3(vertex, 1.0), 0.0, 1.0);
|
||||
uv = vertex / size;
|
||||
uv = vertex / desktopSize;
|
||||
}
|
||||
|
@@ -13,8 +13,7 @@ out highp vec4 color;
|
||||
uniform sampler2D sampler1;
|
||||
|
||||
uniform int scaleAlgo;
|
||||
uniform highp vec2 size;
|
||||
uniform highp float textureScale;
|
||||
uniform highp ivec2 textureSize;
|
||||
|
||||
uniform highp float nvGain;
|
||||
uniform int cbMode;
|
||||
@@ -24,7 +23,7 @@ void main()
|
||||
switch (scaleAlgo)
|
||||
{
|
||||
case EGL_SCALE_NEAREST:
|
||||
color = texelFetch(sampler1, ivec2(uv * size * textureScale), 0);
|
||||
color = texelFetch(sampler1, ivec2(uv * vec2(textureSize)), 0);
|
||||
break;
|
||||
|
||||
case EGL_SCALE_LINEAR:
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,8 @@
|
||||
#version 300 es
|
||||
|
||||
precision mediump float;
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
in vec2 iFragCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
@@ -10,22 +11,6 @@ uniform uvec2 uInRes[8];
|
||||
uniform uvec2 uOutRes;
|
||||
uniform float uSharpness;
|
||||
|
||||
// the following are not available until verion 400 or later
|
||||
// so we implement our own versions of them
|
||||
uint bitfieldExtract(uint val, int off, int size)
|
||||
{
|
||||
uint mask = uint((1 << size) - 1);
|
||||
return uint(val >> off) & mask;
|
||||
}
|
||||
|
||||
uint bitfieldInsert(uint a, uint b, int c, int d)
|
||||
{
|
||||
uint mask = ~(0xffffffffu << d) << c;
|
||||
mask = ~mask;
|
||||
a &= mask;
|
||||
return a | (b << c);
|
||||
}
|
||||
|
||||
#define A_GPU 1
|
||||
#define A_GLSL 1
|
||||
|
||||
|
1199
client/renderers/EGL/shader/ffx_fsr1.h
Normal file
1199
client/renderers/EGL/shader/ffx_fsr1.h
Normal file
File diff suppressed because it is too large
Load Diff
48
client/renderers/EGL/shader/ffx_fsr1_easu.frag
Normal file
48
client/renderers/EGL/shader/ffx_fsr1_easu.frag
Normal file
@@ -0,0 +1,48 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
in vec2 iFragCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D iChannel0;
|
||||
uniform uvec2 uInRes[8];
|
||||
uniform uvec2 uOutRes;
|
||||
|
||||
#define A_GPU 1
|
||||
#define A_GLSL 1
|
||||
#define A_FULL 1
|
||||
|
||||
#include "ffx_a.h"
|
||||
|
||||
#define FSR_EASU_F 1
|
||||
#define FSR_RCAS_F 1
|
||||
|
||||
AF4 FsrEasuRF(AF2 p){return AF4(textureGather(iChannel0, p, 0));}
|
||||
AF4 FsrEasuGF(AF2 p){return AF4(textureGather(iChannel0, p, 1));}
|
||||
AF4 FsrEasuBF(AF2 p){return AF4(textureGather(iChannel0, p, 2));}
|
||||
|
||||
#include "ffx_fsr1.h"
|
||||
|
||||
void main()
|
||||
{
|
||||
AU4 con0, con1, con2, con3;
|
||||
vec2 inRes = vec2(uInRes[0]);
|
||||
vec2 outRes = vec2(uOutRes);
|
||||
|
||||
FsrEasuCon(
|
||||
con0,
|
||||
con1,
|
||||
con2,
|
||||
con3,
|
||||
inRes.x , inRes.y,
|
||||
inRes.x , inRes.y,
|
||||
outRes.x, outRes.y
|
||||
);
|
||||
|
||||
vec3 color;
|
||||
uvec2 point = uvec2(iFragCoord * outRes);
|
||||
FsrEasuF(color, point, con0, con1, con2, con3);
|
||||
fragColor = vec4(color.xyz, 1);
|
||||
}
|
36
client/renderers/EGL/shader/ffx_fsr1_rcas.frag
Normal file
36
client/renderers/EGL/shader/ffx_fsr1_rcas.frag
Normal file
@@ -0,0 +1,36 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
in vec2 iFragCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D iChannel0;
|
||||
uniform uvec2 uInRes[8];
|
||||
uniform float uSharpness;
|
||||
|
||||
#define A_GPU 1
|
||||
#define A_GLSL 1
|
||||
#define A_FULL 1
|
||||
|
||||
#include "ffx_a.h"
|
||||
|
||||
AF4 FsrRcasLoadF(ASU2 p) { return texelFetch(iChannel0, ASU2(p), 0); }
|
||||
void FsrRcasInputF(inout AF1 r, inout AF1 g, inout AF1 b) {}
|
||||
|
||||
#define FSR_RCAS_F 1
|
||||
#define FSR_RCAS_DENOISE 1
|
||||
#include "ffx_fsr1.h"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 inRes = vec2(uInRes[0]);
|
||||
uvec2 point = uvec2(iFragCoord * inRes);
|
||||
|
||||
uvec4 const0;
|
||||
FsrRcasCon(const0, 1.0f - uSharpness);
|
||||
|
||||
FsrRcasF(fragColor.r, fragColor.g, fragColor.b, point, const0);
|
||||
fragColor.a = 1.0f;
|
||||
}
|
Reference in New Issue
Block a user