local shaders = shaders or {}
local frags = {}

-- vec3 linearToGamma(vec3 c) { return max(1.055 * pow(max(c, vec3(0.0)), vec3(0.41666666)) - 0.055, vec3(0.0)); }
-- vec3 gammaToLinear(vec3 c) { return c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878); }

frags.blankShader = [[
 
	vec4 effect(vec4 color, sampler2D tex, vec2 textureCoords, vec2 screenCoords){
		vec4 col = Texel(tex , textureCoords );
		
		return col*color;
	}
]]

frags.noGamma = [[
	vec4 effect(vec4 color, sampler2D tex, vec2 textureCoords, vec2 screenCoords){
		vec4 col = Texel(tex , textureCoords );
		
		return (col)*(color);
	}
]]

frags.unmul = [[
	vec4 effect(vec4 color, sampler2D tex, vec2 textureCoords, vec2 screenCoords){
		vec4 col = Texel(tex , textureCoords );
    vec3 linear = col.rgb/vec3(col.a);
		return vec4(color.rgb*linear,color.a*col.a);
	}
]]

frags.r8 = [[
	uniform float index = 0;
	vec4 effect(vec4 color, sampler2D tex, vec2 textureCoords, vec2 screenCoords){
		vec4 col = Texel(tex , textureCoords );
		if(col.r>0){
			return vec4(index>=0 ? vec3(index): vec3(col.r),1);
		}else{
			discard;
		}
	}
]]

frags.depth = [[
	uniform float zNear = 0.1;
	uniform float zFar = 10000.0;

	float linearDepth(float depthSample)
	{
		depthSample = 2.0 * depthSample - 1.0;
		float zLinear = 2.0 * zNear * zFar / (zFar + zNear - depthSample * (zFar - zNear));
		return zLinear;
	}

	vec4 effect(vec4 color, sampler2D tex, vec2 textureCoords, vec2 screenCoords){
		return vec4(vec3(linearDepth(Texel(tex,textureCoords).r)/1000),1);
	}
]]

frags.interp = [[
  uniform vec2 image_size;
  uniform float intensity = 1.0;
 const vec2 offsets[8] = vec2[8](
vec2(-1,1),
vec2(0,1),
vec2(1,1),
vec2(-1,0),
vec2(1,0),
vec2(-1,-1),
vec2(0,-1),
vec2(1,-1)
 );
  vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc) {
    vec4 col = Texel(tex, tc);
    if (length(col.rgb)>0) {
      return col;
    }

    float div = 0.0;
    for(int i=1; i<=8; i+=1){
      vec4 sample = Texel(tex, tc + offsets[i]/image_size);
      if (length(sample)>0) {
        col+=sample;
        div +=1;
      }
    }

    return vec4(col.rgb/div,1);
  }
]]

-- frags.addTrace = [[
--   vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc) {
--     vec4 source = Texel(tex, tc);
--     vec4 dest = Texel(tex, tc);
--     return source+dest;
--   }
-- ]]

frags.ptmap = [[
 uniform vec2 image_size;
  uniform float intensity = 1.0;
  uniform float exposure = 0.3;
  uniform float blur = 0;
 const vec2 offsets[8] = vec2[8](
vec2(-1,1),
vec2(0,1),
vec2(1,1),

vec2(-1,0),
vec2(1,0),

vec2(-1,-1),
vec2(0,-1),
vec2(1,-1)
 );
 uniform sampler2D gbuffer_position;
uniform sampler2D gbuffer_normal;
uniform vec3 eye_position;
uniform float samples=0;
  vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc) {
    vec4 col = Texel(tex, tc)/samples;
    vec4 position = Texel(gbuffer_position, tc);
    vec3 normal = Texel(gbuffer_normal, tc).xyz*2-1;
    float div = 1.0;
    if (position.a==0){
      discard;
    }

    vec2 is = image_size;
    vec3 ep = eye_position;
    if (blur>0){
     for(int i=1; i<=8; i+=1){
       vec4 pos = Texel(gbuffer_position, tc + blur*offsets[i]/image_size);
       vec3 norm = Texel(gbuffer_normal,  tc + blur*offsets[i]/image_size).xyz*2-1;
       float close = abs(distance(pos.xyz,eye_position)-distance(eye_position,position.xyz));
       if (pos.a>0 && close<5 && dot(normal,norm)>0.8) {
         vec4 sample = Texel(tex, tc + offsets[i]/image_size)/samples;
         col += sample;
         div += 1;
       }
     }
   }

    
    vec3 hdrColor = col.rgb/div;
    // exposure tone mapping
    vec3 mapped = vec3(1.0) - exp(-hdrColor * exposure);
    // gamma correction 

    return vec4(mapped,1);
  }
]]

frags.rtmap = [[
  vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc) {
    vec4 col = Texel(tex, tc);
    return vec4(col.rgb/col.a,1);
  }
]]


frags.simple_blur = [[
	uniform vec2 image_size;
	uniform float alpha = 0.4;
	uniform float intensity = 3.0;
 
	vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc) {
		vec2 offset = vec2(1.0)/image_size;
		vec4 col = Texel(tex, tc);
 
		col += Texel(tex, tc + intensity*vec2(-offset.x, offset.y));
		col += Texel(tex, tc + intensity*vec2(0.0, offset.y));
		col += Texel(tex, tc + intensity*vec2(offset.x, offset.y));
		col += Texel(tex, tc + intensity*vec2(-offset.x, 0.0));
		col += Texel(tex, tc + intensity*vec2(0.0, 0.0))*2;
		col += Texel(tex, tc + intensity*vec2(offset.x, 0.0));
		col += Texel(tex, tc + intensity*vec2(-offset.x, -offset.y));
		col += Texel(tex, tc + intensity*vec2(0.0, -offset.y));
		col += Texel(tex, tc + intensity*vec2(offset.x, -offset.y));
 
		offset = vec2(2.0)/image_size;
 
		col += Texel(tex, tc + intensity*vec2(0.0, offset.y));
		col += Texel(tex, tc + intensity*vec2(-offset.x, 0.0));
		col += Texel(tex, tc + intensity*vec2(offset.x, 0.0));
		col += Texel(tex, tc + intensity*vec2(0.0, -offset.y));
		
		col = col/13.0;
		col.a = alpha;
 
		return col;
	}
]]

frags.blur13 = [[
	uniform float Size = 16.0; // BLUR SIZE (Radius)
	uniform vec2 Resolution = vec2(4096);
	vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 screenCoords){
		float Pi = 6.28318530718; // Pi*2
	
		// GAUSSIAN BLUR SETTINGS {{{
		float Directions = 16.0; // BLUR DIRECTIONS (Default 16.0 - More is better but slower)
		float Quality = 8.0; // BLUR QUALITY (Default 4.0 - More is better but slower)
		
		// GAUSSIAN BLUR SETTINGS }}}
	   
		vec2 Radius = Size/Resolution;
		vec4 Color = Texel(tex, tc);
		for( float d=0.0; d<Pi; d+=Pi/Directions)
		{
			for(float i=1.0/Quality; i<=1.0; i+=1.0/Quality)
			{
				Color += Texel( tex, tc+vec2(cos(d),sin(d))*Radius*i);      
			}
		}
		Color /= Quality * Directions - 15.0;
		return Color;
	}
]]

frags.expandShader = [[
	uniform vec2 image_size;
	vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 screenCoords){
		vec4 col = Texel(tex , tc );
		vec2 offset = vec2(1.0)/image_size;
		float test = 0.0;
		if(length(col)==0){
			test += length(Texel(tex, tc + vec2(-offset.x, offset.y)));
			test += length(Texel(tex, tc + vec2( offset.x, offset.y)));
			test += length(Texel(tex, tc + vec2(-offset.x, -offset.y)));
			test += length(Texel(tex, tc + vec2( offset.x, -offset.y)));
 
			test += length(Texel(tex, tc + vec2(0, offset.y)));
			test += length(Texel(tex, tc + vec2( offset.x,0)));
			test += length(Texel(tex, tc + vec2(-offset.x,0)));
			test += length(Texel(tex, tc + vec2( 0, -offset.y)));
 
			if (test>0){
				return color;
			}
		}
		return col*color;
	}
]]

frags.edgeShader = [[
	float n = 1/sqrt(2);
	uniform vec2 image_size;
	vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 screenCoords){
		vec4 col = Texel(tex , tc );
		vec2 offset = vec2(1.0)/image_size;
		float test = 0.0;
		if(col.a==0){
			test += length(Texel(tex, tc + n*vec2(-offset.x, offset.y)));
			test += length(Texel(tex, tc + n*vec2( offset.x, offset.y)));
			test += length(Texel(tex, tc + n*vec2(-offset.x, -offset.y)));
			test += length(Texel(tex, tc + n*vec2( offset.x, -offset.y)));
 
		   test += length(Texel(tex, tc + vec2(0, offset.y)));
		   test += length(Texel(tex, tc + vec2( offset.x,0)));
		   test += length(Texel(tex, tc + vec2(-offset.x,0)));
		   test += length(Texel(tex, tc + vec2( 0, -offset.y)));
 
			if (test>0){
				return vec4(1);
			}
		}
		return vec4(0);
	}
]]

frags.aa = [[
 
	  
	  // Standard sample locations from Vulkan spec
	  const vec2 samples[16] = vec2[16](
		vec2(.0625, .0625),
		vec2(-.0625, -.1875),
		vec2(-.1875, .125),
		vec2(.25, -.0625),
		vec2(-.3125, -.125),
		vec2(.125, .3125),
		vec2(.3125, .1875),
		vec2(.1875, -.3125),
		vec2(-.125, .3125),
		vec2(0, -.4375),
		vec2(-.25, -.375),
		vec2(-.375, .25),
		vec2(-.5, 0.),
		vec2(.4375, -.25),
		vec2(.375, .4375),
		vec2(-.4375, -.5)
	  );
 
	uniform vec2 image_size;
	vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 screenCoords){
		vec4 col = Texel(tex , tc );
		vec2 offset = vec2(1.0)/image_size;
		float test = 0.0;
		return vec4(color.rgb,col.a);
		//if(col.a==0){
		  ///  for (int i = 0; i < 16; i++) {
		  ///      test += Texel(tex, tc + samples[i]*offset).a;
		  ///  }
		  ///  if (test>0){
		  ///      return vec4(color.rgb,(test/16.0));
		  ///  }else{
		  ///      discard;
		  ///  }
		//}else{
			//return vec4(color.rgb,color.a*col.a);
		//}
	}
]]

frags.r8expand = [[
	uniform float index = 0;
	uniform vec2 image_size;
	vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 screenCoords){
		vec4 col = Texel(tex , tc );
		vec2 offset = vec2(1.0)/image_size;
		float test = 0.0;
		if(col.r==0){
			test += ceil(Texel(tex, tc + vec2(-offset.x, offset.y)).r);
			test += ceil(Texel(tex, tc + vec2( offset.x, offset.y)).r);
			test += ceil(Texel(tex, tc + vec2(-offset.x, -offset.y)).r);
			test += ceil(Texel(tex, tc + vec2( offset.x, -offset.y)).r);
 
			test += ceil(Texel(tex, tc + vec2(0, offset.y)).r);
			test += ceil(Texel(tex, tc + vec2( offset.x,0)).r);
			test += ceil(Texel(tex, tc + vec2(-offset.x,0)).r);
			test += ceil(Texel(tex, tc + vec2( 0, -offset.y)).r);
 
			if (test>1){
				return vec4(vec3(index),1);
			}
		}
	   if(col.r>0){
			return vec4(vec3(index),1);
		}else{
			discard;
		}
	}
]]

frags.selectionShader = [[
	uniform float time = 0;
	vec4 effect(vec4 color, sampler2D tex, vec2 textureCoords, vec2 screenCoords){
		vec4 col = Texel(tex, textureCoords );
		//float a = screenCoords.x+screenCoords.y;//floor(screenCoords.x+time);
		//float b = 2;
		//float w = a - (b * floor(a/b));
		//w = (screenCoords.x)/(love_ScreenSize.x);
		//w = w;
		//w = w +abs(sin(time))/6+0.1;
		//w = sin(w+time);
		float w =fract(sin(screenCoords.x+screenCoords.y+time)/(love_ScreenSize.x));
		w = (w+0.1)/1.1;
		return vec4(w,w,w,1);
	}
]]

frags.xpro_bloom = [[
vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc)
{
	vec4 col = Texel(tex ,tc);
	col.a = pow((col.r+col.b+col.g)/3,4);
	col.r = col.r*col.a*1;
	col.g = col.g*col.a*1;
	col.b = col.b*col.a*1;
 
	return col;
}
]]

frags.xpro = [[
vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc)
{
 
	vec4 col = Texel(tex ,tc);
	float avg = (col.r+col.b+col.g)/3;
	col.r = pow(col.r,0.8)+0.01;
	col.g = pow(col.g,0.9);
	col.b = pow(col.b,1.4)+0.10;
	col.a = 1;
 
	return col;
}
]]

frags.soft_clear = [[
uniform float fade = 0.5;
vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc)
{
 
	vec4 col = Texel(tex ,tc);
	col.a = col.a*fade;
	col.r = col.r*fade;
	col.g = col.g*fade;
	col.b = col.b*fade;
	
 
	return col;
}
]]

frags.drawOnion = [[
uniform vec4 tint;
vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc)
{
	vec4 col = Texel(tex ,tc);
	col.r = (tint.r+(col.r+tint.r))/2;
	col.g = (tint.g+(col.g+tint.g))/2;
	col.b = (tint.b+(col.b+tint.b))/2;
	col.a = col.a-tint.a;
 
	return col;
}
]]

frags.mult = [[
uniform float alpha = 0.3;
uniform float r = 1;
uniform float g = 0;
uniform float b = 0;
uniform sampler2D stroke;
vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc)
{
	vec4 col = Texel(tex ,tc);
	vec4 col2 = Texel(stroke ,tc);
	col2.a = alpha;
	col.r = col.r + (col2.r*col2.a - col.r*col.a);
	col.g = col.g + (col2.g*col2.a - col.g*col.a);
	col.b = col.b + (col2.b*col2.a - col.b*col.a);
	col.a *= col2.a;
	return col;
}
]]

frags.fade_shader = [[
uniform float fade = 1;
uniform float sr = 1;
uniform float sg = 1;
uniform float sb = 1;
vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc)
{
	vec4 stripes = Texel(tex ,tc);
	stripes.r = stripes.r + (sr-stripes.r) * fade;
	stripes.g = stripes.g + (sg-stripes.g) * fade;
	stripes.b = stripes.b + (sb-stripes.b) * fade;
	return stripes;
}
]]

frags.film = [[
uniform float time = 0;
 
uniform float nIntensity = 0.3;
 
uniform float sIntensity = 0.05;
 
uniform float sCount = 2000;
 
vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc)
{
vec4 cTextureScreen = Texel( tex, tc);

float x = tc.x * tc.y * time * 1000.0;
x = mod( x, 13.0 ) * mod( x, 123.0 );
float dx = mod( x, 0.01 );

vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );

vec2 sc = vec2( sin( tc.y * sCount ), cos( tc.y * sCount ) );

cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;

cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );

vec4 col = vec4( cResult, cTextureScreen.a );
 
  float avg = (col.r+col.b+col.g)/3;
	col.r = pow(col.r,0.8)+0.01;
	col.g = pow(col.g,0.9);
	col.b = pow(col.b,1.4)+0.10;
	col.a = 1;
 
  return col;

}
]]

frags.simple_blur2 = [[
	
		uniform vec2 image_size;
		uniform float intensity = 2.0;
 
		vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc) {
			vec2 offset = vec2(1.0)/image_size;
			color = Texel(tex, tc);
 
			if ( Texel(tex, tc + intensity*vec2(-offset.x, offset.y)).a>0.0 ){
			color += Texel(tex, tc + intensity*vec2(-offset.x, offset.y));
			color += Texel(tex, tc + intensity*vec2(offset.x, offset.y));
			color += Texel(tex, tc + intensity*vec2(-offset.x, -offset.y));
			color += Texel(tex, tc + intensity*vec2(offset.x, -offset.y));
		  }
 
			return color/4.0;
		}
	
]]


frags.menu_blur = [[
	uniform vec2 image_size = vec2(640,412);
	uniform float intensity = 3.0;
 
	vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc) {
		vec2 offset = vec2(1.0)/image_size;
		color = Texel(tex, tc);
 
		color += Texel(tex, tc + intensity*vec2(-offset.x, offset.y));
		color += Texel(tex, tc + intensity*vec2(0.0, offset.y));
		color += Texel(tex, tc + intensity*vec2(offset.x, offset.y));
		color += Texel(tex, tc + intensity*vec2(-offset.x, 0.0));
		color += Texel(tex, tc + intensity*vec2(0.0, 0.0))*2;
		color += Texel(tex, tc + intensity*vec2(offset.x, 0.0));
		color += Texel(tex, tc + intensity*vec2(-offset.x, -offset.y));
		color += Texel(tex, tc + intensity*vec2(0.0, -offset.y));
		color += Texel(tex, tc + intensity*vec2(offset.x, -offset.y));
 
		offset = vec2(2.0)/image_size;
 
		color += Texel(tex, tc + intensity*vec2(0.0, offset.y));
		color += Texel(tex, tc + intensity*vec2(-offset.x, 0.0));
		color += Texel(tex, tc + intensity*vec2(offset.x, 0.0));
		color += Texel(tex, tc + intensity*vec2(0.0, -offset.y));
		
		color/=13.0;
		color.a = 0.1;
 
		return color;
	}
]]

frags.blur_fade = [[
 
	uniform float fade = 1;
	uniform vec4 fadecol;
	uniform vec2 image_size;
	uniform float intensity = 2.0;
 
	vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc) {
		vec2 offset = vec2(1.0)/image_size;
		color = Texel(tex, tc);
 
 
		color += Texel(tex, tc + intensity*vec2(-offset.x, offset.y));
		//color += Texel(tex, tc + intensity*vec2(0.0, offset.y));
		color += Texel(tex, tc + intensity*vec2(offset.x, offset.y));
 
		//color += Texel(tex, tc + intensity*vec2(-offset.x, 0.0));
		//color += Texel(tex, tc + intensity*vec2(0.0, 0.0));
		//color += Texel(tex, tc + intensity*vec2(offset.x, 0.0));
 
		color += Texel(tex, tc + intensity*vec2(-offset.x, -offset.y));
		//color += Texel(tex, tc + intensity*vec2(0.0, -offset.y));
		color += Texel(tex, tc + intensity*vec2(offset.x, -offset.y));
 
		vec4 col = color/5.0;
 
		col.r = col.r + (fadecol.r-col.r) * fade * col.a;
		col.g = col.g + (fadecol.g-col.g) * fade * col.a;
		col.b = col.b + (fadecol.b-col.b) * fade * col.a;
	   
		return col;
	}
]]

frags.blur_only = [[
 
	uniform float fade = 1;
	uniform vec4 fadecol;
	uniform vec2 image_size;
	uniform float intensity = 2.0;
 
	vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc) {
		vec2 offset = vec2(1.0)/image_size;
		color = Texel(tex, tc);
		float dist = 2;
 
		color += Texel(tex, tc + intensity*vec2(-offset.x*dist, offset.y*dist));
		//color += Texel(tex, tc + intensity*vec2(0.0, offset.y*dist));
		color += Texel(tex, tc + intensity*vec2(offset.x*dist, offset.y*dist));
 
		//color += Texel(tex, tc + intensity*vec2(-offset.x*dist, 0.0));
		//color += Texel(tex, tc + intensity*vec2(0.0, 0.0));
		//color += Texel(tex, tc + intensity*vec2(offset.x*dist, 0.0));
 
		color += Texel(tex, tc + intensity*vec2(-offset.x*dist, -offset.y*dist));
		//color += Texel(tex, tc + intensity*vec2(0.0, -offset.y*dist));
		color += Texel(tex, tc + intensity*vec2(offset.x*dist, -offset.y*dist));
 
		vec4 col = color/2;
	   
		return col;
	}
]]

frags.fade_only = [[
 
	uniform float fade = 1;
	uniform vec4 fadecol;
	uniform vec2 image_size;
	uniform float intensity = 2.0;
 
	vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc) {
		vec4 col = Texel(tex, tc);
 
		col.r = col.r + (fadecol.r-col.r) * fade * col.a;
		col.g = col.g + (fadecol.g-col.g) * fade * col.a;
		col.b = col.b + (fadecol.b-col.b) * fade * col.a;
	   
		return col;
	}
]]

frags.frosty = [[
uniform float radius =2.0;
uniform float intensity = 2       ;
uniform float alpha     = 1;
uniform vec2 image_size;
 
vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc)
{
   vec4 col = vec4(0);
   vec4 sample = vec4(0);
   vec2 st;
 
   for (float x = -radius; x <= radius; x++) {
	  for (float y = -radius; y <= radius; y++) {
		 // to texture coordinates
		 st.xy = vec2(x,y) / image_size;
		 sample = Texel(tex, tc + intensity*st);
		 sample.r=max(0.235,sample.r*0.15+0.227);
		 sample.b=max(0.235,sample.b*0.15+0.227);
		 sample.g=max(0.235,sample.g*0.15+0.227);
		 col += sample;
	  }
   }
   col = (col-(pow(radius,2.5))) / pow(radius*1.3,4);
   col.a = alpha;
   return col;
}
]]

frags.harsh = [[
	uniform vec4 tint;
	vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc) {
		vec4 col = Texel(tex, tc);
		
		col.a = col.a*2;
		col = col * color;
	   if (col.a<1) {
		//discard;
	   }
		return col;
	}
]]

frags.alpha = [[
	uniform float alpha=1;
	vec4 effect(vec4 color, sampler2D tex, vec2 tc, vec2 pc) {
		vec4 col = Texel(tex, tc);
		color.a=color.a*alpha;
		return color*col;
	}
]]

frags.hqblur = [[
uniform vec2 image_size;
uniform int samples = 4; // pixels per axis; higher = bigger glow, worse performance
uniform float quality = 0.5; // lower = smaller glow, better quality
vec4 effect(vec4 colour, sampler2D tex, vec2 tc, vec2 sc)
{
  vec4 source = Texel(tex, tc);
  vec4 sum = vec4(0);
  int diff = (samples - 1) / 2;
  vec2 sizeFactor = vec2(1) / image_size * quality;
 
 
  for (int d = 1; d<= samples; d++) {
	  for (float r = 0; r<= 6.28; r+=6.28/samples) {
		float x = sin(r)*d;
		float y = cos(r)*d;
		vec2 offset = vec2(x, y) * sizeFactor;
		sum += Texel(tex, tc + offset);
	  }
  }
 
  
  return ((sum / (samples * samples ))*quality + source) * colour;
}
]]

local function loadFrags()
  for s, shade in pairs(frags) do

	if LOVE then
	  shaders[s] = gfx.newShader(shade)
	  print(s,shaders[s])
	else
	  -- shade = shade:gsub(", vec2 pc", "")
	  -- shade = shade:gsub("effect", "color")
	  shade = shade:gsub("Texel", "texture")
	  local _,shade = convertShader(nil,shade)
	  -- shade = gfx.defaultFrag
	  -- shade = [[
   --      #version 330
			-- 	in vec2 fragTexCoord;
   --      in vec4 fragColor;
   --      in vec2 screenCoords;
   --      uniform sampler2D texture0;
   --      out vec4 finalColor;
			-- 	]]..shade..[[
			-- 	void main() {
			-- 		finalColor = effect(fragColor,texture0,fragTexCoord,screenCoords);
			-- 	}
			-- ]]
	  -- shade = gfx.defaultFrag
	  shaders[s] = gfx.newShader(shade, gfx.defaultVert,{name = s})

	end
  end
  return shaders
end

return loadFrags
