Skip to content

Commit

Permalink
fix: shaders
Browse files Browse the repository at this point in the history
Updates shaders for new GLSL version in LÖVE 11; fixes #30
  • Loading branch information
qixils committed Mar 5, 2023
1 parent 1a33c59 commit ea27994
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions shaders/dotnbloom.frag
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ float color_bloom(vec3 color)
return mix(1.0 + shine, 1.0 - shine, bright);
}

vec3 lookup(Image texture, float offset_x, float offset_y, vec2 coord)
vec3 lookup(Image texture, vec2 tex, float offset_x, float offset_y, vec2 coord)
{
vec2 offset = vec2(offset_x, offset_y);
vec3 color = Texel(texture, coord).rgb;
float delta = dist(fract(gl_TexCoord[0].xy * textureSize), offset + vec2(0.5));
float delta = dist(fract(tex.xy * textureSize), offset + vec2(0.5));
return color * exp(-gamma * delta * color_bloom(color));
}

Expand All @@ -50,17 +50,17 @@ vec4 effect(vec4 vcolor, Image texture, vec2 tex, vec2 pixel_coords)
vec2 c12 = tex + vec2( 0, dy);
vec2 c22 = tex + vec2( dx, dy);

vec3 mid_color = lookup(texture, 0.0, 0.0, c11);
vec3 mid_color = lookup(texture, tex, 0.0, 0.0, c11);
vec3 color = vec3(0.0);
color += lookup(texture, -1.0, -1.0, c00);
color += lookup(texture, 0.0, -1.0, c10);
color += lookup(texture, 1.0, -1.0, c20);
color += lookup(texture, -1.0, 0.0, c01);
color += lookup(texture, tex, -1.0, -1.0, c00);
color += lookup(texture, tex, 0.0, -1.0, c10);
color += lookup(texture, tex, 1.0, -1.0, c20);
color += lookup(texture, tex, -1.0, 0.0, c01);
color += mid_color;
color += lookup(texture, 1.0, 0.0, c21);
color += lookup(texture, -1.0, 1.0, c02);
color += lookup(texture, 0.0, 1.0, c12);
color += lookup(texture, 1.0, 1.0, c22);
color += lookup(texture, tex, 1.0, 0.0, c21);
color += lookup(texture, tex, -1.0, 1.0, c02);
color += lookup(texture, tex, 0.0, 1.0, c12);
color += lookup(texture, tex, 1.0, 1.0, c22);
vec3 out_color = mix(1.2 * mid_color, color, blend);

return vec4(out_color, 1.0);
Expand Down
2 changes: 1 addition & 1 deletion shaders/scanline-3x.frag
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ vec4 effect(vec4 vcolor, Image texture, vec2 texture_coords, vec2 pixel_coords)
intens = vec4(0.0, 0.0, 0.0, 1.0);
else
intens = smoothstep(0.2,0.8,rgb) + normalize(vec4(rgb.xyz, 1.0));
number level = (4.0-gl_TexCoord[0].z) * 0.19;
number level = (4.0-texture_coords.x) * 0.19;
return vec4((intens * (0.5-level) + rgb * 1.1).rgb, 1.0);
}
2 changes: 1 addition & 1 deletion shaders/scanline-4x.frag
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ vec4 effect(vec4 vcolor, Image texture, vec2 texture_coords, vec2 pixel_coords)
intens = vec4(0.0, 0.0, 0.0, 1.0);
else
intens = smoothstep(0.2,0.8,rgb) + normalize(vec4(rgb.xyz, 1.0));
number level = (4.0-gl_TexCoord[0].z) * 0.19;
number level = (4.0-texture_coords.x) * 0.19;
return vec4((intens * (0.5-level) + rgb * 1.1).rgb, 1.0);
}

0 comments on commit ea27994

Please sign in to comment.