
uniform sampler2D sInput1;
uniform float Hue;
uniform float Sat;
uniform float Value;
uniform float BlurStart;
uniform float BlurWidth;
uniform vec2 Center;
uniform float nSamples;
uniform vec3 ColorOffset;
vec3 changeC = ColorOffset;
void main()
{
vec4 finalColor;
vec4 c = vec4(0.0);
vec3 grey= vec3(0.0);
vec4 color = vec4(0.0);
float alpha = 0.0;
for(int i=0; i<int(nSamples); i++)
{
float cMax, cMin;
float D;
float H, S, V;
float vR, vG, vB;
float dR,dG,dB;
float scale = BlurStart + BlurWidth*(float(i)/(nSamples1.0));
c = texture2D(sInput1, gl_TexCoord[0].st*scale + Center);
//convert to single color
float luma = (c.r+c.g+c.b)/3;
grey = vec3(luma);
if (luma > 0.10)
{
alpha = 1.0;
}
else
{
alpha = 0.0;
}
color += vec4(grey * changeC,alpha);
vR = color.r;
vG = color.g;
vB = color.b;
// convert to HSV
cMax = max(vR,max(vG,vB));
cMin = min(vR,min(vG,vB));
D = cMax  cMin;
V= cMax;
if (D == 0.0)
{
H = 0.0;
S = 0.0;
}
else
{
S = D/cMax;
dR = (((cMaxvR)/6)+(D/2))/D;
dG = (((cMaxvG)/6)+(D/2))/D;
dB = (((cMaxvB)/6)+(D/2))/D;
if (vR==cMax) H = dBdG;
else if (vG==cMax) H = (1/3)+dRdB;
else if (vB==cMax) H = (2/3)+dGdR;
if (H<0) H += 1;
if (H>1) H = 1;
}
H += Hue + (float(i)/(nSamples));
S *= Sat;
V *= Value;
// convert to RGB
float R,G,B;
float vh,vi,vr,vg,vb,v1,v2,v3;
if (S == 0)
{
R = V;
B = V;
}
else
{
vh = H*6;
if (vh==6) vh=0;
vi = int(vh);
v1 = V * (1S);
v2 = V * (1S*(vhvi));
v3 = V * (1S*(1(vhvi)));
if (vi == 0) { vr = V ; vg = v3; vb = v1;}
else if (vi == 1) { vr = v2; vg = V ; vb = v1;}
else if (vi == 2) { vr = v1; vg = V ; vb = v3;}
else if (vi == 3) { vr = v1; vg = v2; vb = V ;}
else if (vi == 4) { vr = v3; vg = v1; vb = V ;}
else { vr = V ; vg = v1; vb = v2;}
R = vr;
G = vg;
B = vb;
finalColor= vec4(R,G,B,1.0);
}
}
finalColor /= nSamples;
gl_FragColor = finalColor;
}
for(int i=0; i<int(nSamples); i++)
{
float scale = BlurStart + BlurWidth*(float(i)/(nSamples1));
color = texture2D(sInput1, gl_TexCoord[0].st*scale + Center);
c += color;
}
c /= (nSamples);
gl_FragColor = c;
Return to General TouchDesigner Discussion
Users browsing this forum: No registered users and 25 guests