So i've been experimenting with ISF, and was wondering if anyone could point me in the direction for some good resources for learning to code with GL shaders?
as far as modifying, or integrating existing patches, such as the one pasted below this message, i would love to know a bit more about how a file is modified to be read by VDMX> for example, in quartz publishing in/outs etc to get the patch to register with vdmx.
here is an example patch from the glsl.heroku site:
https://glsl.heroku.com/e#13097.1
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
varying vec2 surfacePosition;
const vec2 nullVector=vec2(0.0);
const float pi=3.141592653;
struct segment{
vec2 p1;
vec2 p2;
};
struct triangle{
vec2 p1;
vec2 p2;
vec2 p3;
};
float length2(vec2 v){
return v.x*v.x+v.y*v.y;
}
float distanceToSegment(vec2 pos,segment s){
vec2 v=s.p2-s.p1;
pos-=s.p1;
float t = dot(pos , v)/ length2(v);
if (t < 0.0){ return length(pos);} // Beyond the 'v' end of the segment
else if (t > 1.0){ return distance(pos, v);} // Beyond the 'w' end of the segment
return distance(pos, t*v);
}
float distanceToTriangle(vec2 pos,triangle t){
float d1=distanceToSegment(pos,segment(t.p1,t.p2));
float d2=distanceToSegment(pos,segment(t.p2,t.p3));
float d3=distanceToSegment(pos,segment(t.p3,t.p1));
return min(d1,min(d2,d3));
}
vec2 rotate(vec2 p,vec2 o,float a){
float sina=sin(a);
float cosa=cos(a);
p-=o;
return vec2(p.x*cosa-p.y*sina,p.x*sina+p.y*cosa)+o;
}
float triangleMod1(float f){
return abs(fract(f)-0.5)*2.0;
}
float xor(float a,float b){
return 1.0-(a*a)/(b*b);
}
const float speed=0.1;
const vec2 p=vec2(0.3,0.3);
const vec2 o=vec2(0.5,0.5);
void main( void ) {
vec2 pos=surfacePosition;
triangle t1=triangle(rotate(p,o,speed*time),rotate(p,o,speed*time+2.0*pi/3.0),rotate(p,o,speed*time+4.0*pi/3.0));
triangle t2=triangle(rotate(p,o,-speed*time+pi/3.0),rotate(p,o,-speed*time+2.0*pi/3.0+pi/3.0),rotate(p,o,-speed*time+4.0*pi/3.0+pi/3.0));
float d1=triangleMod1(distanceToTriangle(pos,t1)*25.0);
float d2=triangleMod1(distanceToTriangle(pos,t2)*25.0);
float d=xor(d1,d2);
gl_FragColor=vec4(d,d,d,1.0);
}