Skip to content

Instantly share code, notes, and snippets.

@oprypin
Created July 18, 2021 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oprypin/ba18db84e5e55ddc6d07a661062ae186 to your computer and use it in GitHub Desktop.
Save oprypin/ba18db84e5e55ddc6d07a661062ae186 to your computer and use it in GitHub Desktop.
#version 130
uniform sampler2D source;
in vec2 tex_coords;
out vec4 frag_color;
void main() {
ivec2 coord = ivec2(vec2(textureSize(source, 0)) * tex_coords);
vec3 result = vec3(0, 0, 0);
float a = 0;
vec4 px;
float result_malpha = 0;
float result_max = 0;
<%- (-glow_resolution..glow_resolution).each do |i| -%>
<%- m = gauss(i) / gauss(-glow_resolution, glow_resolution) * glow_intensity -%>
px = texelFetch(source, coord + ivec2(<%= horizontal ? i : 0 %>, <%= horizontal ? 0 : i %>), 0);
result += px.rgb * px.a * <%= m %>;
result_malpha += px.a * <%= m %>;
result_max += <%= m %>;
a += px.a * <%= m %>;
<%- end -%>
frag_color = vec4(result / result_malpha * result_max, a);
}
glow_resolution = (resolution * (GlowTarget.size.x + GlowTarget.size.y) / 3000).to_i
glow_intensity = intensity
horizontal = false
GlowShader::Shader1.load_from_memory({{read_file("base.vert.glsl")}}, ECR.render("glow.frag.glsl.ecr"))
horizontal = true
GlowShader::Shader2.load_from_memory({{read_file("base.vert.glsl")}}, ECR.render("glow.frag.glsl.ecr"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment