Skip to content

Instantly share code, notes, and snippets.

@SimonDanisch
Created May 18, 2017 19:48
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 SimonDanisch/f710e22043e7a599e834bbdb4b3d783f to your computer and use it in GitHub Desktop.
Save SimonDanisch/f710e22043e7a599e834bbdb4b3d783f to your computer and use it in GitHub Desktop.
#version 330
// dependant type declarations
// Julia name: Uniforms
struct Uniforms{
mat4 model;
int max_primtives;
float maxlength;
float thickness;
float pattern_length;
};
// Julia name: Canvas
struct Canvas{
vec2 resolution;
mat4 projection;
mat4 view;
mat4 projectionview;
};
// Julia name: Geom2Fragment
struct Geom2Fragment{
float thickness;
vec4 color;
vec2 uv;
};
// dependant function declarations
float aastep(float threshold1, float threshold2, float value)
{
float afwidth;
afwidth = float(0.001);
return smoothstep(threshold1 - afwidth, threshold1 + afwidth, value) - smoothstep(threshold2 - afwidth, threshold2 + afwidth, value);
}
float aastep(float threshold1, float value)
{
return smoothstep(threshold1 - float(0.001), threshold1 + float(0.001), value);
}
// uniform inputs:
layout (std140) uniform _gensymed_UniformArg1{
Canvas canvas;
};
layout (std140) uniform _gensymed_UniformArg2{
Uniforms uniforms;
};
in Geom2Fragment geom_out;
layout (location = 0) out vec4 _gensymed_color0;
// fragment main function:
void main()
{
vec4 outcolor;
float alpha2;
float alpha;
vec2 xy;
vec4 color;
vec2 uv;
uv = geom_out.uv;
color = geom_out.color;
xy = vec2(0.5, uv.y);
alpha = aastep(0.0, xy.x);
alpha2 = aastep(-1.0, 1.0, xy.y);
outcolor = vec4(color.x, color.y, color.z, color.w * alpha * alpha2);
_gensymed_color0 = outcolor;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment