теперь к фотошопу
забыл привести эту цитату
помогал кому- то недавно, а ты думал я о бабочках рассказывал?
[quot]kernel D
< namespace : "com.filters";
vendor :
version : 1;
description : "effect.";
>
{
input image4 src;
output pixel4 dst;
parameter int2 size
<
minValue:int2(100, 100);
maxValue:int2(4000, 4000);
defaultValue:int2(600, 600);
description: "Set to match source image size";
>;
parameter float innerRadius
<
minValue:0.1;
maxValue:100.0;
defaultValue:25.0;
description: "The inner radius of the repeating annular";
>;
parameter float outerRadius
<
minValue:1.0;
maxValue:100.0;
defaultValue:100.0;
description: "The outer radius of the repeating annular";
>;
parameter float periodicity
<
minValue:-6.0;
maxValue: 6.0;
defaultValue:1.0;
description: "The number of image the image is repeated on each level";
>;
parameter float strands
<
minValue:-6.0;
maxValue: 6.0;
defaultValue:1.0;
description: "The number of strands of the spiral";
>;
parameter int strandMirror
<
minValue:0;
maxValue:1;
defaultValue:0;
description: "Activate for smoother repeating when using more than one strand";
>;
parameter float zoom
<
minValue:0.0;
maxValue:30.0;
defaultValue:0.0;
description: "Overall image magnification";
>;
parameter float rotate
<
minValue:-360.0;
maxValue: 360.0;
defaultValue:0.0;
description: "Overall image rotation";
>;
parameter float2 center
<
minValue:float2(-200.0, -200.0);
maxValue:float2(200.0, 200.0);
defaultValue:float2(0.0, 0.0);
description: "Panning of the image in the output frame";
>;
parameter float2 centerShift
<
minValue:float2(-200.0, -200.0);
maxValue:float2(200.0, 200.0);
defaultValue:float2(0.0, 0.0);
description: "Shift the centre of the spiral";
>;
parameter int numberOfLevels
<
minValue:1;
maxValue:20;
defaultValue:9;
description: "The number of repeating levels of the spiral";
>;
parameter int startLevel
<
minValue:1;
maxValue:20;
defaultValue:3;
description: "The starting spiral level";
>;
parameter int enableTransparencyInside
<
minValue:0;
maxValue:1;
defaultValue:0;
description: "Enable for images with transparent middle areas (such as a picture frame).";
>;
parameter int enableTransparencyOutside
<
minValue:0;
maxValue:1;
defaultValue:0;
description: "Enable for images with transparent areas around the outside.";
>;
parameter int untwist
<
minValue:0;
maxValue:1;
defaultValue:0;
description: "Unroll the circular annular of the image.";
>;
parameter int setAutoPeriodicity
<
minValue:0;
maxValue:1;
defaultValue:0;
description: "Automatically set the ideal periodicity for the current radius settings.";
>;
parameter float3 polarCoordinates
<
minValue: float3(-180, -100, -100);
maxValue: float3(180, 100, 100);
defaultValue: float3(90, 0, 0);
description: "Polar rotation, latitude and longitude";
>;
parameter int enablePoles
<
minValue:0;
maxValue:1;
defaultValue:0;
description: "Show both poles";
>;
parameter int enableHyperDroste
<
minValue:0;
maxValue:1;
defaultValue:0;
description: "Enable hyper droste effect. Applies when enablePoles active.";
>;
parameter int tilePoles
<
minValue:0;
maxValue:1;
defaultValue:0;
description: "Enable for hyper droste option.";
>;
parameter int fractalPoints
<
minValue:1;
maxValue:10;
defaultValue:1;
description: "Used by hyper droste option.";
>;
dependent float r1, r2, p1, p2, w, h, alphaThreshold;
dependent float2 _shift, _center, _rotate, _zoom, xBounds, yBounds, xyMiddle, minDimension;
dependent bool showPoles, hyperDroste, tileBasedOnTransparency, transparentPointsIn, twist;
// Initialize parameters
void evaluateDependents()
{
// Set code variables
r1 = innerRadius / 100.0;
r2 = outerRadius / 100.0;
p1 = periodicity;
if (p1 == 0.0) p1 = 0.001; // Prevent divide by zero
p2 = strands;
transparentPointsIn = enableTransparencyOutside == 0 ? true : false;
tileBasedOnTransparency = (enableTransparencyInside == 1 || !transparentPointsIn) ? true : false;
twist = untwist == 0 ? true : false;
alphaThreshold = 0.01;
_shift = 1.0 + centerShift / 100.0;
_center = (float2(size) / 2.0) + center * (float2(size) / 2.0) / 100.0;
w = float(size.x);
h = float(size.y);
minDimension = float2(min(w, h) / 2.0);
// Autoset periodicity
if (setAutoPeriodicity == 1) {
p1 = p2/2.0 * (1.0 + sqrt(1.0 - pow(log(r2/r1)/PI, 2.0)));
}
// Set rotation
_rotate = p1 > 0.0 ? float2(-(PI/180.0) * rotate, 0.0) : float2((PI/180.0) * rotate, 0.0);
// Set zoom
_zoom = float2((exp(zoom) + innerRadius - 1.0) / 100.0, 0.0);
// Scale viewport pixels to complex plane
if (twist) {
xBounds = float2(-r2, r2);
yBounds = float2(-r2, r2);
} else {
xBounds = float2(-log(r2/r1), log(r2/r1));
yBounds = float2(0.0, 2.1 * PI);
}
xyMiddle = float2((xBounds.x + xBounds.y) / 2.0, (yBounds.x + yBounds.y) / 2.0);
float2 xyRange = float2(xBounds.y - xBounds.x, yBounds.y - yBounds.x);
xyRange.x = xyRange.y * (w / h);
xBounds = float2(xyMiddle.x - xyRange.x/2.0, xyMiddle.x + xyRange.x/2.0);
// Polar options
showPoles = enablePoles == 1 ? true : false;
hyperDroste = enableHyperDroste == 1 ? true : false;
}
void renderPixel(
in float2 z,
inout float alphaRemaining,
inout int sign,
inout int iteration,
inout pixel4 colorSoFar
)
{
float2 d = minDimension * (z + _shift);
sign = 0;
if (tileBasedOnTransparency || iteration == 0) {
dst = sample(src, d);
colorSoFar += dst * (dst.a * alphaRemaining);
alphaRemaining *= (1.0 - dst.a);
}
if (tileBasedOnTransparency) {
if ( transparentPointsIn && alphaRemaining > alphaThreshold) sign = -1;
if (!transparentPointsIn && alphaRemaining > alphaThreshold) sign = 1;
} else {
if (iteration > 0) colorSoFar = sample(src, d);
float radius = length(z);
sign = (radius < r1) ? -1 : (radius > r2 ? 1 : 0);
}
iteration += 1;
}
void evaluatePixel()
{
float2 s = outCoord();
float2 z, d, ratio, polar;
float radius, theta, div;
int iteration;
int sign = 0;
float alphaRemaining = 1.0;
z = float2((xBounds.x + (xBounds.y - xBounds.x) * ((s.x - _center.x) + w / 2.0) / w),
(yBounds.x + (yBounds.y - yBounds.x) * ((s.y - _center.y) + h / 2.0) / h));
// Only allow for procedural zooming/scaling in the standard coordinates
if (twist) {
z = xyMiddle + complexMult(complexDivision((z - xyMiddle), _zoom), complexExp(complexMult(-I, _rotate)));
}
// Extra options
polar = (float2(polarCoordinates.y, polarCoordinates.z) * w / s.x) / 100.0;
if (showPoles) {
theta = (PI/180.0) * polarCoordinates.x;
div = (1.0 + pow(z.x, 2.0) + pow(z.y, 2.0) + ((1.0 - pow(z.x, 2.0) - pow(z.y, 2.0)) * cos(theta)) - (2.0 * z.x * sin(theta))) / 2.0;
z.x = z.x * cos(theta) + ((1.0 - pow(z.x, 2.0) - pow(z.y, 2.0)) * sin(theta) / 2.0);
z = complexDivision(z, float2(div, 0.0));
} else {
if (hyperDroste) {
z = complexSin(z);
}
if (tilePoles == 1) {
z = power(z, fractalPoints);
z = complexTan(complexMult(z, float2(2.0, 0.0)));
}
}
z += polar;
if (twist) {
z = complexLog(complexDivision(z, float2(r1, 0.0)));
}
// Start Droste-effect code
float2 alpha = float2(atan((p2/p1) * (log(r2/r1) / (2.0*PI))), 0.0);
float2 f = float2(cos(alpha.x), 0.0);
float2 beta = complexMult(f, complexExp(complexMult(alpha, I)));
// The angle of rotation between adjacent annular levels
float2 angle = float2(-2.0 * PI * p1, 0.0);
if (p2 > 0.0) angle = -angle;
if (strandMirror == 1) angle /= strands;
z = complexDivision(complexMult(float2(p1, 0.0), z), beta);
z = complexMult(float2(r1, 0.0), complexExp(z));
// End Droste-effect code
// Start drawing
if (tileBasedOnTransparency && startLevel > 0) {
if (!transparentPointsIn) ratio = complexMult(float2(r2/r1, 0.0), complexExp(complexMult(angle, I)));
if ( transparentPointsIn) ratio = complexMult(float2(r1/r2, 0.0), complexExp(complexMult(angle,-I)));
z = complexMult(z, power(ratio, startLevel));
}
pixel4 colorSoFar = pixel4(0.0, 0.0, 0.0, 0.0);
iteration = 0;
renderPixel(z, alphaRemaining, sign, iteration, colorSoFar);
if (sign < 0) ratio = complexMult(float2(r2/r1, 0.0), complexExp(complexMult(angle, I)));
if (sign > 0) ratio = complexMult(float2(r1/r2, 0.0), complexExp(complexMult(angle, -I)));
iteration = startLevel;
int maxIteration = numberOfLevels + startLevel - 1;
while (sign != 0 && iteration < maxIteration) {
z = complexMult(z, ratio);
renderPixel(z, alphaRemaining, sign, iteration, colorSoFar);
}
dst = colorSoFar;
}
}[/quot]