Shaders
radial shader
/*
* radial shader... dsward@webnation.com
* this shader works best on a square panel.
* it draws rays from the center to the edges.
*/
surface
radial(
float majorAngle = 15;
float minorAngle = 15;
float spiralAngle = 45;
float offsetAngle = 0;
color specularColor = color(0, 0, 0); )
{
float stDist;
float curAngle;
float taperAngle;
float taperBase;
float halfAngle;
float midPt = 0.5;
float ratio;
/* measure the distance from midpoint s,t to current s,t */
point pointA = (s, t, 0);
point pointB = (midPt, midPt, 0);
stDist = distance(pointA, pointB);
/* measure the angle from midpoint s,t to current s,t */
curAngle = degrees(atan((s - midPt), (t - midPt))) +
offsetAngle + ((stDist * 2) * spiralAngle);
if (curAngle < 0) curAngle = 360 + curAngle;
/* find current angle within major angle */
while (curAngle > majorAngle) curAngle = curAngle - majorAngle;
if (curAngle < minorAngle)
{
taperAngle = minorAngle;
halfAngle = taperAngle / 2;
taperBase = halfAngle - (minorAngle / 2);
if (curAngle > taperBase)
{
if (curAngle < (minorAngle - taperBase))
{
if (curAngle > (minorAngle / 2))
{
curAngle = minorAngle - curAngle;
}
Ci = mix (Cs, specularColor, smoothstep (0, halfAngle, curAngle));
}
else
{
Ci = Cs;
}
}
else
{
Ci = Cs;
}
}
else
{
Ci = Cs;
}
}