Skip to content

Instantly share code, notes, and snippets.

@CharStiles
Created July 6, 2019 18:32
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 CharStiles/f49fcd90134ca75ebace1fb43d2276cd to your computer and use it in GitHub Desktop.
Save CharStiles/f49fcd90134ca75ebace1fb43d2276cd to your computer and use it in GitHub Desktop.
/*{
"DESCRIPTION": "",
"CREDIT": "",
"ISFVSN": "2",
"CATEGORIES": [
"XXX"
],
"INPUTS": [
{
"NAME": "inputImage",
"TYPE": "image"
},
{
"NAME": "boolInput",
"TYPE": "bool",
"DEFAULT": 1.0
},
{
"NAME": "colorInput",
"TYPE": "color",
"DEFAULT": [
0.0,
0.0,
1.0,
1.0
]
},
{
"NAME": "flashInput",
"TYPE": "event"
},
{
"NAME": "floatInput",
"TYPE": "float",
"DEFAULT": 0.5,
"MIN": 0.0,
"MAX": 1.0
},
{
"NAME": "longInputIsAPopUpButton",
"TYPE": "long",
"VALUES": [
0,
1,
2
],
"LABELS": [
"red",
"green",
"blue"
],
"DEFAULT": 1
},
{
"NAME": "pointInput",
"TYPE": "point2D",
"DEFAULT": [
0,
0
]
}
],
"PASSES": [
{
"TARGET":"bufferVariableNameA",
"WIDTH": "$WIDTH/16.0",
"HEIGHT": "$HEIGHT/16.0"
},
{
"DESCRIPTION": "this empty pass is rendered at the same rez as whatever you are running the ISF filter at- the previous step rendered an image at one-sixteenth the res, so this step ensures that the output is full-size"
}
]
}*/
// http://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
float equiTri(vec2 p){
float side = sqrt(3.0);
p.x = abs(p.x) - 1.0;
p.y = p.y +1.0/side;
if(p.x + side*p.y > 0.0){
p = vec2(p.x - side*p.y, -side*p.x - p.y)/2.0;
}
p.x -= clamp(p.x,-2.0,0.0);
return -length(p)*sign(p.y);
}
// http://www.iquilezles.org/www/articles/palettes/palettes.htm
// As t runs from 0 to 1 (our normalized palette index or domain),
//the cosine oscilates c times with a phase of d.
//The result is scaled and biased by a and b to meet the desired constrast and brightness.
vec3 cosPalette( float t, vec3 a, vec3 b, vec3 c, vec3 d )
{
return a + b*cos( 6.28318*(c*t+d) );
}
void main()
{
// distance metric
vec2 uv = (isf_FragNormCoord * vec2(2)) -vec2(1);
float shape = equiTri(uv * vec2(3.0));
vec3 col = cosPalette(0.5,vec3(0.5),vec3(0.5),vec3(1),vec3(TIME*0.01,TIME*0.1,TIME*.2));
// lighting: darken at the center
col = vec3(shape) * col;
// output: pixel color
gl_FragColor = min(vec4( col.rgb, 1.0 ), vec4(0.8,0.8,0.8,1.0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment