Sync to koko-aio 1.9.20-hotfix3 (#596)

* there were an undefined function, fixed

* fixed name

* Sync to 1.9.20-hotfix1 and removed a bunch of unused files

* Sync to koko-aio 1.9.20-hotfix2

* resync

* Sync to koko-aio 1.9.20-hotfix3
This commit is contained in:
Antonio Orefice 2024-05-23 03:35:55 +02:00 committed by GitHub
parent 9c930380c5
commit 56d13de9b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
27 changed files with 67 additions and 2890 deletions

View File

@ -84,27 +84,34 @@ float get_avg_lum_from_mip(sampler2D tex, vec2 co, float lod) {
vec3 mip = textureLod(colortools_and_ntsc_pass, co, lod).rgb; vec3 mip = textureLod(colortools_and_ntsc_pass, co, lod).rgb;
mip = apply_fuzzy_main_pass_stage_2(mip, vFuzzy_main_pass_stage_1); mip = apply_fuzzy_main_pass_stage_2(mip, vFuzzy_main_pass_stage_1);
//return (mip.r+mip.g+mip.b)/3.0; //return (mip.r+mip.g+mip.b)/3.0;
float luminance_from_feedback = rgb_to_gray(mip);
float luminance_first_pass = texture(bloom_pass_finalFeedback,vTexCoord).a; float luminance_first_pass = texture(bloom_pass_finalFeedback,vTexCoord).a;
luminance_first_pass = max(luminance_first_pass, 0.0); // <- Sanitize input to avoid glitches when enabling the option runtime. luminance_first_pass = max(luminance_first_pass, 0.0); // <- Sanitize input to avoid glitches when enabling the option runtime.
//temporal smooth. //temporal smooth.
//the defined emulated eye adaption speed needs to be divided //the defined emulated eye adaption speed needs to be divided
//by the eye adaption strength (BLOOM_EYE_ADPT_SRT) //by the eye adaption strength (BLOOM_EYE_ADPT_SRT)
//The following makes the adaption speed more constant: float eye_adaption_speed;
float eye_adaption_speed = BLOOM_PUPIL_ADAPTION_SPEED * ( luminance_first_pass / luminance_from_feedback ) ; float luminance_from_feedback = rgb_to_gray(mip);
if (DELTA_RENDER == 0.0) {
//The following makes the adaption speed more constant:
eye_adaption_speed = BLOOM_PUPIL_ADAPTION_SPEED * ( luminance_first_pass / luminance_from_feedback ) ;
//The following is needed so that the speed is the same even for higher strength //The following is needed so that the speed is the same even for higher strength
eye_adaption_speed = (eye_adaption_speed / BLOOM_EYE_ADPT_SRT); eye_adaption_speed = (eye_adaption_speed / BLOOM_EYE_ADPT_SRT);
//The following simulates pupil inertia //The following simulates pupil inertia
eye_adaption_speed = clamp(eye_adaption_speed, 1.0/BLOOM_EYE_INERTIA, 1.0); eye_adaption_speed = clamp(eye_adaption_speed, 1.0/BLOOM_EYE_INERTIA, 1.0);
} else {
float luminance = mix(luminance_first_pass, luminance_from_feedback, eye_adaption_speed); //Temporal adaption speed is no good with deltarenter.
eye_adaption_speed = 1.0;
}
float luminance = mix(luminance_first_pass, luminance_from_feedback, eye_adaption_speed);
return luminance + eps; return luminance + eps;
} }

View File

@ -157,7 +157,12 @@ vec4 ntscdec(vec2 uv, vec3 RGB_ori) {
#endif #endif
for (int n=0; n < N; n++) { for (int n=0; n < N; n++) {
vec2 pos = uv + vec2( (n-NTSC_FILTER_MIDDLE) * params.SourceSize.z , 0.0); vec2 pos = uv + vec2( (n-NTSC_FILTER_MIDDLE) * params.SourceSize.z , 0.0);
vec3 smp_mul_weight = vec3((texture(Source, pos).rgb * RGB2YIQ).x) * vNTSC_weights[n] ; //vec3 smp_mul_weight = vec3((texture(Source, pos).rgb * RGB2YIQ).x) * vNTSC_weights[n] ;
//need texture nearest here, because we have to sample linearly from previous pass,
//In turn, because we need linear feedback from this pass (linear feedback mipmaps needed by deltarender)
//and linear feedback is controlled by this pass filtering, contrary to the present linear filtering
//which is controlled by next pass filtering (What a mess RetroArch!)
vec3 smp_mul_weight = vec3((texture_NEAREST(Source, pos, params.SourceSize).rgb * RGB2YIQ).x) * vNTSC_weights[n] ;
float phase = vSubcarrierFrequency_mul_size_mul_TAU * pos.x; float phase = vSubcarrierFrequency_mul_size_mul_TAU * pos.x;
@ -272,10 +277,6 @@ bool first_in_range_strict(float a, float lo, float hi) {
return a == bounded; return a == bounded;
} }
/*bool first_in_range_strict(float a, float lo, float hi) {
return (a >= lo) && (a <= hi);
}*/
vec3 pixel_dedither(sampler2D tex, vec2 coords, vec4 sourcesize, float tmin, float tmax, float strength1, float strength2) { vec3 pixel_dedither(sampler2D tex, vec2 coords, vec4 sourcesize, float tmin, float tmax, float strength1, float strength2) {
#define DX sourcesize.z #define DX sourcesize.z
#define DY sourcesize.w #define DY sourcesize.w
@ -345,14 +346,8 @@ vec3 pixel_dedither(sampler2D tex, vec2 coords, vec4 sourcesize, float tmin, flo
} }
} }
//if (accum_div1 > 0.0) {
//pixel_out = (pxb + pxa + pxc + pya + pyc + pxya + pxyc + pxya2 + pxyc2) / 9.0;
//pixel_out = (pxb + pxa + pxc + pya + pyc ) / 5.0;
//pixel_out = mix(p0, (avg_x + avg_y + avg_xy + avg_yx) / accum_div, strength1);
//}
vec3 pixel_out = p0; vec3 pixel_out = p0;
if (accum_div1 > 0.0) { if (accum_div1 > 0.0) {
//pixel_out = mix(pixel_out, (avg_x + avg_y) / accum_div1, strength1);
pixel_out = mix(pixel_out, fma(avg_x, vec3(1.0)/accum_div1, avg_y / accum_div1) , strength1); //ASM PROOF FASTER pixel_out = mix(pixel_out, fma(avg_x, vec3(1.0)/accum_div1, avg_y / accum_div1) , strength1); //ASM PROOF FASTER
} }
if (accum_div2 > 0.0) { if (accum_div2 > 0.0) {
@ -364,38 +359,6 @@ vec3 pixel_dedither(sampler2D tex, vec2 coords, vec4 sourcesize, float tmin, flo
} }
vec3 persistence_v1(vec3 feedback, vec3 pixel_now, float start_decay, float end_decay, float motion_blur_cancel) {
//start_decay: is the initial decay, the fast one: 1.0 means instantaneous, try around 0.8
//end decay the higher, the more the persistance in the long run, try around 1.0;
//motion_blur_cancel: 0.0 means full blur on bright areas; try around 2.5
vec3 x=(feedback - pixel_now);
vec3 a = vec3( 1 + start_decay );
vec3 b = vec3( end_decay );
//compute fade speed as an high gamma curve:
vec3 fade_speed=pow(a, pow(x,b) )-1;
//higher speed is needed when composing over brighter colors to avoid motion blur
fade_speed = fade_speed + (pixel_now*motion_blur_cancel);
//Ensure a minimum speed to reach 0.0 and clamp to 1.0 to avoid funky effects
float min_speed = 0.05 ;
fade_speed=clamp(fade_speed, min_speed, 1.0);
//Compute the persistent light by mixing pixel current and previous one
vec3 pixel_persistent = mix(feedback, pixel_now, fade_speed );
//blend only if we are fading out
vec3 light_fading_out = vec3(greaterThan(feedback, pixel_now));
return mix(pixel_now, pixel_persistent, light_fading_out);
}
vec3 persistence(vec3 feedback, vec3 pixel_now, float start_decay, float late_persistence, float motion_blur_cancel) { vec3 persistence(vec3 feedback, vec3 pixel_now, float start_decay, float late_persistence, float motion_blur_cancel) {
//start_decay: is the initial decay, the fast one: 1.0 means instantaneous, try around 0.8 //start_decay: is the initial decay, the fast one: 1.0 means instantaneous, try around 0.8
//end decay the higher, the more the persistance in the long run, try around 1.0; //end decay the higher, the more the persistance in the long run, try around 1.0;
@ -516,10 +479,11 @@ void main() {
*/ */
if (DO_PPERSISTENCE == 1.0) { if (DO_PPERSISTENCE == 1.0) {
//persistence(vec3 feedback, vec3 pixel_now, float start_decay, float end_decay, float motion_blur_cancel) { if (params.OutputSize.xy == global.colortools_and_ntsc_passFeedbackSize.xy) {
vec3 feedback = texture(colortools_and_ntsc_passFeedback, co).rgb; vec3 feedback = texture(colortools_and_ntsc_passFeedback, co).rgb;
float motion_blur_cancel = 2.5; float motion_blur_cancel = 2.5;
pixel_out = persistence(feedback, pixel_out, PPERSISTENCE_START, PPERSISTENCE_END, motion_blur_cancel); pixel_out = persistence(feedback, pixel_out, PPERSISTENCE_START, PPERSISTENCE_END, motion_blur_cancel);
}
} }

View File

@ -39,6 +39,7 @@ layout(std140, set = 0, binding = 0) uniform UBO {
vec4 avglum_passSize; vec4 avglum_passSize;
vec4 flick_and_noise_passSize; vec4 flick_and_noise_passSize;
vec4 colortools_and_ntsc_passSize; vec4 colortools_and_ntsc_passSize;
vec4 colortools_and_ntsc_passFeedbackSize;
float COLOR_MONO_COLORIZE; float COLOR_MONO_COLORIZE;
float COLOR_MONO_HUE1; float COLOR_MONO_HUE1;

39
bezel/koko-aio/shaders-ng/final_pass.slang Normal file → Executable file
View File

@ -423,7 +423,7 @@ layout(set = 0, binding = 6) uniform sampler2D monitor_body_straight;
layout(set = 0, binding = 7) uniform sampler2D monitor_body_curved; layout(set = 0, binding = 7) uniform sampler2D monitor_body_curved;
layout(set = 0, binding = 8) uniform sampler2D bg_under; layout(set = 0, binding = 8) uniform sampler2D bg_under;
layout(set = 0, binding = 9) uniform sampler2D bg_over; layout(set = 0, binding = 9) uniform sampler2D bg_over;
//layout(set = 0, binding = 10) uniform sampler2D halo_pre_gamma_pass; //layout(set = 0, binding = 10) uniform sampler2D in_glow_pass_x;
layout(set = 0, binding = 11) uniform sampler2D in_glow_pass; layout(set = 0, binding = 11) uniform sampler2D in_glow_pass;
layout(set = 0, binding = 12) uniform sampler2D halo_pass; layout(set = 0, binding = 12) uniform sampler2D halo_pass;
#ifndef D3D_WORKAROUND #ifndef D3D_WORKAROUND
@ -1295,9 +1295,7 @@ void main() {
#ifndef D3D_WORKAROUND #ifndef D3D_WORKAROUND
if (DELTA_RENDER == 1.0) { if (DELTA_RENDER == 1.0) {
bool reuse_old = bool( float(texture(in_glow_pass, co_content).a > 3.0) * canvas_busy * vDeltaRenderOk ) ; bool reuse_old = bool( float( texture(in_glow_pass, co_content).a == 0.0) * canvas_busy * vDeltaRenderOk ) ;
// ^^ We have to check if alpha is > 3.0 because till 3.0 it means it is carrying the scanline
// ^^ inflation information from glow_y pass.
if (reuse_old) { if (reuse_old) {
FragColor = texture(final_passFeedback, vOutputCoord);// * vec4(1,0,0,0); FragColor = texture(final_passFeedback, vOutputCoord);// * vec4(1,0,0,0);
return; return;
@ -1524,38 +1522,5 @@ void main() {
#endif #endif
FragColor = vec4(pixel_out, 1.0); FragColor = vec4(pixel_out, 1.0);
/*
float m = 1.0;
vec2 d = global.flick_and_noise_passSize.zw*m;
vec2 sharpness = d*SERVICE1/m;
vec3 gx = texture(in_glow_pass, vec2(vTexCoord.x + d.x, vTexCoord.y)).rgb -
texture(in_glow_pass, vec2(vTexCoord.x - d.x, vTexCoord.y)).rgb;
vec3 gy = texture(in_glow_pass, vec2(vTexCoord.x, vTexCoord.y + d.y)).rgb -
texture(in_glow_pass, vec2(vTexCoord.x, vTexCoord.y - d.y)).rgb;
float fgx = +(gx.x+gx.y+gx.z)/3.0;
float fgy = +(gy.x+gy.y+gy.z)/3.0;
// fgx = clamp(fgx, -SERVICE1, SERVICE1);
// fgy = clamp(fgy, -SERVICE1, SERVICE1);
vec2 warp = vec2(fgx, fgy) * sharpness;
vec2 warpedTexCoord = vTexCoord + warp;
vec4 warpedColor = texture(in_glow_pass, warpedTexCoord);
FragColor = vec4(fgx*fgy);
FragColor = warpedColor;
*/
} }

15
bezel/koko-aio/shaders-ng/halo.slang Normal file → Executable file
View File

@ -55,24 +55,15 @@ layout(location = 3) in float vDeltaRenderOk;
layout(location = 0) out vec4 FragColor; layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 4) uniform sampler2D Source; layout(set = 0, binding = 4) uniform sampler2D Source;
layout(set = 0, binding = 5) uniform sampler2D in_glow_pass; layout(set = 0, binding = 5) uniform sampler2D in_glow_pass_x;
void main() { void main() {
if (DO_HALO == 0.0 ) return; if (DO_HALO == 0.0 ) return;
if (DELTA_RENDER == 1.0) {
if (vDeltaRenderOk == 1.0) {
//No need to process halo if we're using deltarender and content did not change.
if (texture(in_glow_pass, vTexCoord).a > 3.0)
return;
}
}
//Pass the right texture unchanged for tighter blurs: //Pass the right texture unchanged for tighter blurs:
if (HALO_SHARPNESS >= GLOW_SHARP_MAX) { if (HALO_SHARPNESS >= GLOW_SHARP_MAX) {
FragColor = vec4( pow(texture(Source, vTexCoord).rgb * vHALO_POWER, vec3(HALO_GAMMA_OUT)), 1.0) ; FragColor = vec4( pow(texture(Source, vTexCoord).rgb * vHALO_POWER, vec3(HALO_GAMMA_OUT)), 0.0) ;
return; return;
} }
@ -81,6 +72,6 @@ void main() {
pixel_haloed = pow(pixel_haloed, vec3(HALO_GAMMA_OUT)); pixel_haloed = pow(pixel_haloed, vec3(HALO_GAMMA_OUT));
FragColor = vec4(pixel_haloed.rgb, 1.0); FragColor = vec4(pixel_haloed.rgb, 0.0);
} }

17
bezel/koko-aio/shaders-ng/in_glow_x.slang Normal file → Executable file
View File

@ -14,7 +14,6 @@ layout(location = 1) out float glow_h_and_w_outside_interval;
layout(location = 2) out float glow_w_inside_interval; layout(location = 2) out float glow_w_inside_interval;
layout(location = 3) out float vSharp_sub; layout(location = 3) out float vSharp_sub;
layout(location = 4) out float vShowArtifactsMask; layout(location = 4) out float vShowArtifactsMask;
layout(location = 5) out float vDeltaRenderOk;
void main() { void main() {
gl_Position = global.MVP * Position; gl_Position = global.MVP * Position;
@ -41,9 +40,6 @@ void main() {
vShowArtifactsMask = float(DO_NTSC_ARTIFACTS + NTSC_SHOW_ARTF_MASK > 1.5); vShowArtifactsMask = float(DO_NTSC_ARTIFACTS + NTSC_SHOW_ARTF_MASK > 1.5);
bool bIs_Interlaced = is_interlaced();
vDeltaRenderOk = is_deltarender_allowed(bIs_Interlaced); //carries DR mandatory conditions, including forced refreshed frames
} }
@ -74,19 +70,6 @@ vec3 blur_select_wrap(sampler2D texture_in, vec2 co, vec4 sourcesize, float shar
void main() { void main() {
//Delta render?
if (DELTA_RENDER == 1.0) {
if (vDeltaRenderOk == 1.0) {
float DR_unchanged = delta_render_unchanged(colortools_and_ntsc_passFeedback, colortools_and_ntsc_pass,
vTexCoord, DELTA_RENDER_CHECK_AREA);
if (DR_unchanged > 0.0) {
FragColor = vec4(0.0,0.0,0.0,DR_unchanged);
return;
}
}
}
//Modulate glow power via ntsc artifact mask: //Modulate glow power via ntsc artifact mask:
float ntsc_artifacts = texture(shift_and_bleed_pass, vTexCoord).a; //compiler is smart enough to reuse this lookup, no need to branch. float ntsc_artifacts = texture(shift_and_bleed_pass, vTexCoord).a; //compiler is smart enough to reuse this lookup, no need to branch.

38
bezel/koko-aio/shaders-ng/in_glow_y.slang Normal file → Executable file
View File

@ -64,6 +64,8 @@ layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 5) uniform sampler2D shift_and_bleed_pass; layout(set = 0, binding = 5) uniform sampler2D shift_and_bleed_pass;
layout(set = 0, binding = 6) uniform sampler2D Source; layout(set = 0, binding = 6) uniform sampler2D Source;
layout(set = 0, binding = 7) uniform sampler2D in_glow_passFeedback; layout(set = 0, binding = 7) uniform sampler2D in_glow_passFeedback;
layout(set = 0, binding = 8) uniform sampler2D colortools_and_ntsc_passFeedback;
layout(set = 0, binding = 9) uniform sampler2D colortools_and_ntsc_pass;
vec3 glow_blur_bias(sampler2D source_tex, vec2 co, vec3 pixel_glowed, float bias){ vec3 glow_blur_bias(sampler2D source_tex, vec2 co, vec3 pixel_glowed, float bias){
vec3 pixel_source = texture(source_tex, co).rgb; vec3 pixel_source = texture(source_tex, co).rgb;
@ -222,22 +224,20 @@ void main() {
return; return;
*/ */
//Delta render?
if (DELTA_RENDER == 1.0) {
if (vDeltaRenderOk == 1.0) {
float DR_unchanged = texture(Source,vTexCoord).a;
if (DR_unchanged > 0.0) {
FragColor = vec4( texture(in_glow_passFeedback, vTexCoord).rgb,DR_unchanged);
return;
}
}
}
//Delta render?
float DR_changed = 1.0;
if (DELTA_RENDER == 1.0) {
if (vDeltaRenderOk == 1.0) {
DR_changed = delta_render_changed(colortools_and_ntsc_passFeedback, colortools_and_ntsc_pass,
vTexCoord, DELTA_RENDER_CHECK_AREA);
}
}
float max_inLum = max( 1.0, DO_CCORRECTION * apply_contrast_brightness(1.0, CONTRAST, BRIGHTNESS)); float max_inLum = max( 1.0, DO_CCORRECTION * apply_contrast_brightness(1.0, CONTRAST, BRIGHTNESS));
//Scanlines (over)inflation. //Scanlines (over)inflation.
//The result will be stored in the alpha channel to be consumed by final pass. //The result will be stored in the alpha channel to be consumed by final pass.
float dy = global.flick_and_noise_passSize.w; float dy = params.OriginalSize.w * 0.5;
float inflation = PIXELGRID_INFLATION * 0.25 * dy * PIXELGRID_MAX_H; float inflation = PIXELGRID_INFLATION * 0.25 * dy * PIXELGRID_MAX_H;
vec3 gy = texture(Source, vec2(vTexCoord.x, vTexCoord.y + dy)).rgb vec3 gy = texture(Source, vec2(vTexCoord.x, vTexCoord.y + dy)).rgb
@ -245,12 +245,20 @@ void main() {
gy /=max_inLum; gy /=max_inLum;
float scanline_inflation = (gy.x+gy.y+gy.z) * (inflation*global.FinalViewportSize.y); float scanline_inflation = (gy.x+gy.y+gy.z) * (inflation*global.FinalViewportSize.y)
+ (eps * DELTA_RENDER);
//This eps is needed because we multiplex deltarender and inflection and we NEED to have dr = 0.0 (and not a positive number)
//To reuse old pixels, only that way (using 0.0 to reuse pixels) multiplexing is possible.
float inflation_or_DR = scanline_inflation;
if (DR_changed == 0.0) {
inflation_or_DR = DR_changed;
}
if (DO_IN_GLOW == 0.0) { if (DO_IN_GLOW == 0.0) {
FragColor = vec4(texture(shift_and_bleed_pass, vTexCoord).rgb * vGlow_Gain, scanline_inflation); FragColor = vec4(texture(shift_and_bleed_pass, vTexCoord).rgb * vGlow_Gain, inflation_or_DR);
return; return;
} }
@ -288,7 +296,7 @@ void main() {
} }
FragColor = vec4(pixel_glowed * vGlow_Gain, scanline_inflation); FragColor = vec4(pixel_glowed * vGlow_Gain, inflation_or_DR);
} }

View File

@ -1583,15 +1583,17 @@ float is_deltarender_allowed(bool is_interlaced) {
( (! is_interlaced) || PIXELGRID_INTR_DISABLE_Y >= 1.0 || DO_PIXELGRID_H == 0.0)); // - screen is not interlaced or we disabled scanlines on interlaced content ( (! is_interlaced) || PIXELGRID_INTR_DISABLE_Y >= 1.0 || DO_PIXELGRID_H == 0.0)); // - screen is not interlaced or we disabled scanlines on interlaced content
} }
float delta_render_unchanged(sampler2D mip_past, sampler2D mip_now, vec2 co, float lod) { float delta_render_changed(sampler2D smp_past, sampler2D smp_now, vec2 co, float lod) {
vec3 p1 = textureLod(mip_now, co, lod).rgb; vec3 s1 = textureLod(smp_now, co, 1.0).rgb; // It is important that this is with lod = 1.0
vec3 p2 = textureLod(mip_past, co, lod).rgb; vec3 s2 = textureLod(smp_past, co, 1.0).rgb; // It is important that this is with lod = 1.0
vec3 m1 = textureLod(smp_now, co, lod).rgb;
vec3 m2 = textureLod(smp_past, co, lod).rgb;
return float(p1 == p2)*1000.0; if (m1 == m2 && s1==s2 )
// ^^ we mul by 1000 because glow_y will sample this alpha and will multiplex it with the return 0.0;
// inflation/warp_y value. else
// multiplying by 1000 will allow the final pass to understand if is a deltarender value or an inflation one. return 1.0;
// The number has to be high, to avoid lerp issues.
} }
float max3(vec3 v){ float max3(vec3 v){

View File

@ -1,138 +0,0 @@
#version 450
#include "config.inc"
#define eps 1e-8
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out vec2 vTexCoord_zoom;
#include "functions.include.slang"
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
vTexCoord_zoom = TexCoord;
if (DO_BEZEL==1.0 && BEZEL_INNER_ZOOM !=0.0) vTexCoord_zoom = zoomout_coords(TexCoord, -BEZEL_INNER_ZOOM , 1.0);
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in vec2 vTexCoord_zoom;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Original;
layout(set = 0, binding = 3) uniform sampler2D main_pass;
layout(set = 0, binding = 4) uniform sampler2D isrotated_pass;
bool border_updown(){
//Return if black bars are up and down or left and right.
//Why this one work?
return ((params.OriginalSize.x > params.OriginalSize.y) && (global.main_passSize.x < global.main_passSize.y )) ||
(params.OriginalSize.x < params.OriginalSize.y) && (global.main_passSize.x > global.main_passSize.y ) ;
}
vec3 main_wrap(){
float myborder = 0.025; //20% border to be displaced
vec2 newcoords = vTexCoord_zoom;
vec3 pixel_out;
float mydiv;
float myoffset;
if (!border_updown()) {
mydiv = vTexCoord.x / myborder;
myoffset = (1.0-myborder) * floor(mydiv);
if (vTexCoord.x < 0.5)
newcoords.x = newcoords.x - ( myborder * floor(mydiv) ) ;
else
newcoords.x = (1 - myborder) + ( newcoords.x - (myborder*floor(mydiv)) ) ;
return texture(Original, newcoords).rgb;
}
//Is rotated
mydiv = vTexCoord.y / myborder;
myoffset = (1.0-myborder) * floor(mydiv);
if (vTexCoord.y < 0.5)
newcoords.y = newcoords.y - ( myborder * floor(mydiv) ) ;
else
newcoords.y = (1 - myborder) + ( newcoords.y - (myborder*floor(mydiv)) ) ;
return texture(Original, newcoords).rgb;
}
#include "functions.include.slang"
float mborder(vec2 coord,float aspect,float corner_size, float corner_smooth) {
coord = (coord - vec2(0.5)) + vec2(0.5, 0.5);
coord = min(coord, vec2(1.0) - coord) * aspect;
vec2 cdist = vec2(corner_size);
coord = (cdist - min(coord, cdist));
float dist = sqrt(dot(coord, coord));
return clamp((cdist.x - dist)*corner_smooth, 0.0, 1.0);
}
vec2 bget_scaled_coords(vec2 pTexCoord, vec4 destsize){
if (!border_needed()) return pTexCoord;
//else
float scale_x = 1.0;
float scale_y = 1.0;
float offset_x = 0.0 ;
float offset_y = 0.0 ;
float in_aspect = get_in_aspect();
if (is_rotated()) {
//scale_y = params.OutputSize.y/(params.OutputSize.x / in_aspect );
//scale_y = global.FinalViewportSize.y/(global.FinalViewportSize.x / in_aspect );
scale_y = destsize.y/(destsize.x / in_aspect );
offset_y = (0.5 * scale_y ) - 0.5 ;
} else {
//scale_x = params.OutputSize.x/(params.OutputSize.y * in_aspect);
//scale_x = global.FinalViewportSize.x/(global.FinalViewportSize.y * in_aspect);
scale_x = destsize.x/(destsize.y * in_aspect);
offset_x = (0.5 * scale_x ) - 0.5 ;
}
vec2 scale_coord=vec2(pTexCoord.x*scale_x - offset_x , pTexCoord.y*scale_y - offset_y);
return scale_coord;
}
void main() {
if (DO_AMBILIGHT != 1.0) return;
//bool is_rotated = texture(isrotated_pass,vec2(0.5,0.5)).r > 0.5;
//Disegna un rettangolo sul gioco.
//samplo main_pass per riferimento.
vec4 pixel_Original = texture(Original,vTexCoord);
FragColor = pixel_Original;
/*
float dist = 1-length(vTexCoord-0.5);
FragColor = vec4(main_wrap(),1.0);
float corner_size = 0.25;
float corner_smooth = 4.0;
float zoom = 0.4;
vec2 co = get_scaled_coords(zoomout_coords(vTexCoord, -zoom , 1.0),global.FinalViewportSize);
float ss=pow(mborder(co,1.0,corner_size, corner_smooth),2.0);
//ss = ss * smoothstep(shade_end,shade_start, vTexCoord.x);
FragColor = vec4(ss);
vec2 ccords = get_scaled_coords(vTexCoord,global.FinalViewportSize);
ccords = zoomout_coords(ccords,-BEZEL_INNER_ZOOM,1.0);
//FragColor = texture(Original,ccords)*ss;
*/
}

View File

@ -1,61 +0,0 @@
#version 450
#include "config.inc"
#define eps 1e-8
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out vec2 vOutputCoord;
#include "functions.include"
void main() {
gl_Position = global.MVP * Position;
vTexCoord = get_scaled_coords(TexCoord);
vOutputCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in vec2 vOutputCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D final_pass;
layout(set = 0, binding = 4) uniform sampler2D ambi_temporal_pass;
#include "functions.include"
vec4 pixel_border() {
vec3 ambi = texture(ambi_temporal_pass, vOutputCoord).rgb;
float l = length(ambi);
float sat = 1.25;
float bright = 1.25;
ambi = normalize( pow(ambi.rgb + vec3(eps), vec3(sat)))*l * bright ;
ambi*=bright;
return vec4(ambi,0.0);
}
vec3 ambi_noised() {
return pixel_border().rgb + random();
}
void main() {
vec4 psample = texture(final_pass, vOutputCoord);
if (DO_AMBILIGHT == 1) {
vec3 ambinoised = ambi_noised();
if (is_outer_frame(psample)) {
FragColor = mark_outer_frame(ambi_noised());
} else {
FragColor = vec4(mix(ambinoised.rgb,psample.rgb,min(psample.a*1.5,1.0)),psample.a);
}
} else {
FragColor = psample ;
}
//FragColor = vec4(ambi_noised(), 1.0);
}

View File

@ -1,28 +0,0 @@
#version 450
#include "config.inc"
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
void main() {
if (DO_AMBILIGHT == 1.0)
FragColor = texture(Source, vTexCoord);
else
return;
}

View File

@ -1,33 +0,0 @@
#version 450
/* This pass apply an pre-gain to the leds on the rear of the virtual screen
* it is intended to produce a mipmap to be used by the next pass */
#include "config.inc"
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main() {
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D first_pass;
#include "includes/functions.include.slang"
void main() {
if (DO_AMBILIGHT != 1.0) return;
vec3 pixel_out = texture(first_pass, vTexCoord).rgb;
pixel_out = apply_fuzzy_main_pass(pixel_out);
pixel_out = pixel_push_luminance(pixel_out, AMBI_POWER-1);
FragColor = vec4(pixel_out, 1.0);
}

View File

@ -1,36 +0,0 @@
#version 450
#include "config.inc"
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D main_pass;
void main() {
vec2 coords = vTexCoord;
if (DO_BLOOM == 1) {
if (DO_CURVATURE == 1.0) {
if ((GEOM_WARP_X > 0.0) || (GEOM_WARP_Y > 0.0))
coords = Warp(vTexCoord,GEOM_WARP_X,GEOM_WARP_Y);
}
FragColor = texture(main_pass,coords);
return;
} else {
//No bloom requested
return;
}
}

View File

@ -1,12 +0,0 @@
vec4 blur9(sampler2D image, vec2 uv, vec2 resolution, vec2 direction, float lod) {
vec4 color = vec4(0.0);
vec2 off1 = vec2(1.3846153846) * direction;
vec2 off2 = vec2(3.2307692308) * direction;
color += textureLod(image, uv, lod) * 0.2270270270;
color += textureLod(image, uv + (off1 / resolution), lod) * 0.3162162162;
color += textureLod(image, uv - (off1 / resolution), lod) * 0.3162162162;
color += textureLod(image, uv + (off2 / resolution), lod) * 0.0702702703;
color += textureLod(image, uv - (off2 / resolution), lod) * 0.0702702703;
return color;
}

View File

@ -1,226 +0,0 @@
#version 450
#include "config.inc"
/*
CRT Shader by EasyMode
License: GPL
Modified by kokoko3k, stripped to keep just curvature related code.
*/
#define FIX(c) max(abs(c), 1e-5)
#define PI 3.141592653589
#define TEX2D(c) texture(tex, c)
#define in_texture final_pass
#define in_textureSize final_passSize
//#define in_textureSize SourceSize
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out vec2 vOutputCoord;
#include "functions.include"
void main() {
gl_Position = global.MVP * Position;
vTexCoord = get_scaled_coords(TexCoord);
vOutputCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in vec2 vOutputCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D in_texture;
float curve_distance(float x, float sharp)
{
float x_step = step(0.5, x);
float curve = 0.5 - sqrt(0.25 - (x - x_step) * (x - x_step)) * sign(0.5 - x);
return mix(x, curve, sharp);
}
mat4x4 get_color_matrix(sampler2D tex, vec2 co, vec2 dx)
{
return mat4x4(TEX2D(co - dx), TEX2D(co), TEX2D(co + dx), TEX2D(co + 2.0 * dx));
}
vec4 filter_lanczos(vec4 coeffs, mat4x4 color_matrix)
{
vec4 col = color_matrix * coeffs;
vec4 sample_min = min(color_matrix[1], color_matrix[2]);
vec4 sample_max = max(color_matrix[1], color_matrix[2]);
col = clamp(col, sample_min, sample_max);
return col;
}
vec2 curve_coordinate(vec2 co, float curvature_x, float curvature_y)
{
vec2 curve = vec2(curvature_x, curvature_y);
vec2 co2 = co + co * curve - curve / 2.0;
vec2 co_weight = vec2(co.y, co.x) * 2.0 - 1.0;
co = mix(co, co2, co_weight * co_weight);
return co;
}
float get_corner_weight(vec2 co, vec2 corner, float smoothfunc)
{
float corner_weight;
co = min(co, vec2(1.0) - co) * vec2(1.0, 0.75);
co = (corner - min(co, corner));
corner_weight = clamp((corner.x - sqrt(dot(co, co))) * smoothfunc, 0.0, 1.0);
corner_weight = mix(1.0, corner_weight, ceil(corner.x));
return corner_weight;
}
#define GEOM_ANTIALIAS 1.0
vec3 curve_antialias(vec2 xy,vec2 tex_size){
vec2 midpoint = vec2(0.5, 0.5);
vec2 co = vOutputCoord * tex_size * params.in_textureSize.zw;
vec2 co2 = vTexCoord * tex_size * params.in_textureSize.zw;
vec3 col;
float corner_weight = get_corner_weight(curve_coordinate(co2, GEOM_BORDER_WX, GEOM_BORDER_WY ), vec2(GEOM_CORNER_SIZE), GEOM_CORNER_SMOOTH);
if ( (GEOM_WARP_X > 0) || (GEOM_WARP_Y > 0) ) {
xy *= params.in_textureSize.xy / tex_size;
vec2 dx = vec2(1.0 / tex_size.x, 0.0);
vec2 dy = vec2(0.0, 1.0 / tex_size.y);
vec2 pix_co = xy * tex_size - midpoint;
vec2 tex_co = (floor(pix_co) + midpoint) / tex_size;
vec2 dist = fract(pix_co);
float curve_x, curve_y;
vec3 col2, diff;
curve_x = curve_distance(dist.x, SHARPNESS_H * SHARPNESS_H);
curve_y = curve_distance(dist.y, SHARPNESS_V * SHARPNESS_V);
vec4 coeffs_x = PI * vec4(1.0 + curve_x, curve_x, 1.0 - curve_x, 2.0 - curve_x);
vec4 coeffs_y = PI * vec4(1.0 + curve_y, curve_y, 1.0 - curve_y, 2.0 - curve_y);
coeffs_x = FIX(coeffs_x);
coeffs_x = 2.0 * sin(coeffs_x) * sin(coeffs_x / 2.0) / (coeffs_x * coeffs_x);
coeffs_x /= dot(coeffs_x, vec4(1.0));
coeffs_y = FIX(coeffs_y);
coeffs_y = 2.0 * sin(coeffs_y) * sin(coeffs_y / 2.0) / (coeffs_y * coeffs_y);
coeffs_y /= dot(coeffs_y, vec4(1.0));
mat4x4 color_matrix;
color_matrix[0] = filter_lanczos(coeffs_x, get_color_matrix(in_texture, tex_co - dy, dx));
color_matrix[1] = filter_lanczos(coeffs_x, get_color_matrix(in_texture, tex_co, dx));
color_matrix[2] = filter_lanczos(coeffs_x, get_color_matrix(in_texture, tex_co + dy, dx));
color_matrix[3] = filter_lanczos(coeffs_x, get_color_matrix(in_texture, tex_co + 2.0 * dy, dx));
col = filter_lanczos(coeffs_y, color_matrix).rgb;
} else {
col = texture(in_texture, vOutputCoord).rgb;
}
col *= vec3(corner_weight);
return col;
}
vec2 Warp2(vec2 texCoord){
vec2 curvedCoords = texCoord * 2.0 - 1.0;
vec2 CRT_Distortion = vec2(GEOM_WARP_X, GEOM_WARP_Y) * 15.;
float curvedCoordsDistance = sqrt(curvedCoords.x*curvedCoords.x+curvedCoords.y*curvedCoords.y);
curvedCoords = curvedCoords / curvedCoordsDistance;
curvedCoords = curvedCoords * (1.0-pow(vec2(1.0-(curvedCoordsDistance/1.4142135623730950488016887242097)),(1.0/(1.0+CRT_Distortion*0.2))));
curvedCoords = curvedCoords / (1.0-pow(vec2(0.29289321881345247559915563789515),(1.0/(vec2(1.0)+CRT_Distortion*0.2))));
curvedCoords = curvedCoords * 0.5 + 0.5;
return curvedCoords;
}
vec3 do_curvature_antialias(){
vec2 tex_size = params.in_textureSize.xy ;
vec2 co = vOutputCoord * tex_size * params.in_textureSize.zw;
vec2 co2 = vTexCoord * tex_size * params.in_textureSize.zw;
vec2 curved_xy = curve_coordinate(co, GEOM_WARP_X,GEOM_WARP_Y );
vec3 col;
//float corner_weight = get_corner_weight(curve_coordinate(co2, GEOM_BORDER_WX, GEOM_BORDER_WY ), vec2(GEOM_CORNER_SIZE), GEOM_CORNER_SMOOTH);
float corner_weight = get_corner_weight(Warp2(co), vec2(GEOM_CORNER_SIZE), GEOM_CORNER_SMOOTH);
if ( (GEOM_WARP_X > 0) || (GEOM_WARP_Y > 0) ) {
if (GEOM_ANTIALIAS == 1.0)
col = curve_antialias(curved_xy,tex_size);
else
col = texture(in_texture,curved_xy).rgb;
} else {
col = texture(in_texture, vOutputCoord).rgb;
}
col *= vec3(corner_weight) ;
return col;
}
const vec2 corner_aspect = vec2(1.0, 0.75);
float corner2(vec2 coord)
{
coord = (coord - vec2(0.5)) + vec2(0.5, 0.5);
coord = min(coord, vec2(1.0) - coord) * corner_aspect;
vec2 cdist = vec2(GEOM_CORNER_SIZE);
coord = (cdist - min(coord, cdist));
float dist = sqrt(dot(coord, coord));
return clamp((cdist.x - dist)*GEOM_CORNER_SMOOTH, 0.0, 1.0);
}
vec3 do_curvature_alias(){
vec2 curved_xy = Warp2(vOutputCoord);
return texture(in_texture,curved_xy ).rgb * corner2(curved_xy);
}
vec4 main_wrap()
{
if (DO_CURVATURE == 1.0) {
return vec4(do_curvature_antialias(), 1.0);
} else {
return texture(in_texture, vOutputCoord);
}
}
#include "functions.include"
void main() {
vec4 psample = texture(in_texture, vOutputCoord);
if ( border_needed() ) {
if (is_outer_frame(psample))
FragColor = mark_outer_frame(vec3(0.0));
else
FragColor = main_wrap();
} else {
FragColor = main_wrap();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,59 +0,0 @@
#version 450
#include "config.inc"
#define pi 3.141592654
// Blur sizes must not depend on input resolution
#define scalemod_x (global.in_glow_passSize.x/360.0)
#define scalemod_y (global.in_glow_passSize.y/270.0)
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out vec2 vOutputCoord;
void main() {
gl_Position = global.MVP * Position;
//vTexCoord = get_scaled_coords(TexCoord);
vTexCoord = TexCoord;
vOutputCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in vec2 vOutputCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D FXAA_pass;
layout(set = 0, binding = 3) uniform sampler2D first_pass;
layout(set = 0, binding = 4) uniform sampler2D in_glow_pass;
layout(set = 0, binding = 5) uniform sampler2D shift_and_bleed_pass;
#include "includes/pixel_glows.include.slang"
vec4 main_wrap(void) {
//Halo
vec3 pixel_haloed;
vec2 halo_coords = vTexCoord;
if (DO_IN_GLOW == 1.0)
pixel_haloed = pixel_glow(in_glow_pass, HALO_W, HALO_H, HALO_POWER, HALO_GAMMA, halo_coords, global.FXAA_passSize, global.FXAA_passSize).rgb;
else if ( DO_SHIFT_RGB + DO_SAT_BLEED > 0.0)
pixel_haloed = pixel_glow(shift_and_bleed_pass, HALO_W, HALO_H, HALO_POWER, HALO_GAMMA, halo_coords, global.FXAA_passSize, global.FXAA_passSize).rgb;
else if (DO_FXAA > 0.0)
pixel_haloed = pixel_glow(FXAA_pass, HALO_W, HALO_H, HALO_POWER, HALO_GAMMA, halo_coords, global.FXAA_passSize, global.FXAA_passSize).rgb;
else
pixel_haloed = pixel_glow(first_pass, HALO_W, HALO_H, HALO_POWER, HALO_GAMMA, halo_coords, global.FXAA_passSize, global.FXAA_passSize).rgb;
return vec4(pixel_haloed.rgb,1.0);
}
void main() {
if (DO_HALO == 0.0 ) return;
FragColor = main_wrap();
}

View File

@ -1,126 +0,0 @@
#version 450
#include "config.inc"
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main() {
gl_Position = global.MVP * Position;
vTexCoord = TexCoord ;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 3) uniform sampler2D FXAA_pass;
layout(set = 0, binding = 4) uniform sampler2D first_pass;
layout(set = 0, binding = 5) uniform sampler2D shift_and_bleed_pass;
// Blur sizes must not depend on input resolution
#define scalemod_x (params.OutputSize.x/360.0)
#define scalemod_y (params.OutputSize.y/270.0)
#include "includes/pixel_glows.include.slang"
vec3 glow_blur_bias_smother_bloomer(sampler2D source_tex, vec2 co, vec3 pixel_glowed, float bias) {
//Modulates the mix of the blurred version over the sharp one
//by the luminosity difference of the blurred version and the original
vec3 pixel_original = texture(source_tex,vTexCoord).rgb;
vec3 pixel_sharp = pow(pixel_original,vec3(IN_GLOW_GAMMA)) * IN_GLOW_POWER;
vec3 pixel_glowed_c = clamp(pixel_glowed, 0.0, 1.0);
vec3 pixel_sharp_c = clamp(pixel_sharp, 0.0, 1.0);
vec3 vmix = vec3( pixel_glowed_c.r - pixel_original.r,
pixel_glowed_c.g - pixel_original.g,
pixel_glowed_c.b - pixel_original.b);
vmix += IN_GLOW_BIAS;
vmix = clamp(vmix, 0.0, 1.0);
vmix *= vmix;
return mix(pixel_sharp, pixel_glowed, vmix );
//return mix(pixel_sharp, pixel_glowed, clamp( (vmix+0.01 * vInGlowBias) , 0.0,1.0) );
//return pixel_sharp + pixel_glowed*clamp( (vmix+0.01 * vInGlowBias) , 0.0,1.0);
}
vec3 glow_blur_bias_sharper_AA(sampler2D source_tex, vec2 co, vec3 pixel_glowed, float bias) {
//from latitude. with pow.
vec3 pixel_source = texture(source_tex, co).rgb;
pixel_source = pow(pixel_source,vec3(IN_GLOW_GAMMA)) * IN_GLOW_POWER;
float glowlum = max(max(pixel_glowed.r, pixel_glowed.g), pixel_glowed.b);
float orilum = max(max(pixel_source.r, pixel_source.g), pixel_source.b);
glowlum = clamp(glowlum, 0.0, 1.0);
orilum = clamp(orilum, 0.0, 1.0);
float g_mix = (glowlum - orilum);
g_mix += IN_GLOW_BIAS;
g_mix = clamp(g_mix, 0.0, 1.0);
g_mix *= g_mix ;
return mix(pixel_source, pixel_glowed, g_mix);
}
vec3 glow_blur_bias(sampler2D source_tex, vec2 co, vec3 pixel_glowed, float bias){
vec3 pixel_source = texture(source_tex, co).rgb;
pixel_source = pow(pixel_source,vec3(IN_GLOW_GAMMA)) * IN_GLOW_POWER;
vec3 glow_light = clamp((pixel_glowed - pixel_source) * IN_GLOW_SPREAD, 0.0, 1.0);
/* powering glow_light is fine when not dealing with scanline minimum thickness,
* but then the scanline shape gets smaller, it kinda produces a visive
* pow(x,2) by its own; in that case powering glow_light make things worse.
* It makes sense, because we are emulating the light spread twice.
* FIXME: How to deal with this?
*/
vec3 proper_glow = glow_light * glow_light + pixel_source;
return mix(proper_glow, pixel_glowed, max(0.0, bias));
/*if (IN_GLOW_W < 0.99)
return glow_blur_bias_sharper_AA( source_tex, co, pixel_glowed, bias);
else
return glow_blur_bias_smother_bloomer( source_tex, co, pixel_glowed, bias);
*/
}
void main() {
if (DO_IN_GLOW == 0.0) return;
vec3 pixel_glowed;
if ( DO_SHIFT_RGB + DO_SAT_BLEED > 0.0) {
pixel_glowed = pixel_glow(shift_and_bleed_pass, IN_GLOW_W, IN_GLOW_H, IN_GLOW_POWER, IN_GLOW_GAMMA, vTexCoord, params.OutputSize, params.OutputSize).rgb;
if (IN_GLOW_BIAS < IN_GLOW_BIAS_MAX && (IN_GLOW_W < GLOW_SHARP_MAX || IN_GLOW_H < GLOW_SHARP_MAX) )
pixel_glowed = glow_blur_bias(shift_and_bleed_pass, vTexCoord, pixel_glowed, IN_GLOW_BIAS);
}
else if (DO_FXAA > 0.0) {
pixel_glowed = pixel_glow(FXAA_pass, IN_GLOW_W, IN_GLOW_H, IN_GLOW_POWER, IN_GLOW_GAMMA, vTexCoord, params.OutputSize, params.OutputSize).rgb;
if (IN_GLOW_BIAS < IN_GLOW_BIAS_MAX && (IN_GLOW_W < GLOW_SHARP_MAX || IN_GLOW_H < GLOW_SHARP_MAX) )
pixel_glowed = glow_blur_bias(FXAA_pass, vTexCoord, pixel_glowed, IN_GLOW_BIAS);
}
else {
pixel_glowed = pixel_glow(first_pass, IN_GLOW_W, IN_GLOW_H, IN_GLOW_POWER, IN_GLOW_GAMMA, vTexCoord, params.OutputSize, params.OutputSize).rgb;
if (IN_GLOW_BIAS < IN_GLOW_BIAS_MAX && (IN_GLOW_W < GLOW_SHARP_MAX || IN_GLOW_H < GLOW_SHARP_MAX) )
pixel_glowed = glow_blur_bias(first_pass, vTexCoord, pixel_glowed, IN_GLOW_BIAS);
}
FragColor = vec4((pixel_glowed),1.0);
}

View File

@ -1,33 +0,0 @@
#version 450
#include "config.inc"
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out float mark_color_rotated;
#include "includes/functions.include.slang"
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
if (is_rotated())
mark_color_rotated = 1.0;
else
mark_color_rotated = 0.0;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in float mark_color_rotated;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
void main() {
FragColor.r = mark_color_rotated;
}

View File

@ -1,323 +0,0 @@
#version 450
#include "config.inc"
#define half_pi 1.5707963267949
// RGB mask: R G B
#define m1 vec3 ( 1.0 , 0.0 , 0.0 ) //col 1
#define m2 vec3 ( 0.0 , 1.0 , 0.0 ) //col 2
#define m3 vec3 ( 0.0 , 0.0 , 1.0 ) //col 3
// RGB mask low dpi (green-magenta, exploiting native rgb subpixels)
#define m1gm vec3 ( 0.0 , 1.0 , 0.0 ) //col 1
#define m2gm vec3 ( 1.0 , 0.0 , 1.0 ) //col 2
// Blur sizes must not depend on input resolution
#define scalemod_x (global.in_glow_passSize.x/360.0)
#define scalemod_y (global.in_glow_passSize.y/270.0)
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out vec2 vOutputCoord;
#include "includes/functions.include.slang"
void main() {
gl_Position = global.MVP * Position;
vTexCoord = get_scaled_coords(TexCoord,global.FinalViewportSize, is_rotated());
vOutputCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in vec2 vOutputCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 3) uniform sampler2D FXAA_pass;
layout(set = 0, binding = 4) uniform sampler2D in_glow_pass;
layout(set = 0, binding = 5) uniform sampler2D halo_pass;
layout(set = 0, binding = 6) uniform sampler2D first_pass;
layout(set = 0, binding = 7) uniform sampler2D avglum_passFeedback;
#include "includes/functions.include.slang"
vec3 pixel_vmask(vec3 source, vec3 white_reference, float over_white) {
int col = int( vOutputCoord.x * params.OutputSize.x );
vec3 pixel_out;
vec3 vmasked;
vec4 vec_mod=(vec4(3,1,2,3) + vec4(VMASK_GAP,0.0,0.0,0.0))* VMASK_DARKLINE_SCALE ;
float mask_lightness = 1.0 - RGB_MASK_STRENGTH;
if ( mod(col, vec_mod.x) < vec_mod.y) vmasked = min(m1 + mask_lightness,vec3(1.0)) * source;
else if (mod(col, vec_mod.x) < vec_mod.z) vmasked = min(m2 + mask_lightness,vec3(1.0)) * source;
else if (mod(col, vec_mod.x) < vec_mod.w) vmasked = min(m3 + mask_lightness,vec3(1.0)) * source;
else vmasked = min(vec3(0.0) + mask_lightness,vec3(1.0)) * source;
if (over_white == 1.0) pixel_out = vmasked;
else {
float whiteness=(white_reference.r+white_reference.g+white_reference.b)/3.0;
whiteness-= over_white;
whiteness= clamp(whiteness,0.0,1.0);
pixel_out= mix(vmasked,source,whiteness);
}
return pixel_out;
}
vec3 pixel_vmask_gm(vec3 source, vec3 white_reference, float over_white) {
int col = int( vOutputCoord.x * params.OutputSize.x );
vec3 pixel_out;
vec3 vmasked;
vec3 vec_mod=(vec3(2,1,2) + vec3(VMASK_GAP,0.0,0.0))* VMASK_DARKLINE_SCALE ;
float mask_lightness = 1.0 - RGB_MASK_STRENGTH;
if (mod(col, vec_mod.x) < vec_mod.y) vmasked = min(m1gm + mask_lightness,vec3(1.0)) * source;
else if (mod(col, vec_mod.x) < vec_mod.z) vmasked = min(m2gm + mask_lightness,vec3(1.0)) * source;
else vmasked = min(vec3(0.0) + mask_lightness,vec3(1.0)) * source;
if (over_white == 1.0) pixel_out = vmasked;
else {
float whiteness=(white_reference.r+white_reference.g+white_reference.b)/3.0;
whiteness-= over_white;
whiteness= clamp(whiteness,0.0,1.0);
pixel_out= mix(vmasked,source,whiteness);
}
return pixel_out;
}
vec3 pixel_darklines(vec3 source,float darkline_every, float darkline_trans,
float do_offset, vec3 white_reference,float over_white) {
float Darkline_part_w = (3.0 - VMASK_USE_GM + VMASK_GAP) * VMASK_DARKLINE_SCALE;
float Darkline_part_w_x2 = Darkline_part_w*2;
//vec3 pixel_out=source;
float col_2 = vOutputCoord.x * params.OutputSize.x;
float line_2 = vOutputCoord.y * params.OutputSize.y;
darkline_every *= VMASK_DARKLINE_SCALE;
if (over_white != 1.0) {
//less effect on bright colors.
float whiteness=(white_reference.r+white_reference.g+white_reference.b)/3.0;
darkline_trans+=(whiteness-over_white);
darkline_trans=clamp(darkline_trans,0.0,1.0);
}
if (do_offset == 1.0) {
if (int(mod(line_2, darkline_every)) < VMASK_DARKLINE_SCALE) {
if (int(mod(col_2, Darkline_part_w_x2)) < Darkline_part_w) return source * darkline_trans;
} else if (int(mod(line_2+(darkline_every/2), darkline_every)) < VMASK_DARKLINE_SCALE ) {
// DRAW WITH OFFSET:
col_2+=Darkline_part_w;
if ((int(mod(col_2, Darkline_part_w_x2))) < Darkline_part_w)
return source * darkline_trans;
}
} else {
if ( darkline_every >= 0.0)
if (int(mod(line_2, darkline_every)) < VMASK_DARKLINE_SCALE) return source * darkline_trans;
}
return source;
}
/*
float scanline_shape_static_in_lum(vec2 coords, float in_luminance) {
// Modulate scanline weight via in_luminance
float period = (params.OriginalSize.y > MIN_LINES_INTERLACED ) ? 2 : 1 ;
float angle = coords.y * pi * period * params.OriginalSize.y ;
float lines = abs(sin(angle));
lines=clamp(lines, SCANLINE_DARK,1.0);
lines = (lines*lines);
float w = (SCANLINES_BLEEDING * 9.0 * in_luminance +1 ); // + SCANLINES_BLEEDING;
lines = pow(lines,1.0/ w );
return lines;
}
*/
/*
float scanline_shape_dumb(vec2 coords, bool do_flicker) {
float source_dy = global.first_passSize.w ;
if ( mod(coords.y, source_dy*2) < source_dy ) {
return 1.0;
}
return 0.0;
}
*/
float scanline_shape(vec2 coords, bool do_flicker) {
bool alternate = false;
float period = 1.0;
int slow = 1;
if (do_flicker) {
if (params.FrameCount/slow % 2 == 0.0) alternate = true;
if (params.OriginalSize.y > MIN_LINES_INTERLACED ) period = 0.5;
}
float angle = coords.y * pi * params.OriginalSize.y * period;
float lines;
if (alternate)
lines = -sin(angle+half_pi); //lines = abs(cos(angle));
else
lines = sin(angle);
lines = (lines*lines);
if (SCANLINE_DARK >= 0.0) {
lines = lines * (1.0 - SCANLINE_DARK) + SCANLINE_DARK;
} else {
float deepness = -SCANLINE_DARK;
lines = lines * ((1-SCANLINE_DARK) ) + SCANLINE_DARK ;
}
return lines;
}
vec4 main_wrap(vec2 co) {
bool isinterlaced = is_interlaced();
bool flickering_scanlines = (DO_SCANLINES == 1.0) && scanline_have_to_flicker(isinterlaced) ;
vec3 pixel_in;
vec3 pixel_glowed;
//Get the first available pixel_in:
if (DO_IN_GLOW == 1.0) {
pixel_glowed = texture(in_glow_pass,co).rgb;
pixel_in = pixel_glowed;
}
else if (DO_FXAA == 1.0)
pixel_in = texture(FXAA_pass,co).rgb ;
else
pixel_in = texture(first_pass,co).rgb ;
vec3 pixel_out = pixel_in;
vec3 pixel_in_clamped = min(pixel_in,vec3(1.0)); //Clamp here for moth vmask and darklines.
//Mask and darklines:
if (DO_VMASK_AND_DARKLINES == 1.0 ) {
if (RGB_MASK_STRENGTH > 0.0) {
//Use RGB pattern or exploit RGB layout with green and magenta?
if (VMASK_USE_GM < 1.0) {
pixel_out = pixel_vmask(pixel_in, pixel_in_clamped, VMASK_OVERWHITE);
} else {
pixel_out = pixel_vmask_gm(pixel_in, pixel_in_clamped, VMASK_OVERWHITE);
}
}
//Screen lines
if (DARKLINES_STRENGTH > 0.0 ) {
float MYDARKLINES_TRANSPARENCY = 1.0 - DARKLINES_STRENGTH;
pixel_out = pixel_darklines(pixel_out,DARKLINES_PERIOD,MYDARKLINES_TRANSPARENCY,DO_DARKLINES_VOFFSET,pixel_in_clamped,DRKLN_OVERWHITE);
}
}
//Halo
vec3 pixel_haloed;
if (DO_HALO == 1.0 ) {
pixel_haloed = texture(halo_pass,co).rgb;
pixel_out += pixel_haloed;
pixel_out = clamp(pixel_out,0.0,HALO_CLAMP);
}
// Non flickering scanlines
if ( DO_SCANLINES == 1.0 ) {
vec3 pixel_bleed ;
if (! ( isinterlaced && (SCANLINE_DISABLE_ON_INTERLACE == 1.0)) ) {
if (DO_IN_GLOW + DO_HALO > 0.0) {
if (DO_HALO == 1.0) pixel_bleed = pixel_haloed;
else if (DO_IN_GLOW == 1.0) pixel_bleed = pixel_glowed;
else pixel_bleed = pixel_in;
}
float scanline_shape = scanline_shape(co, flickering_scanlines ) ;
vec3 pixel_scanlined = scanline_shape * pixel_out;
pixel_out = pixel_scanlined + (pixel_out * pixel_bleed * SCANLINES_BLEEDING * (1-scanline_shape));
}
}
if (DO_CCORRECTION == 1.0) pixel_out = pow(pixel_out,vec3(GAMMA_OUT));
//Out
return vec4(pixel_out,1.0) ; //* border(border_coords);
}
/*
//Test masks to be used with pixel_vmask_test()
// Actually slower than pixel_vmask(), but handy for quick test
//first element of the array is the useful size.
const vec3 oo = vec3(0); //padding
const vec3 mask_RGB[10] = vec3[]( vec3(3), vec3(1,0,0), vec3(0,1,0), vec3(0,0,1), oo, oo, oo, oo, oo, oo);
const vec3 mask_GM[10] = vec3[]( vec3(2), vec3(0,1,0), vec3(1,0,1), oo, oo, oo, oo, oo, oo, oo);
vec3 pixel_vmask_test(vec3 color_in, vec3[10] vmask, int multiplier, float gap, vec3 white_reference, float over_white) {
int col = int( vOutputCoord.x * params.OutputSize.x );
vec3 vmasked;
float size = (vmask[0].x + gap) * multiplier;
for (int i = multiplier ; i <= size * multiplier ; i+=multiplier) {
if (mod(col, size) < i) {
vmasked = min (vmask[i/multiplier] + 1.0 - RGB_MASK_STRENGTH, vec3(1.0)) * color_in;
break;
}
}
if (over_white == 1.0) return vmasked;
else {
float whiteness=(white_reference.r+white_reference.g+white_reference.b)/3.0;
whiteness-= over_white;
whiteness= clamp(whiteness,0.0,1.0);
return mix(vmasked, color_in, whiteness);
}
}
*/
void main() {
vec2 coords = vTexCoord;
if (DO_DYNZOOM == 1.0) {
float zoomin = 1.0 + (texture(avglum_passFeedback, vec2(0.25,0.25) ).a/ DYNZOOM_FACTOR);
coords = zoom(vTexCoord, zoomin);
}
vec2 coords_curved = coords;
//Curvature: set coords_curved coordinate: (global var)
if (DO_CURVATURE == 1.0) {
if ((GEOM_WARP_X > 0.0) || (GEOM_WARP_Y > 0.0))
coords_curved = Warp(coords_curved,GEOM_WARP_X,GEOM_WARP_Y);
}
if (DO_BEZEL == 1.0) {
coords_curved = zoomout_coords(coords_curved, -BEZEL_INNER_ZOOM , 1.0);
coords = zoomout_coords(coords, -BEZEL_INNER_ZOOM , 1.0);
}
//FIXME: bezel may need a wider border when zoomed in.
//But for performance reasons we can wide the border in relation to the desidered reflection area.
//by now, just wide by BEZEL_REFLECTION_AREA_SIZE defined in config.inc
bool is_border = false;
if (border_needed()) {
float WIDEN = DO_BEZEL * BEZEL_REFLECTION_AREA_SIZE;
bool b_is_rotated = is_rotated();
bool is_outside_x = ((coords.x > 1.0+WIDEN ) || (coords.x < 0.0 - WIDEN) );
bool is_outside_y = ((coords.y > 1.0+WIDEN ) || (coords.y < 0.0 - WIDEN) );
is_border = (b_is_rotated && is_outside_y) || (!b_is_rotated && is_outside_x);
}
if (is_border)
FragColor = mark_outer_frame(vec3(0.0));
else
FragColor = main_wrap(coords_curved);
}

View File

@ -1,25 +0,0 @@
#version 450
#include "../config.inc"
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
void main() {
FragColor = texture(Source, vTexCoord);
}

View File

@ -1,36 +0,0 @@
#version 450
#include "config.inc"
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Original;
void main() {
FragColor = vec4(texture(Original, vTexCoord).xyz,1.0);
/* //Use to debug:
vec4 pixel;
//pixel=vec4(abs(sin(params.FrameCount/3.14/20))); //white fade
//pixel=vec4(abs(sin(params.FrameCount/3.14/20)),0.0,0.0,0.0); //red fade
//pixel=vec4(0.2);
if (mod(params.FrameCount,100) == 0.0) {
pixel = vec4(0.6);
} else {
pixel = vec4(0.0);
}
FragColor = pixel;
*/
}

View File

@ -1,59 +0,0 @@
vec3 pow_2(vec3 v) {
return v*v*v;
}
vec3 pow_3(vec3 v) {
return v*v*v;
}
vec3 pow_4(vec3 v) {
vec3 v2 = v*v;
return v2*v2;
}
vec3 pow_5(vec3 v) {
vec3 v2 = v*v;
return v2*v2*v;
}
vec3 pow_6(vec3 v) {
vec3 v2 = v*v;
return v2*v2*v2;
}
vec3 pow_7(vec3 v) {
vec3 v2 = v*v;
return v2*v2*v2*v;
}
vec3 pow_8(vec3 v) {
vec3 v2 = v*v;
vec3 v4 = v2*v2;
return v4*v4;
}
vec3 pow_9(vec3 v) {
vec3 v2 = v*v;
vec3 v4 = v2*v2;
return v4*v4*v;
}
vec3 pow_10(vec3 v) {
vec3 v2 = v*v;
vec3 v4 = v2*v2;
return v4*v4*v2;
}
vec3 my_pow(vec3 c,float p) {
if (p == 1) return c;
else if (p == 2) return c * c ;
else if (p == 3) return pow_3(c);
else if (p == 4) return pow_4(c);
else if (p == 5) return pow_5(c);
else if (p == 6) return pow_6(c);
else if (p == 7) return pow_7(c);
else if (p == 8) return pow_8(c);
else if (p == 9) return pow_9(c);
else if (p == 10) return pow_10(c);
return pow(c,vec3(p));
}

View File

@ -1,264 +0,0 @@
#version 450
#include "config.inc"
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 1) out vec2 vWarp_vexp;
layout(location = 2) out vec2 vWarp_arg2;
layout(location = 0) out vec2 vTexCoord;
#include "includes/functions.include.slang"
void main() {
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
//Precalc some Curvature/Warp values:
vWarp_vexp = 1.0/ (1 + (vec2(GEOM_WARP_X, GEOM_WARP_Y) * 0.2)) ;
vWarp_arg2 = 1.0 - pow(vec2(0.29289321881345247559915563789515), vWarp_vexp );
if (DO_BEZEL > 0.5)
vTexCoord = zoom(TexCoord, BEZEL_REFL_ZOOM + (BEZEL_REFL_ZOOM_STRAIGHT_OFFSET * BEZEL_USE_STRAIGHT) );
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in vec2 vWarp_vexp;
layout(location = 2) in vec2 vWarp_arg2;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 1) uniform sampler2D first_pass;
layout(set = 0, binding = 2) uniform sampler2D avglum_pass;
#define SourceTexture first_pass
#define SourceTextureSize global.first_passSize
#include "includes/functions.include.slang"
#define c_tolerance 0.051
vec3 texture_clamp_to_border(sampler2D tex, vec2 coords, float lod) {
//This emulates clamp to border:
if (coords.x < 0.0 || coords.x > 1.0 || coords.y < 0.0 || coords.y > 1.0)
return vec3(0.0);
else
return textureLod( tex, coords, lod).rgb ;
}
vec3 blur_unroll_clamp_to_border(float Size, vec2 co, float lod) {
//Blur the image along x axis and emulate a clamp_to_border when outside the [0..1] range
Size = Size * NEW_SCALEMOD_X; //<- so that blur size doesn't depend on output resolution
vec3 color;
vec2 d = SourceTextureSize.zw * Size;
color = texture_clamp_to_border( SourceTexture, co + d * vec2(-1.0, 1.0 ) ,lod).rgb;
color += texture_clamp_to_border( SourceTexture, co + d * vec2( 1.0, 1.0 ) ,lod).rgb;
color += texture_clamp_to_border( SourceTexture, co + d * vec2(-1.0, -1.0 ) ,lod).rgb;
color += texture_clamp_to_border( SourceTexture, co + d * vec2( 1.0, -1.0 ) ,lod).rgb;
return color / 4.0;
}
vec3 blur_unroll(float Size, vec2 co, float lod) {
//Blurs the image along x axis
Size = Size * NEW_SCALEMOD_X; //<- so that blur size doesn't depend on output resolution
vec3 color;
vec2 d = SourceTextureSize.zw * Size;
color = textureLod( SourceTexture, co + d * vec2(-1.0, 1.0 ) ,lod).rgb;
color += textureLod( SourceTexture, co + d * vec2( 1.0, 1.0 ) ,lod).rgb;
color += textureLod( SourceTexture, co + d * vec2(-1.0, -1.0 ) ,lod).rgb;
color += textureLod( SourceTexture, co + d * vec2( 1.0, -1.0 ) ,lod).rgb;
return color / 4.0;
}
vec2 mirrored_repeat(vec2 co, vec2 crop) {
//Do a coords mirrored repeat with the mirror axis
//shifted by a "crop" amount.
//Don't try to unbranch me, it is a matter of 1/1000.
vec2 cmin = 0.0 + crop ;
vec2 cmax = 1.0 - crop ;
if (co.x < cmin.x )
co.x = 2*cmin.x - co.x;
if (co.y < cmin.y)
co.y = 2*cmin.y - co.y;
if (co.x > cmax.x )
co.x = 2*cmax.x - co.x;
if (co.y > cmax.y )
co.y = 2*cmax.y - co.y;
return co;
}
float circle_smooth(vec2 coords, vec2 middle, float f_radius, float FALLOFF) {
//Draw a circle with smoothed borders:
float fdistance=distance(middle, vec2(coords.x, coords.y));
float circle = (1-smoothstep(f_radius-FALLOFF, f_radius+FALLOFF, fdistance));
return circle;
}
float square_smooth(vec2 co, vec2 corner, float size, float smoothshade) {
//Draws a square with smooth borders:
vec4 rect = vec4(corner.x, corner.y, corner.x+size, corner.y+size);
vec2 hv = smoothstep(rect.xy - smoothshade, rect.xy, co) * smoothstep(co - smoothshade, co, rect.zw);
return hv.x * hv.y;
}
float corners_shade(vec2 co, float size, float smoothsize){
//Draws 4 smooth squares or circles in the corners.
//They are intended to modulate the blur radius and the strength of the reflection.
/*
vec4 circles;
float circle_radius = size; //0.13?
float circle_falloff = smoothsize; //0.05?
float circle_power =2.0;
circles.x = circle_smooth(co, vec2(0.0,0.0), circle_radius, circle_falloff) * circle_power;
circles.y = circle_smooth(co, vec2(0.0,1.0), circle_radius, circle_falloff) * circle_power;
circles.z = circle_smooth(co, vec2(1.0,0.0), circle_radius, circle_falloff) * circle_power;
circles.w = circle_smooth(co, vec2(1.0,1.0), circle_radius, circle_falloff) * circle_power;
float circle = max(max(max(circles.x, circles.y), circles.z), circles.w);
circle = min(circle, 1.0);
circle = 1-circle;
return circle;
*/
vec4 squares;
float squaresize = size;
float squarefade = smoothsize;
//(vec2 co, vec2 corner, float size, float smoothshade) {
squares.x = square_smooth(co, vec2(0.0,0.0), squaresize, squarefade);
squares.y = square_smooth(co, vec2(1.0 - squaresize, 0.0), squaresize, squarefade);
squares.z = square_smooth(co, vec2(0.0, 1-squaresize), squaresize, squarefade);
squares.w = square_smooth(co, vec2(1-squaresize, 1-squaresize), squaresize, squarefade);
return max(max(max(squares.x, squares.y), squares.z), squares.w);
}
float borders_gradient(vec2 co, vec2 foffset) {
// Create a b/w shade near the borders that will be used to
// Modulate from sharp reflections to blur reflections.
vec4 shades;
shades.x = abs( co.x - foffset.x );
shades.y = abs( 1 - co.x - foffset.x );
shades.z = abs( co.y - foffset.y );
shades.w = abs( 1 - co.y - foffset.y );
return min(min(min(shades.x, shades.y), shades.z), shades.w);
}
bool is_void_area(vec2 co, vec2 crop_point) {
// Given a coordinate and a negative crop_point,
// this returns if the point falls into an blank area
return (co.y < 0.0 && co.y > crop_point.y*2) || (co.y > 1.0 && co.y < 1 - crop_point.y*2) ||
(co.x < 0.0 && co.x > crop_point.x*2) || (co.x > 1.0 && co.x < 1 - crop_point.x*2);
}
void main() {
if (DO_BEZEL == 0.0) return;
//Zoom out the image coordinates by the bezel border size to make room for reflections:
vec2 coords = zoomout_coords(vTexCoord, BEZEL_BORDER_SIZE, 1.0);
vec2 coords_zoomedout = coords;
//This skip condition will be used to speed-up processing by discarding unuseful pixels.
//the c_tolerance parameter is a safe measure /FIXME: for what?
bool skip_condition = (coords.x < 1.0 - c_tolerance && coords.x > c_tolerance &&
coords.y < 1.0 - c_tolerance && coords.y > c_tolerance ) ;
//Mark the pixel as not useful, so that the next pass will be aware of it and skip rendering too:
if (skip_condition) {
FragColor = mark_useless(vec3(0.0));
return;
}
//If coords needs to be curved, do it now:
if (DO_CURVATURE == 1.0 && ( GEOM_WARP_X > 0.0 || GEOM_WARP_Y > 0.0) ) {
coords = Warp_fast(coords, vWarp_vexp, vWarp_arg2); //coords_curved = Warp(coords_curved,GEOM_WARP_X,GEOM_WARP_Y);
}
//Since we will use a mirrored_repeat trick to simulate reflections, we need to know
//where the mirror axis is.
//The mirror axis position may depend on the dynamic zoom level
//(the feature that zooms the image in when it is bright)
vec2 coords_crop_point = vec2(0.0);
if (DO_DYNZOOM == 1.0) {
//Crop coordinates to move the mirror axes
float dyn_zoom = get_dyn_zoom(avglum_pass);
coords_crop_point = vec2((dyn_zoom - 1.0) * 0.5);
//Zoom image coords to align it
coords = zoom(coords, dyn_zoom);
}
coords_crop_point += BEZEL_RFL_OFFSET; // <- Adding the user offset
//Mirror repeat the image by taking the crop point (mirror axis offset) into account:
vec2 coords_for_mirrored_repeat = coords;
/* float test_zoom_y = 0.5;
coords_for_mirrored_repeat = vec2(coords.x, zoom1D(coords.y, test_zoom_y));
if (test_zoom_y < 1.0)
coords_crop_point.y += - ( (1.0/(4*test_zoom_y) ) - (1.0/4.0) );
else
coords_crop_point.y += ( test_zoom_y - 1.0) * 0.5;
*/
coords = mirrored_repeat(coords_for_mirrored_repeat, coords_crop_point);
//Create gradients in the corners to fadeout reflections and to blur more near them:
float fcorners_shade = corners_shade(vTexCoord, BEZEL_REFL_CORNER_BLANK_SIZE, BEZEL_REFL_CORNER_BLANK_SHADE);
//Create a gradient near borders to modulate between blurrend and sharp refection.
//This also goes into output alpha channel to make the next pass aware of it.
float shade_sharp_blur = borders_gradient(coords, coords_crop_point);
shade_sharp_blur = shade_sharp_blur * 1/(BEZEL_BORDER_SIZE * 0.3) ;
shade_sharp_blur = shade_sharp_blur - BEZEL_RFL_BLR_SHD; //Modulates between sharp and blur via user parameter
//Also modulate in the corners via fcorners_shade (fcorners_shade
shade_sharp_blur = max(fcorners_shade, shade_sharp_blur);
//Clamp to min 0.01 because anything lower will cause the next pass to think the pixel is useless.
shade_sharp_blur = max(shade_sharp_blur, 0.01);
//shade_sharp_blur = clamp(shade_sharp_blur, 0.01, 1.0);
//blur the reflection along x axis:
vec3 pixel_out;
if ( !is_void_area(coords_for_mirrored_repeat, coords_crop_point) ) {
float lod0 = floor(shade_sharp_blur*3.0);
float lod1 = lod0 + 1;
vec3 s1 = textureLod( SourceTexture, coords, lod0).rgb;
vec3 s2 = textureLod( SourceTexture, coords, lod1).rgb;
float lodmix = fract(shade_sharp_blur*3.0);
pixel_out = mix(s1, s2, lodmix);
pixel_out = textureLod( SourceTexture, coords, shade_sharp_blur*3.0).rgb;
//pixel_out = blur_unroll(BEZEL_REFL_BLUR_MAX * shade_sharp_blur, coords, shade_sharp_blur*3.0 );
}
else
pixel_out = vec3(0.0);
// I tried, instead of simple blur_unroll() to take a black border into account ( blur_unroll_clamp_to_border() )
// to emulate the reflection of black border into the main content
// when it is smaller than the bezel, but due to the low resolution of this pass, the results are bad:
//pixel_out = blur_unroll_clamp_to_border(BEZEL_REFL_BLUR_MAX * shade_sharp_blur, coords, 2.0);
//multiply the blurred image by the corner shade so that reflections will not be visible in the corners.
pixel_out = pixel_out * (1 - fcorners_shade);
// Finally, output the blurred image and put the sharp to blurred gradient in the alpha channel
// to be used by the next blur-y pass too to modulate the blur radius.
FragColor = vec4(apply_fuzzy_main_pass(pixel_out), shade_sharp_blur);
}

View File

@ -1,81 +0,0 @@
#version 450
#include "config.inc"
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main() {
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
#include "includes/functions.include.slang"
#define SourceTexture Source
#define SourceTextureSize params.SourceSize
#define b_offset_x -0.05
#define Pi2 6.28318530717959
vec3 blur(float Quality, float Directions, float Size, vec2 co) {
Size = Size * NEW_SCALEMOD_Y;
vec4 iResolution = SourceTextureSize;
vec2 Radius = Size/iResolution.xy ;
vec3 color = vec3(0.0,0.0,0.0);
vec3 lookup = vec3(0.0,0.0,0.0);
float steps=0.0;
for( float d=0.0; d<Pi2; d+=Pi2/Directions) {
for(float i=1.0/Quality; i<=1.0; i+=1.0/Quality) {
lookup = texture( SourceTexture, co + vec2(cos(d) + b_offset_x , sin(d))*Radius*i ).rgb ;
color +=lookup.rgb;
steps+=1.0;
}
}
color /= steps;
return color;
}
vec3 blur_unroll(float Size, vec2 co) {
Size = Size * NEW_SCALEMOD_Y;
vec3 color = vec3(0.0,0.0,0.0);
vec2 d = SourceTextureSize.zw * Size;
color = texture( SourceTexture, co + d * vec2(-1.0, 1.0 )).rgb ;
color += texture( SourceTexture, co + d * vec2( 1.0, 1.0 )).rgb ;
color += texture( SourceTexture, co + d * vec2(-1.0, -1.0 )).rgb ;
color += texture( SourceTexture, co + d * vec2( 1.0, -1.0 )).rgb ;
color /= 4.0;
return color;
}
void main() {
if (DO_BEZEL == 0.0) return;
vec2 coords = vTexCoord;
vec4 pixel_source = texture(Source, coords);
if (is_useless(pixel_source)) {
//FragColor = vec4(0.0);
return;
}
float blur_modulation = pixel_source.a;
vec3 pixel_out = blur_unroll(BEZEL_REFL_BLUR_MAX * blur_modulation, coords);
//pixel_out = mix(vec3(blur_modulation), pixel_out, 0.5);
FragColor = vec4(pixel_out, 1.0);
//FragColor = vec4(blur_modulation);
}

View File

@ -1,103 +0,0 @@
#version 450
#include "config.inc"
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D in_glow_pass;
layout(set = 0, binding = 3) uniform sampler2D FXAA_pass;
layout(set = 0, binding = 4) uniform sampler2D doublesize_pass;
bool scanline_have_to_flicker(bool is_interlaced) {
return ((scanline_flickering == 1.0) || ((scanline_flickering==2.0) && is_interlaced ));
}
void main()
{
vec3 pixel_out = vec3(0.0);
//Use to debug:
//pixel_out=vec4(abs(sin(params.FrameCount/3.14/20))); //white fade
//pixel_out=vec4(abs(sin(params.FrameCount/3.14/20)),0.0,0.0,0.0); //red fade
//pixel_out=vec4(0.2);
if (DO_SCANLINES == 1.0) {
if (scanline_flickering != 0.0) {
bool is_interlaced = (params.OriginalSize.y > MIN_LINES_INTERLACED) ? true : false ;
if ( scanline_have_to_flicker(is_interlaced) ) {
//Choose the right source
if (DO_IN_GLOW == 1.0) {
pixel_out = texture(in_glow_pass, vTexCoord).rgb;
} else if (DO_FXAA == 1.0) {
pixel_out = texture(FXAA_pass, vTexCoord).rgb;
} else {
pixel_out = texture(doublesize_pass, vTexCoord).rgb;
}
int scanline_period;
int scanline_period_half;
/* Puae switches from lowres to sdres on interlaced screens
since we blindly double the h-resolution, because we need
to double y resolution on low resolution to simulate scanlines
and providing sd-res to fxaa, we can check if a screen is
interlaced by testing v-resolution of source image.
which could be at least 200*2(puae)*2(ourselves)=800px.
Rest assured that everything over 576,
(maximum pal overscanned) is interlaced.
*/
if (is_interlaced) {
scanline_period=4;
scanline_period_half=2;
} else {
scanline_period=2;
scanline_period_half=1;
}
//Skip scanlines on interlaced content?
if (! ( is_interlaced && (scanline_disable_on_interlace == 1.0)) ) {
float mymod = mod(vTexCoord.y * params.OutputSize.y , scanline_period);
//Do flickering based on user prefs.
//(blank odd lines on odd frames and even lines on even frames)
if ((scanline_flickering == 1.0) ||
((scanline_flickering==2.0) && is_interlaced )) {
if (int(mod(float(params.FrameCount),2 )) < 1.0 ) {
if (mymod >= scanline_period_half) { pixel_out *= SCANLINE_DARK; }
} else {
if (mymod < scanline_period_half) { pixel_out *= SCANLINE_DARK; }
}
}
}
}
}
}
FragColor = vec4(pixel_out,1.0);
}

View File

@ -1,49 +0,0 @@
#version 450
#include "config.inc"
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
#include "functions.include"
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
float aspect_prev = (params.SourceSize.y / params.SourceSize.x);
if (border_needed() ) {
vTexCoord.x = vTexCoord.x * aspect_prev - ((0.5 * aspect_prev) - 0.5);
float in_aspect = get_in_aspect();
vTexCoord.x = vTexCoord.x * in_aspect - ((0.5 * in_aspect) - 0.5);
} else {
vTexCoord.x = vTexCoord.x * aspect_prev - ((0.5 * aspect_prev) - 0.5);
float dasp = global.FinalViewportSize.x/global.FinalViewportSize.y;
vTexCoord.x = (vTexCoord.x* dasp - ((0.5 * dasp) - 0.5)) ;
}
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
#include "functions.include"
void main() {
if ((DO_VIGNETTE != 1.0) && (DO_SPOT != 1.0)) return;
vec3 pixel_out;
if (DO_VIGNETTE == 1.0)
pixel_out.r = gauss_xy(0.0, 0.0, v_size, v_power, 0.0, 1.0);
if (DO_SPOT == 1.0)
pixel_out.g = gauss_xy(s_center_x, s_center_y, s_size, s_power, 0.0, 10.0);
FragColor = vec4(pixel_out,1.0);
}