0.5) { thisPix.r = clamp(source.r + ((thisPix.r-0.5) * opAlpha),0.0,1.0); }
else { thisPix.r = clamp(source.r - ((0.5-thisPix.r) * opAlpha),0.0,1.0); }
if (thisPix.g > 0.5) { thisPix.g = clamp(source.g + ((thisPix.g-0.5) * opAlpha),0.0,1.0); }
else { thisPix.g = clamp(source.g - ((0.5-thisPix.g) * opAlpha),0.0,1.0); }
if (thisPix.b > 0.5) { thisPix.b = clamp(source.b + ((thisPix.b-0.5) * opAlpha),0.0,1.0); }
else { thisPix.b = clamp(source.b - ((0.5-thisPix.b) * opAlpha),0.0,1.0); }
thisPix.a = 1.0;
}
if (thisMode == 14) {
thisPix.r = clamp(source.r / ((1.0 - (thisPix.r*opAlpha) +.0001)),0.0,1.0);
thisPix.g = clamp(source.g / ((1.0 - (thisPix.g*opAlpha) +.0001)),0.0,1.0);
thisPix.b = clamp(source.b / ((1.0 - (thisPix.b*opAlpha) +.0001)),0.0,1.0);
thisPix.a = 1.0;
}
if (thisMode >= 15) {
thisPix.r = clamp((1.0-(1.0-source.r)/(thisPix.r+0.0001)),0.0,1.0);
thisPix.g = clamp((1.0-(1.0-source.g)/(thisPix.g+0.0001)),0.0,1.0);
thisPix.b = clamp((1.0-(1.0-source.b)/(thisPix.b+0.0001)),0.0,1.0);
thisPix.a = 1.0;
vec4 mix = thisPix;
mix.r = (source.r*thisAlpha) + (thisPix.r*opAlpha);
mix.g = (source.g*thisAlpha) + (thisPix.g*opAlpha);
mix.b = (source.b*thisAlpha) + (thisPix.b*opAlpha);
thisPix = mix;
}
thisPix.r = (source.r * (1.0-alphaChannel)) + (thisPix.r * alphaChannel);
thisPix.g = (source.g * (1.0-alphaChannel)) + (thisPix.g * alphaChannel);
thisPix.b = (source.b * (1.0-alphaChannel)) + (thisPix.b * alphaChannel);
if (ignorealpha == 1.0) thisPix.a = 1.0;
return thisPix;
}
vec2 getDisplacementPoint (vec2 uv)
{
vec2 point;
float warpAmount = displacementvalue;
vec4 source=texture2D(tex3,uv);
int mode=int(displacementmode);
float mult = 0.0;
vec2 newpos;
if (mode==0) // off
newpos=vec2(0.0,0.0);
else if (mode==1) // Full Displace
{
mult = (source.r) + (source.g) + (source.b);
mult /= 3.0;
mult *= warpAmount;
newpos = vec2((uv.x - 0.5) *mult,(uv.y - 0.5) *mult);
} else if (mode ==2) // Outer Circle
{
mult = (source.r) + (source.g) + (source.b);
mult /= 3.0;
mult *= warpAmount;
newpos = vec2((uv.x - 0.5) *mult * (1.0 - sin(uv.x * (3.14159))),(uv.y - 0.5) *mult * (1.0 - sin(uv.y * (3.14159))));
} else if(mode==3) // Inner Circle
{
mult = (source.r) + (source.g) + (source.b);
mult /= 3.0;
mult *= warpAmount;
newpos = vec2((uv.x - 0.5) *mult * (sin(uv.x * (3.14159))),(uv.y - 0.5) *mult * (sin(uv.x * (3.14159))));
}
return newpos;
}
vec4 getPixelAt (vec2 uv, vec2 dpoint,vec2 offs) {
vec4 color;
color = texture2D(tex2,uv + dpoint);
color = blendMode (color, blendmode, blendopacity, dpoint,offs);
return color;
}
void main()
{
vec2 p = vec2 ((1.0-positionX) - 0.5,positionY - 0.5) * 2.0;
vec2 z = vec2 (0.5 + (zoomLevel)-0.5,0.5+(zoomLevel) - 0.5) *4.0;
vec2 uv = (gl_FragCoord.xy-vec2(viewportX,viewportY)) / iResolution.xy;
uv.x = uv.x + p.x;
uv.y = uv.y + p.y;
uv.x -= 0.5;
uv.y -= 0.5;
uv *= z;
uv.x += 0.5;
uv.y += 0.5;
if (clampMode == 1) {
uv.x = clamp(uv.x,0.0,1.0);
uv.y = clamp(uv.y,0.0,1.0);
}
vec2 dpoint = getDisplacementPoint (uv);
if (clampMode == 0 || clampMode == 1) {
gl_FragColor = getPixelAt (uv, dpoint, p);
} else {
vec2 thisUV = uv + (p * vec2 (0.25 - (zoomLevel*0.25),0.25- (zoomLevel*0.25)) );
if (thisUV.x >= 0.0 && thisUV.x <= 1.0 && thisUV.y >= 0.0 && thisUV.y <= 1.0)
{
gl_FragColor = getPixelAt (uv, dpoint, p);
}
else {
gl_FragColor = vec4 (0.0,0.0,0.0,0.0);
}
}
}]]>