mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 03:46:50 +01:00
Ported: Disable Alpha throughout Glow and FXAA code in order to avoid issues with transparent viewports. - clayjohn
f92141be13
This commit is contained in:
parent
2c0ca59835
commit
3f432af82b
@ -235,13 +235,21 @@ vec4 apply_fxaa(vec4 color, vec2 uv_interp, vec2 pixel_size) {
|
||||
const float FXAA_REDUCE_MIN = (1.0 / 128.0);
|
||||
const float FXAA_REDUCE_MUL = (1.0 / 8.0);
|
||||
const float FXAA_SPAN_MAX = 8.0;
|
||||
const vec3 luma = vec3(0.299, 0.587, 0.114);
|
||||
|
||||
vec4 rgbNW = texture2DLod(source, uv_interp + vec2(-1.0, -1.0) * pixel_size, 0.0);
|
||||
vec4 rgbNE = texture2DLod(source, uv_interp + vec2(1.0, -1.0) * pixel_size, 0.0);
|
||||
vec4 rgbSW = texture2DLod(source, uv_interp + vec2(-1.0, 1.0) * pixel_size, 0.0);
|
||||
vec4 rgbSE = texture2DLod(source, uv_interp + vec2(1.0, 1.0) * pixel_size, 0.0);
|
||||
vec3 rgbM = color.rgb;
|
||||
vec3 luma = vec3(0.299, 0.587, 0.114);
|
||||
|
||||
#ifdef DISABLE_ALPHA
|
||||
float lumaNW = dot(rgbNW.rgb, luma);
|
||||
float lumaNE = dot(rgbNE.rgb, luma);
|
||||
float lumaSW = dot(rgbSW.rgb, luma);
|
||||
float lumaSE = dot(rgbSE.rgb, luma);
|
||||
float lumaM = dot(rgbM, luma);
|
||||
#else
|
||||
float lumaNW = dot(rgbNW.rgb, luma) - ((1.0 - rgbNW.a) / 8.0);
|
||||
float lumaNE = dot(rgbNE.rgb, luma) - ((1.0 - rgbNE.a) / 8.0);
|
||||
float lumaSW = dot(rgbSW.rgb, luma) - ((1.0 - rgbSW.a) / 8.0);
|
||||
@ -249,6 +257,7 @@ vec4 apply_fxaa(vec4 color, vec2 uv_interp, vec2 pixel_size) {
|
||||
float lumaM = dot(rgbM, luma) - (color.a / 8.0);
|
||||
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
||||
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
||||
#endif
|
||||
|
||||
vec2 dir;
|
||||
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
||||
@ -267,6 +276,13 @@ vec4 apply_fxaa(vec4 color, vec2 uv_interp, vec2 pixel_size) {
|
||||
vec4 rgbA = 0.5 * (texture2DLod(source, uv_interp + dir * (1.0 / 3.0 - 0.5), 0.0) + texture2DLod(source, uv_interp + dir * (2.0 / 3.0 - 0.5), 0.0));
|
||||
vec4 rgbB = rgbA * 0.5 + 0.25 * (texture2DLod(source, uv_interp + dir * -0.5, 0.0) + texture2DLod(source, uv_interp + dir * 0.5, 0.0));
|
||||
|
||||
|
||||
#ifdef DISABLE_ALPHA
|
||||
float lumaB = dot(rgbB.rgb, luma);
|
||||
vec4 color_output = ((lumaB < lumaMin) || (lumaB > lumaMax)) ? rgbA : rgbB;
|
||||
return vec4(color_output.rgb, 1.0);
|
||||
#else
|
||||
|
||||
float lumaB = dot(rgbB.rgb, luma) - ((1.0 - rgbB.a) / 8.0);
|
||||
vec4 color_output = ((lumaB < lumaMin) || (lumaB > lumaMax)) ? rgbA : rgbB;
|
||||
if (color_output.a == 0.0) {
|
||||
@ -276,11 +292,16 @@ vec4 apply_fxaa(vec4 color, vec2 uv_interp, vec2 pixel_size) {
|
||||
}
|
||||
|
||||
return color_output;
|
||||
#endif
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 color = texture2DLod(source, uv_interp, 0.0);
|
||||
|
||||
#ifdef DISABLE_ALPHA
|
||||
color.a = 1.0;
|
||||
#endif
|
||||
|
||||
#ifdef USE_FXAA
|
||||
color = apply_fxaa(color, uv_interp, pixel_size);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user