Examples of converting Arnold 4 shaders to use closures.
Diffuse Shader
// old AtRGB direct_diffuse = Kd * AiDirectDiffuse(sg->Nf, sg); AtRGB indirect_diffuse = Kd * AiIndirectDiffuse(sg->Nf, sg); sg->out.RGB = direct_diffuse + indirect_diffuse; AiAOVSetRGB(sg, "direct_diffuse", direct_diffuse); AiAOVSetRGB(sg, "indirect_diffuse", indirect_diffuse); // new, light path expressions AOVs are automatically written by closures sg->out.CLOSURE() = AiOrenNayarBSDF(sg, Kd, sg->Nf);
Opacity Shader
// old sg->out.RGB = color; sg->out_opacity = opacity; // new, opacity must be premultiplied into other closures AtClosureList closures; closures.add(AiClosureEmission(sg, opacity * color)); closures.add(AiClosureTransparent(sg, 1 - opacity)); sg->out.CLOSURE() = closures;
Matte Shader
// old sg->out.RGBA = AiRGBACreate(color.r, color.g, color.b, alpha); sg->out_opacity = opacity; // new, matte alpha is specified through its own closure AtClosureList closures; closures.add(AiClosureEmission(sg, opacity * color)); closures.add(AiClosureMatte(sg, opacity * (1 - alpha))); closures.add(AiClosureTransparent(sg, 1 - opacity)); sg->out.CLOSURE() = closures;
Volume Shader
// old AiShaderGlobalsSetVolumeAttenuation(sg, attenuation); AiShaderGlobalsSetVolumeScattering(sg, scattering, anisotropy); AiShaderGlobalsSetVolumeEmission(sg, emission); // new sg->out.CLOSURE() = AiClosureVolumeHenyeyGreenstein(sg, attenuation - scattering, scattering, emission, anisotropy);
Atmosphere Shader
// old sg->Vo = emission; sg->out.RGB = transparent * sg->Ci + emission; sg->out.RGBA.a = matte_alpha; // new AtRGB matte = (1 - transparent) * (1 - matte_alpha); sg->out.CLOSURE() = AiClosureVolumeAtmosphere(emission, transparent, matte);