Creating an OSL Shader

Harlepengren

Gooch Shader Example

Gooch OSL Shader

shader gooch(
    vector inputVector = vector(0,0,0),
    color baseColor = color(1.0, 1.0, 1.0),
    color highlight = 1,
    color warmColor = color(0.3, 0.3, 0),
    color coolColor = color(0, 0, 0.55),
    float exponent = 2.0,
    output closure color out_color = 0.0
    )
{
    // Color Shift
    color coolFinal = coolColor + 0.25 * baseColor;
    color warmFinal = warmColor + 0.25 * baseColor;
    
    vector L = normalize(inputVector);
    float t = (dot(N,L) + 1)/2;
    
    float specular = pow((dot(N,I) + 1)/2,exponent);
    
    // Debug
    //printf("Specular: %f   Warm: %f   Cool: %f\n",specular,(1-specular)*t, (1-t));

    out_color = specular * highlight * diffuse(N) + (1 - specular) * t * warmFinal * diffuse(N) + (1-t) * coolFinal * diffuse(N);
}
# PRESENTING CODE