Monthly Archives: September 2020

tooled steel osl shader by Ivan DeWolf

Ivan DeWolf has created this very cool tooled steel .osl shader.

tooled_steel.osl

“The only real controls are cellmult, and the xalph and yalph. xalph and yalph control anisotropy, as they are standard OSL microfacet closure controls (try setting both to 0).”

vector nearPtLine(
point testLoc,
point lineStart,
point lineEnd)
{
float lineMag = distance(lineStart, lineEnd);
float U = dot(testLoc-lineStart, lineEnd – lineStart) / (lineMag * lineMag);
return lineStart + U * (lineEnd – lineStart);
}
shader tooldSteel(
color attenColor = color(0.9,0.8,0.7),
float xalph = 1,
float yalph = .1,
float cellmult = 2,
point Ploc = P,
vector Normal = N,
output closure color Metal = 0.0)
{
vector centerLoc = round(Ploc * cellmult)/cellmult;
vector spinCenter = nearPtLine(Ploc, centerLoc+Normal, centerLoc -Normal);
vector anisoDir = normalize(spinCenter-Ploc);
Metal = attenColor * microfacet(“beckmann”, Normal, anisoDir, xalph, yalph, 15, 0);
}