145 lines
5 KiB
Text
145 lines
5 KiB
Text
|
|
#version 460
|
||
|
|
layout(location = 0) out vec4 FragColor;
|
||
|
|
|
||
|
|
in vec2 TexCoord;
|
||
|
|
|
||
|
|
uniform sampler2D Tex;
|
||
|
|
|
||
|
|
float pixel = 1f/1600f;
|
||
|
|
|
||
|
|
vec3 accentColor = vec3(0.8,0.533,0.6);
|
||
|
|
//vec3(0,1,1);
|
||
|
|
|
||
|
|
|
||
|
|
vec2 SampleCircle[45] = vec2[45](
|
||
|
|
vec2(0.0f*pixel,1.0f*pixel),
|
||
|
|
vec2(0.13917310096006544f*pixel,0.9902680687415704f*pixel),
|
||
|
|
vec2(0.27563735581699916f*pixel,0.9612616959383189f*pixel),
|
||
|
|
vec2(0.4067366430758002f*pixel,0.9135454576426009f*pixel),
|
||
|
|
vec2(0.5299192642332049f*pixel,0.848048096156426f*pixel),
|
||
|
|
vec2(0.6427876096865393f*pixel,0.766044443118978f*pixel),
|
||
|
|
vec2(0.7431448254773942f*pixel,0.6691306063588582f*pixel),
|
||
|
|
vec2(0.8290375725550417f*pixel,0.5591929034707468f*pixel),
|
||
|
|
vec2(0.898794046299167f*pixel,0.43837114678907746f*pixel),
|
||
|
|
vec2(0.9510565162951535f*pixel,0.30901699437494745f*pixel),
|
||
|
|
vec2(0.984807753012208f*pixel,0.17364817766693041f*pixel),
|
||
|
|
vec2(0.9993908270190958f*pixel,0.03489949670250108f*pixel),
|
||
|
|
vec2(0.9945218953682733f*pixel,-0.10452846326765355f*pixel),
|
||
|
|
vec2(0.9702957262759965f*pixel,-0.24192189559966779f*pixel),
|
||
|
|
vec2(0.9271838545667874f*pixel,-0.37460659341591207f*pixel),
|
||
|
|
vec2(0.8660254037844387f*pixel,-0.4999999999999998f*pixel),
|
||
|
|
vec2(0.788010753606722f*pixel,-0.6156614753256583f*pixel),
|
||
|
|
vec2(0.6946583704589971f*pixel,-0.7193398003386512f*pixel),
|
||
|
|
vec2(0.5877852522924732f*pixel,-0.8090169943749473f*pixel),
|
||
|
|
vec2(0.4694715627858907f*pixel,-0.882947592858927f*pixel),
|
||
|
|
vec2(0.3420201433256689f*pixel,-0.9396926207859083f*pixel),
|
||
|
|
vec2(0.20791169081775931f*pixel,-0.9781476007338057f*pixel),
|
||
|
|
vec2(0.06975647374412552f*pixel,-0.9975640502598242f*pixel),
|
||
|
|
vec2(-0.06975647374412527f*pixel,-0.9975640502598242f*pixel),
|
||
|
|
vec2(-0.2079116908177595f*pixel,-0.9781476007338056f*pixel),
|
||
|
|
vec2(-0.34202014332566866f*pixel,-0.9396926207859084f*pixel),
|
||
|
|
vec2(-0.46947156278589086f*pixel,-0.8829475928589269f*pixel),
|
||
|
|
vec2(-0.587785252292473f*pixel,-0.8090169943749476f*pixel),
|
||
|
|
vec2(-0.6946583704589974f*pixel,-0.7193398003386511f*pixel),
|
||
|
|
vec2(-0.7880107536067221f*pixel,-0.6156614753256581f*pixel),
|
||
|
|
vec2(-0.8660254037844384f*pixel,-0.5000000000000004f*pixel),
|
||
|
|
vec2(-0.9271838545667873f*pixel,-0.3746065934159123f*pixel),
|
||
|
|
vec2(-0.9702957262759965f*pixel,-0.24192189559966779f*pixel),
|
||
|
|
vec2(-0.9945218953682734f*pixel,-0.10452846326765336f*pixel),
|
||
|
|
vec2(-0.9993908270190958f*pixel,0.03489949670250128f*pixel),
|
||
|
|
vec2(-0.9848077530122081f*pixel,0.17364817766692997f*pixel),
|
||
|
|
vec2(-0.9510565162951536f*pixel,0.30901699437494723f*pixel),
|
||
|
|
vec2(-0.898794046299167f*pixel,0.4383711467890774f*pixel),
|
||
|
|
vec2(-0.8290375725550416f*pixel,0.559192903470747f*pixel),
|
||
|
|
vec2(-0.7431448254773946f*pixel,0.6691306063588578f*pixel),
|
||
|
|
vec2(-0.6427876096865396f*pixel,0.7660444431189778f*pixel),
|
||
|
|
vec2(-0.529919264233205f*pixel,0.848048096156426f*pixel),
|
||
|
|
vec2(-0.40673664307580015f*pixel,0.913545457642601f*pixel),
|
||
|
|
vec2(-0.27563735581699894f*pixel,0.9612616959383189f*pixel),
|
||
|
|
vec2(-0.13917310096006588f*pixel,0.9902680687415703f*pixel)
|
||
|
|
);
|
||
|
|
|
||
|
|
vec2 SampleCircleSmol[8] = vec2[8](
|
||
|
|
vec2(0.0f*pixel,1.0f*pixel),
|
||
|
|
vec2(0.7071067811865475f*pixel,0.7071067811865476f*pixel),
|
||
|
|
vec2(1.0f*pixel,0.00000000000000006123233995736766f*pixel),
|
||
|
|
vec2(0.7071067811865476f*pixel,-0.7071067811865475f*pixel),
|
||
|
|
vec2(0.00000000000000012246467991473532f*pixel,-1.0f*pixel),
|
||
|
|
vec2(-0.7071067811865475f*pixel,-0.7071067811865477f*pixel),
|
||
|
|
vec2(-1.0f*pixel,-0.00000000000000018369701987210297f*pixel),
|
||
|
|
vec2(-0.7071067811865477f*pixel,0.7071067811865474f*pixel)
|
||
|
|
);
|
||
|
|
|
||
|
|
vec2 SampleDirs[4] = vec2[4](vec2(-pixel,0),
|
||
|
|
vec2(0,-pixel),
|
||
|
|
vec2(0,pixel),
|
||
|
|
vec2(pixel,0));
|
||
|
|
|
||
|
|
float euler = 2.71828182845904523536f;
|
||
|
|
|
||
|
|
float distribution = 7.5f;
|
||
|
|
|
||
|
|
float maxinc = 0.5f;
|
||
|
|
|
||
|
|
float gaussian(float x){
|
||
|
|
return maxinc * pow(euler,
|
||
|
|
-(pow(x,2)
|
||
|
|
/
|
||
|
|
pow(2f*distribution,2)));
|
||
|
|
}
|
||
|
|
|
||
|
|
void main(){
|
||
|
|
vec4 color = texture(Tex,TexCoord.xy);
|
||
|
|
|
||
|
|
FragColor = color;
|
||
|
|
|
||
|
|
if(color.a != 1){
|
||
|
|
for(int j = 1; j <= 2; j++){
|
||
|
|
for(int i = 0; i < 8; i++){
|
||
|
|
float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircleSmol[i].xy * j))).a;
|
||
|
|
|
||
|
|
if(Test != 0)
|
||
|
|
FragColor = vec4(accentColor,1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if(color.a > 0){
|
||
|
|
bool hit = false;
|
||
|
|
|
||
|
|
for(int j = 0; j < 45; j += 9){
|
||
|
|
float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircle[j].xy * 64))).a;
|
||
|
|
|
||
|
|
if(Test == 0){
|
||
|
|
hit = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if(hit){
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
bool finished = false;
|
||
|
|
for(float i = 1; i < 64; i += 2){
|
||
|
|
int step = int(45f/(2f*i));
|
||
|
|
if(step == 0){
|
||
|
|
step = 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
for(int j = 0; j < 45; j += step){
|
||
|
|
float Test = texture(Tex, vec2(TexCoord.xy + (SampleCircle[j].xy * i))).a;
|
||
|
|
|
||
|
|
if(Test == 0 && !finished){
|
||
|
|
float val = gaussian(i);
|
||
|
|
|
||
|
|
FragColor = vec4((accentColor * val * 2 ) + (color.xyz * 1f - val ),1);
|
||
|
|
finished = true;
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|