Skip to content

Commit

Permalink
move fp and zebra into supershader, limit to gl3
Browse files Browse the repository at this point in the history
  • Loading branch information
KillerInk committed Jul 2, 2021
1 parent afa8be8 commit 8dfd8d7
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 513 deletions.
34 changes: 0 additions & 34 deletions app/src/main/assets/shader/focuspeak.fsh

This file was deleted.

71 changes: 0 additions & 71 deletions app/src/main/assets/shader/focuspeak_sobel.fsh

This file was deleted.

81 changes: 0 additions & 81 deletions app/src/main/assets/shader/focuspeak_zebra.fsh

This file was deleted.

26 changes: 0 additions & 26 deletions app/src/main/assets/shader/preview.fsh

This file was deleted.

79 changes: 79 additions & 0 deletions app/src/main/assets/shader/supershader.fsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#version 300 es
#line 1
#extension GL_OES_EGL_image_external_essl3 : require
precision mediump float;

uniform samplerExternalOES sTexture;
out vec4 Output;
in vec2 texCoord;

uniform float float_position;
uniform float zebra_high;
uniform float zebra_low;
uniform bool show_zebra;
uniform bool show_focuspeak;

uniform vec4 peak_color;
uniform float peak_strength;

vec4 getZebra(vec2 texS, vec4 color, float pos,float high,float low)
{
vec4 out_color;
if(fract((texS.x + texS.y)*(20.0+pos)) > 0.9)
{
float gray = (color.r + color.g +color.b) /3.0;
if(gray > (1.0 - high))
out_color = mix(color,vec4(1.0, 0.0, 0.0, 1.0),gray);
else if(gray < low)
out_color = mix(color,vec4(0.0, 0.4, 1.0, 1.0),1.0-gray);
else
out_color = color;
}
else if(fract((texS.x - texS.y)*(20.0+pos)) > 0.9)
{
float gray = (color.r + color.g +color.b) /3.0;
if(gray > (1.0 - high))
out_color = mix(color,vec4(1.0, 0.0, 0.0, 1.0),gray);
else if(gray < low)
out_color = mix(color,vec4(0.0, 0.4, 1.0, 1.0),1.0-gray);
else
out_color = color;
}
else
out_color = color;
return out_color;
}

void main() {
vec2 texSize = texCoord.xy;
vec4 color = texture(sTexture,texSize);
vec4 out_color = color;
if (show_zebra)
out_color = getZebra(texSize, color,float_position,zebra_high,zebra_low);

if(show_focuspeak)
{
vec2 size = vec2(textureSize(sTexture, 0));
float w = 1.0 / size.x;
float h = 1.0 / size.y;
vec4 n[9];
n[0] = texture(sTexture, texCoord + vec2( -w, -h));
n[1] = texture(sTexture, texCoord + vec2(0.0, -h));
n[2] = texture(sTexture, texCoord + vec2( w, -h));
n[3] = texture(sTexture, texCoord + vec2( -w, 0.0));
n[4] = texture(sTexture, texCoord);
n[5] = texture(sTexture, texCoord + vec2( w, 0.0));
n[6] = texture(sTexture, texCoord + vec2( -w, h));
n[7] = texture(sTexture, texCoord + vec2(0.0, h));
n[8] = texture(sTexture, texCoord + vec2( w, h));

vec4 sobel_edge_h = n[2] + (peak_strength*n[5]) + n[8] - (n[0] + (peak_strength*n[3]) + n[6]);
vec4 sobel_edge_v = n[0] + (peak_strength*n[1]) + n[2] - (n[6] + (peak_strength*n[7]) + n[8]);
vec4 sobel = sqrt(((sobel_edge_h * sobel_edge_h) + (sobel_edge_v * sobel_edge_v)));
if(sobel == min(sobel, vec4(0.3,0.3,0.3,1)))
sobel = vec4(0,0,0,1);
out_color = mix(out_color, peak_color, sobel);
}

Output = out_color;
}
44 changes: 0 additions & 44 deletions app/src/main/assets/shader/zebra.fsh

This file was deleted.

28 changes: 0 additions & 28 deletions app/src/main/assets/shader/zebramethod.fsh

This file was deleted.

Loading

0 comments on commit 8dfd8d7

Please sign in to comment.