Fix compat mode stealth shader (#11833)

This commit is contained in:
Leon Friedrich
2022-10-11 13:55:19 +13:00
committed by GitHub
parent f2a9f6ad88
commit 436131e9f4

View File

@@ -9,28 +9,28 @@ const mediump float distance_scale = 0.125;
void fragment() { void fragment() {
vec4 sprite = zTexture(UV); highp vec4 sprite = zTexture(UV);
if (sprite.a == 0.0) { if (sprite.a == 0.0) {
discard; discard;
} }
// get distortion magnitude. hand crafted from a random jumble of trig functions // get distortion magnitude. hand crafted from a random jumble of trig functions
vec2 coords = (FRAGCOORD.xy + reference) * distance_scale; highp vec2 coords = (FRAGCOORD.xy + reference) * distance_scale;
float w = sin(TIME + (coords.x + coords.y + 2.0*sin(TIME*time_scale) * sin(TIME*time_scale + coords.x - coords.y)) ); highp float w = sin(TIME + (coords.x + coords.y + 2.0*sin(TIME*time_scale) * sin(TIME*time_scale + coords.x - coords.y)) );
// visualize distortion via: // visualize distortion via:
// COLOR = vec4(w,w,w,1); // COLOR = vec4(w,w,w,1.0);
w *= (3 + visibility * 2); w *= (3.0 + visibility * 2.0);
vec4 background = zTextureSpec(SCREEN_TEXTURE, ( FRAGCOORD.xy + vec2(w) ) * SCREEN_PIXEL_SIZE ); highp vec4 background = zTextureSpec(SCREEN_TEXTURE, ( FRAGCOORD.xy + vec2(w) ) * SCREEN_PIXEL_SIZE );
float alpha; lowp float alpha;
if (visibility>0) if (visibility>0.0)
alpha = sprite.a * visibility; alpha = sprite.a * visibility;
else else
alpha = 0; alpha = 0.0;
COLOR.xyz = mix(background.xyz, sprite.xyz, alpha); COLOR.xyz = mix(background.xyz, sprite.xyz, alpha);
COLOR.a = 1.0; COLOR.a = 1.0;