Created
May 10, 2020 17:13
-
-
Save drewgillievfx/d05e84472d8e40b3584cc42edd8eb70e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Layer 1 SeExpression | |
#Stained | |
Scale=floatInput1; | |
Jitter=floatInput2; | |
fbmScale=floatInput3; | |
fbmOctaves=floatInput4; | |
fbmLacunarity=floatInput3; | |
fbmGain=floatInput1; | |
Scale = (1-Scale)*10; | |
fbmOctaves = fbmOctaves*9+1; | |
fbmLacunarity = fbmLacunarity*3+1; | |
Cv2 = cvoronoi(P*Scale,1,Jitter,fbmScale,fbmOctaves,fbmLacunarity,fbmGain)->clamp(0,1)->contrast(.4)->invert()->contrast (.9); | |
Cv1 = cvoronoi(P*Scale,1,Jitter,fbmScale,fbmOctaves,fbmLacunarity,fbmGain)*.5+.5; | |
Cv2 | |
/*---------------------------------------------------------*/ | |
// Layer 2 OSL | |
float | |
voronoi1D (point Pv, | |
float jitter) | |
{ | |
point thiscell = point (floor(Pv[0])+0.5, floor(Pv[1])+0.5, | |
floor(Pv[2])+0.5); | |
float f1 = 1000; /* f1 is dist2nearest */ | |
int i, j, k; | |
for (i = -1; i <= 1; i += 1) { | |
for (j = -1; j <= 1; j += 1) { | |
for (k = -1; k <= 1; k += 1) { | |
point testcell = thiscell + vector(i,j,k); | |
point pos = testcell + | |
jitter * (cellnoise (testcell) - 0.5); | |
vector offset = pos - Pv; | |
float dist = dot (offset , offset); /* actually dist^2 */ | |
if (dist < f1) { | |
f1 = dist; | |
} | |
} | |
} | |
} | |
return sqrt(f1); | |
} | |
shader voronoi(float jitter = 0.5, | |
output float Fout = 0, | |
output color resRGB = color(0)) | |
{ | |
float result = voronoi1D(P, jitter); | |
Fout = result * result; | |
resRGB = color(Fout, Fout, Fout); | |
} | |
//------// | |
# Layer 2 // SeExpression | |
Twist =floatInput1; #0,30.00 | |
Slope =-floatInput2; #-15,15 | |
stripes =floatInput3; # 1,10 | |
adjust =floatInput4; #1,10.00 | |
thicknessA =0.025; | |
thicknessB =0.025; | |
thicknessC =0.025; | |
thicknessD =0.310; | |
offsetA =0.493; #0,1.00 | |
offsetB =-0.042; #-1.00,1.00 | |
offsetC =0.413; #0,1.00 | |
offsetD =0.634; #0,1.00 | |
## Stripe A | |
x = P[0]; y = P[2]; z = P[1]; | |
rho = (x > 0 && y >= 0) ? atan(y/x): | |
(x > 0 && y < 0) ? atan(y/x) + 2*PI : | |
(x <0) ? atan(y/x) + PI : | |
(x == 0 && y > 0) ? PI/2: | |
(x == 0 && y < 0) ? 3*PI/2: 0; | |
rho = rho/(PI*2)-offsetA; | |
theta = atan(sqrt( pow(x,2)+pow(y,2)) / z); | |
theta = theta/ (PI/2); | |
x = rho; | |
y = (P[1] - 7.048) /adjust;#(18.072); | |
y = y * Twist; | |
x = x * Slope; | |
mask = ((x + y)*stripes) %1; | |
mask = mask > thicknessA; | |
CoutA =mask; | |
## Stripe B | |
x = P[0]; y = P[2]; z = P[1]; | |
rho = (x > 0 && y >= 0) ? atan(y/x): | |
(x > 0 && y < 0) ? atan(y/x) + 2*PI : | |
(x <0) ? atan(y/x) + PI : | |
(x == 0 && y > 0) ? PI/2: | |
(x == 0 && y < 0) ? 3*PI/2: 0; | |
rho = rho/(PI*2)+offsetB; | |
#rho = rho/(PI*2)+testX; | |
theta = atan(sqrt( pow(x,2)+pow(y,2)) / z); | |
theta = theta/ (PI/2); | |
x = rho; | |
y = (P[1] - 7.048) /adjust;#(18.072); | |
y = y * Twist; | |
x = x * Slope; | |
mask = ((x + y)*stripes) %1; | |
mask = mask > thicknessB; | |
CoutB =mask; | |
## Stripe C | |
x = P[0]; y = P[2]; z = P[1]; | |
rho = (x > 0 && y >= 0) ? atan(y/x): | |
(x > 0 && y < 0) ? atan(y/x) + 2*PI : | |
(x <0) ? atan(y/x) + PI : | |
(x == 0 && y > 0) ? PI/2: | |
(x == 0 && y < 0) ? 3*PI/2: 0; | |
rho = rho/(PI*2)+offsetC; | |
theta = atan(sqrt( pow(x,2)+pow(y,2)) / z); | |
theta = theta/ (PI/2); | |
x = rho; | |
y = (P[1] - 7.048)/ adjust;#(18.072); | |
y = y * Twist; | |
x = x * Slope; | |
mask = ((x + y)*stripes) %1; | |
mask = mask > thicknessC; | |
CoutC =mask; | |
## Stripe D | |
x = P[0]; y = P[2]; z = P[1]; | |
rho = (x > 0 && y >= 0) ? atan(y/x): | |
(x > 0 && y < 0) ? atan(y/x) + 2*PI : | |
(x <0) ? atan(y/x) + PI : | |
(x == 0 && y > 0) ? PI/2: | |
(x == 0 && y < 0) ? 3*PI/2: 0; | |
rho = rho/(PI*2)+offsetD; | |
theta = atan(sqrt( pow(x,2)+pow(y,2)) / z); | |
theta = theta/ (PI/2); | |
x = rho; | |
y = (P[1] - 7.048)/ adjust;#(18.072); | |
y = y * Twist; | |
x = x * Slope; | |
mask = ((x + y)*stripes) %1; | |
mask = mask > thicknessD; | |
CoutD =mask; | |
## Min the 3 together | |
temp1 = min(CoutA, CoutB ); | |
temp2 =min(CoutC, CoutD ); | |
Cout = min(temp1, temp2); | |
Cout | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment