//----------------------------------------------------------------------------- //GLSL //----------------------------------------------------------------------------- [vert.glsl] #version 120 attribute vec2 in_position; uniform vec2 in_screen_res; uniform float in_step; varying vec2 pass_pos; varying vec2 pass_p[8]; void main() { //JFA ALGO pass_pos = ((vec2(1.0) + in_position) * 0.5); float k = in_step; vec2 p2 = pass_pos; pass_p[0] = p2 + vec2(-k, -k); pass_p[1] = p2 + vec2( 0, -k); pass_p[2] = p2 + vec2( k, -k); pass_p[3] = p2 + vec2(-k, 0); pass_p[4] = p2 + vec2( k, 0); pass_p[5] = p2 + vec2(-k, k); pass_p[6] = p2 + vec2( 0, k); pass_p[7] = p2 + vec2( k, k); gl_Position = vec4(in_position, 0.0, 1.0); } [frag.glsl] #version 120 #if defined GL_ES precision highp float; #endif uniform sampler2D in_texture; varying vec2 pass_pos; varying vec2 pass_p[8]; void main(void) { vec4 src_color = texture2D(in_texture, pass_pos); vec4 neigh_color; for (int i = 0; i < 8; ++i) { neigh_color = texture2D(in_texture, pass_p[i]); if (neigh_color.z > 0.0 && src_color.z == 0.0) src_color = neigh_color; else if (neigh_color.z > 0.0 && src_color.z > 0.0 && length(neigh_color.xy - pass_pos) < length(src_color.xy - pass_pos)) src_color = neigh_color; } gl_FragColor = src_color; } //----------------------------------------------------------------------------- //HLSL //----------------------------------------------------------------------------- [vert.hlsl] void main(float2 in_Position : POSITION, out float2 pass_Position : TEXCOORD0, out float4 out_Position : POSITION) { pass_Position = in_Position; out_Position = float4(in_Position, 0.0, 1.0); } [frag.hlsl] void main(in float2 pass_Position : TEXCOORD0, uniform sampler2D in_Texture, uniform float in_Flag, uniform float3 in_Point, uniform float3 in_Color, out float4 out_FragColor : COLOR) { out_FragColor = float4(0.0); }