Skip to content

Instantly share code, notes, and snippets.

@drewgillievfx
Created May 10, 2020 17:17
Show Gist options
  • Save drewgillievfx/d3ea3acb006b8279a1bddf9eebd6af61 to your computer and use it in GitHub Desktop.
Save drewgillievfx/d3ea3acb006b8279a1bddf9eebd6af61 to your computer and use it in GitHub Desktop.
// Diffuse Color
shader
colorByP(float minheight = 1.25,
float maxheight = 1.25,
color mincolor = color(1,0,0),
color maxcolor = color(0,1,0),
output color resultRGB = 0
)
{
point p = transform("world", P);
float blend = smoothstep(minheight, maxheight, p[1]);
resultRGB = mix(mincolor, maxcolor, blend);
}
// Bump - SeExpression
length_xyz =floatInput1; #0.0,2.0
width1_xyz =floatInput2; #0.0,2.0
width2_xyz =floatInput3; #0.0,2.0
x1 = choose(width1_xyz/2,P[0],P[1],P[2]);
y1 = choose(width2_xyz/2,P[0],P[1],P[2]);
ss = choose(length_xyz/2,P[0],P[1],P[2]);
x = x1;
y = y1;
tt = (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;
tt = tt/(2*PI);
twist =floatInput4; # 1,200.00
threadCount =1.000; #1,20.00
grooveShape =3.487; #0.1,10.00
disp = (ss*threadCount - tt*twist)%1;
disp = ((disp -.5)*2) -> abs() -> pow(grooveShape) -> invert();
disp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment