Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare fragment shader outputs, improving compatibility (macOS) #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion shaders/simple_color.frag
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

in vec4 out_color;

out vec4 fragColor;

void main() {
gl_FragColor = out_color;
fragColor = out_color;
}
4 changes: 3 additions & 1 deletion shaders/simple_epic.frag
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ uniform sampler2D image;

in vec2 out_uv;

out vec4 fragColor;

vec3 hsl2rgb(vec3 c) {
vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0);
return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0));
Expand All @@ -18,5 +20,5 @@ void main() {
float alpha = smoothstep(0.5 - aaf, 0.5 + aaf, d);
vec2 frag_uv = gl_FragCoord.xy / resolution;
vec4 rainbow = vec4(hsl2rgb(vec3((time + frag_uv.x + frag_uv.y), 0.5, 0.5)), 1.0);
gl_FragColor = vec4(rainbow.rgb, alpha);
fragColor = vec4(rainbow.rgb, alpha);
}
4 changes: 3 additions & 1 deletion shaders/simple_image.frag
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ uniform sampler2D image;

in vec2 out_uv;

out vec4 fragColor;

void main() {
gl_FragColor = texture(image, out_uv);
fragColor = texture(image, out_uv);
}
4 changes: 3 additions & 1 deletion shaders/simple_text.frag
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ uniform sampler2D image;
in vec4 out_color;
in vec2 out_uv;

out vec4 fragColor;

void main() {
float d = texture(image, out_uv).r;
float aaf = fwidth(d);
float alpha = smoothstep(0.5 - aaf, 0.5 + aaf, d);
gl_FragColor = vec4(out_color.rgb, alpha);
fragColor = vec4(out_color.rgb, alpha);
}