原始图像
处理后
源码
1 #version 330 core 2 out vec4 FragColor; 3 in vec2 TexCoords; 4 uniform sampler2D screenTexture; 5 6 void main() 7 { 8 vec2 uv = TexCoords; 9 vec4 clraverge = vec4(0, 0, 0, 0); 10 float range = 10.0; 11 float count = 0; 12 vec2 cpos = vec2(0.5, 0.5); 13 float x1, y1; 14 for (float j = 1; j <= range; j++) 15 { 16 if (cpos.x - uv.x == 0) 17 { 18 x1 = uv.x; 19 y1 = uv.y + (cpos.y - uv.y) * j / (10 * range); 20 } 21 else 22 { 23 float k = (cpos.y - uv.y) / (cpos.x - uv.x); 24 x1 = uv.x + (cpos.x - uv.x) * j / (10.0 * range); 25 y1 = cpos.y - (cpos.x - x1) * k; 26 27 if (x1 < 0.0 || y1 < 0.0 || x1 > 1.0 || y1 > 1.0) 28 { 29 continue; 30 } 31 } 32 clraverge += texture(screenTexture, vec2(x1, y1)); 33 count += 1; 34 } 35 clraverge /= count; 36 37 FragColor = clraverge; 38 }