69 lines
2.2 KiB
GLSL
69 lines
2.2 KiB
GLSL
#version 450 core
|
|
in vec2 vTexPos;
|
|
out vec4 fColor;
|
|
const vec2 winSize = vec2 (300.0,300.0);
|
|
// note that the above opening bracket should be the first in this file
|
|
// this is so that the window size can be extracted and the shader recompiled on
|
|
// the fly
|
|
layout (binding = 0) uniform sampler2D screenTexture;
|
|
// the 1.5 maximises the blend, so to speak
|
|
const float hOff = 1.5 / winSize.x;
|
|
const float vOff = 1.5 / winSize.y;
|
|
//const vec2 off[9] = vec2[]
|
|
// ( vec2( hOff, vOff )
|
|
// , vec2( hOff, 0.0 )
|
|
// , vec2( hOff,-vOff )
|
|
// , vec2( 0.0, vOff )
|
|
// , vec2( 0.0, 0.0 )
|
|
// , vec2( 0.0,-hOff )
|
|
// , vec2(-hOff, vOff )
|
|
// , vec2(-hOff, 0.0 )
|
|
// , vec2(-hOff,-vOff )
|
|
// );
|
|
const vec2 fiveOff[5] = vec2[]
|
|
( vec2( hOff, vOff )
|
|
, vec2( hOff,-vOff )
|
|
, vec2( 0.0, 0.0 )
|
|
, vec2(-hOff, vOff )
|
|
, vec2(-hOff,-vOff )
|
|
);
|
|
void main()
|
|
{
|
|
vec4 sumFive = vec4 (0.0,0.0,0.0,0.0);
|
|
for (int i=0; i<5; i++)
|
|
{
|
|
sumFive += vec4(texture(screenTexture, vTexPos + fiveOff[i]));
|
|
}
|
|
//sumFive = sumFive * 3 * sin(dot(vTexPos,vTexPos) * 10000);
|
|
//fColor = vec4 ( max( (sumFive / 10) , texture(screenTexture,vTexPos) ) );
|
|
fColor = vec4 ( max( (sumFive / 10) , texture(screenTexture,vTexPos) ) );
|
|
//fColor = max(texture(screenTexture,vTexPos), sumFive / 5);
|
|
//fColor = vec4 ( (sumFive / 5).rgb, max((sumFive/5.0).a,texture(screenTexture,vTexPos).a) );
|
|
// vec4 sampleTex[9];
|
|
// for(int i=0; i<9; i++)
|
|
// {
|
|
// sampleTex[i] = vec4(texture(screenTexture, vTexPos + off[i]));
|
|
// }
|
|
// vec4 sampleFive[5];
|
|
// for(int i=0; i<5; i++)
|
|
// {
|
|
// sampleFive[i] = vec4(texture(screenTexture, vTexPos + fiveOff[i]));
|
|
// }
|
|
// vec4 col = vec4(0,0,0,0);
|
|
// for (int i = 0; i < 9; i++)
|
|
// col = combinef(col,sampleTex[i]);
|
|
// //col += sampleTex[i] * frac;
|
|
// float alph = 0.0;
|
|
// for (int i = 0; i < 9; i++)
|
|
// //alph += sampleTex[i].a;
|
|
// alph = max(alph, 0.5 * sampleTex[i].a);
|
|
// alph = max(sampleTex[4].a, alph);
|
|
// //
|
|
// //fColor = col;
|
|
// fColor = vec4(col.rgb/col.a,alph);
|
|
// //if (col.a == 0.0)
|
|
// //{ fColor = vec4(0,0,0,0); }
|
|
// //else
|
|
// //{ fColor = vec4( col.r/col.a , col.g/col.a , col.b/col.a, col.a/9.0); }
|
|
}
|