Functions
Shader Closure API

AtClosure creation. More...

Functions

AI_API AI_DEVICE AtClosure AiClosureEmpiricalBSSRDF (const AtShaderGlobals *sg, const AtRGB &weight, const AtVector &mfp, const AtRGB &albedo)
 Create BSSRDF closure for subsurface scattering in surface shaders. More...
 
AI_API AI_DEVICE AtClosure AiClosureRandomWalkBSSRDF (const AtShaderGlobals *sg, const AtRGB &weight, const AtVector &mfp, const AtRGB &albedo, float g=0.0f)
 Create BSSRDF closure for subsurface scattering in surface shaders. More...
 
AI_API AI_DEVICE AtClosure AiClosureRandomWalkV2BSSRDF (const AtShaderGlobals *sg, const AtRGB &weight, const AtVector &mfp, const AtRGB &albedo, float g=0.0f)
 Create BSSRDF closure for subsurface scattering in surface shaders. More...
 
AI_API AI_DEVICE void AiClosureBSSRDFSetDirectIndirect (AtClosure closure, float weight_direct, float weight_indirect)
 Set the BSSRDF closure direct and indirect light contribution weights. More...
 
AI_API AI_DEVICE AtClosure AiClosureEmission (const AtShaderGlobals *sg, const AtRGB &weight)
 Create emission closure for surface shaders. More...
 
AI_API AI_DEVICE AtClosure AiClosureTransparent (const AtShaderGlobals *sg, const AtRGB &weight=AI_RGB_WHITE, const AtClosureList interior=NULL, int32_t importance=0)
 Create transparent closure for surface shaders. More...
 
AI_API AtClosure AiClosureMatte (const AtShaderGlobals *sg, const AtRGB &weight=AI_RGB_WHITE)
 Create matte closure for surface shaders. More...
 
AI_API AtClosure AiClosureBackground (const AtShaderGlobals *sg, const AtRGB &weight=AI_RGB_WHITE)
 Create background closure for background surface shaders. More...
 
AI_API AI_DEVICE AtClosure AiClosureVolumeAbsorption (const AtShaderGlobals *sg, const AtRGB &weight)
 Create volume absorption closure, for volume shaders. More...
 
AI_API AI_DEVICE AtClosure AiClosureVolumeEmission (const AtShaderGlobals *sg, const AtRGB &weight)
 Create volume emission closure, for volume shaders. More...
 
AI_API AI_DEVICE AtClosure AiClosureVolumeHenyeyGreenstein (const AtShaderGlobals *sg, const AtRGB &absorption, const AtRGB &scattering, const AtRGB &emission, float g=0.f)
 Create Henyey-Greenstein volume scattering closure, for volume shaders. More...
 
AI_API AI_DEVICE AtClosure AiClosureVolumeMatte (const AtShaderGlobals *sg, const AtRGB &weight)
 Create volume matte closure, for volume shaders. More...
 
AI_API AI_DEVICE AtClosure AiClosureVolumeAtmosphere (const AtShaderGlobals *sg, const AtRGB &emission, const AtRGB &transparent, const AtRGB &matte)
 Create volume atmosphere closure, for legacy atmosphere shaders. More...
 

Detailed Description

AtClosure creation.

Shaders can return these instead of final colors.

Closures describe the way surfaces and volumes scatter light, leaving the lights loops and integration to Arnold.

For creating BSDF closures, an AtBSDF can be wrapped in a closure:

AtBSDF *bsdf = AiOrenNayarBSDF(sg, sg->Nf);
sg->out.CLOSURE() = AtClosure(diffuse_color, bsdf);

Function Documentation

AI_API AI_DEVICE AtClosure AiClosureEmpiricalBSSRDF ( const AtShaderGlobals sg,
const AtRGB weight,
const AtVector mfp,
const AtRGB albedo 
)

Create BSSRDF closure for subsurface scattering in surface shaders.

This is a diffusion BSSRDF model empirically fitted to match brute-force Monte Carlo scattering. The BSSRDF accounts for both single and multiple scattering.

Note that Fresnel or other layer or mixing weights must be provided separately from the albedo, as the albedo affects the shape of the BSSRDF profile.

See also
http://graphics.pixar.com/library/ApproxBSSRDF/

BSSRDF sampling quality is controlled by the GI_sss_samples render option.

Parameters
sgshader globals
weightRGB weights for mixing profiles or applying fresnel
mfpper RGB wavelength mean free path lengths (mfp = 1/sigmat' = 1/(sigmas' + sigmaa))
albedodiffuse reflectivity
Returns
BSSRDF closure
AI_API AI_DEVICE AtClosure AiClosureRandomWalkBSSRDF ( const AtShaderGlobals sg,
const AtRGB weight,
const AtVector mfp,
const AtRGB albedo,
const float  g 
)

Create BSSRDF closure for subsurface scattering in surface shaders.

This is a brute-force Monte Carlo random walk approach to subsurface scattering that produces estimates from a series of simulated interior scattering events.

Note that Fresnel or other layer or mixing weights must be provided separately from the albedo, as the albedo affects the shape of the BSSRDF profile.

BSSRDF sampling quality is controlled by the GI_sss_samples render option.

Parameters
sgshader globals
weightRGB weights for mixing profiles or applying fresnel
mfpper RGB wavelength mean free path lengths (mfp = 1/sigmat' = 1/(sigmas' + sigmaa))
albedodiffuse reflectivity
gHenyey-Greenstein eccentricy parameter for anisotropic scattering
Returns
BSSRDF closure
AI_API AI_DEVICE AtClosure AiClosureRandomWalkV2BSSRDF ( const AtShaderGlobals sg,
const AtRGB weight,
const AtVector mfp,
const AtRGB albedo,
const float  g 
)

Create BSSRDF closure for subsurface scattering in surface shaders.

This is an improved version of the brute-force Monte Carlo random walk that suffers from less brightening and desaturation at corners. Please note that this change causes light to penetrate more deeply at grazing angles, which can cause an increase in noise and scattering distance.

Note that Fresnel or other layer or mixing weights must be provided separately from the albedo, as the albedo affects the shape of the BSSRDF profile.

BSSRDF sampling quality is controlled by the GI_sss_samples render option.

Parameters
sgshader globals
weightRGB weights for mixing profiles or applying fresnel
mfpper RGB wavelength mean free path lengths (mfp = 1/sigmat' = 1/(sigmas' + sigmaa))
albedodiffuse reflectivity
gHenyey-Greenstein eccentricy parameter for anisotropic scattering
Returns
BSSRDF closure
AI_API AI_DEVICE void AiClosureBSSRDFSetDirectIndirect ( AtClosure  closure,
float  weight_direct,
float  weight_indirect 
)

Set the BSSRDF closure direct and indirect light contribution weights.

For physically correct rendering, these must be set to the default 1.0, however for artistic control the direct and indirect light contributions can be scaled independently.

Parameters
closureBSSRDF closure
weight_directDirect light weight
weight_indirectIndirect light weight
AI_API AI_DEVICE AtClosure AiClosureEmission ( const AtShaderGlobals sg,
const AtRGB weight 
)

Create emission closure for surface shaders.

Parameters
sgshader globals
weightemission radiance
Returns
emission closure
AI_API AI_DEVICE AtClosure AiClosureTransparent ( const AtShaderGlobals sg,
const AtRGB weight,
const AtClosureList  interior,
int32_t  importance 
)

Create transparent closure for surface shaders.

When making a surface transparent, other surface closures should have the opacity multiplied in, so that the total weight of all closures does not exceed 1 and energy is conserved. Mixing with other closures can be done as follows:

1 closures *= opacity;
2 closures.add(AiClosureTransparent(sg, 1 - opacity));

Objects must have the opaque parameter off to render transparency.

Parameters
sgshader globals
weighttransparency
interioroptional volume closures for interior of the object
importanceused to resolve overlaps
Returns
transparent closure
AI_API AtClosure AiClosureMatte ( const AtShaderGlobals sg,
const AtRGB weight 
)

Create matte closure for surface shaders.

The matte closure creates a holdout effect by rendering alphas as zero. This works like the matte parameter on shapes.

Parameters
sgshader globals
weightmatte transparency
Returns
matte closure
AI_API AtClosure AiClosureBackground ( const AtShaderGlobals sg,
const AtRGB weight 
)

Create background closure for background surface shaders.

Parameters
sgshader globals
weightemission radiance
Returns
background closure
AI_API AI_DEVICE AtClosure AiClosureVolumeAbsorption ( const AtShaderGlobals sg,
const AtRGB weight 
)

Create volume absorption closure, for volume shaders.

The closure weight is the absorption coefficient. This coefficient is the rate at which the volume absorbs light that is traveling along the given direction at the given point. Any light that traverses a volume with a given absoprtion coefficient will be attenuated at a rate of:

attenuation = expf(-(scattering_coefficient + absorption_coefficient) * distance_travelled)

Parameters
sgshader globals that the volume shader was invoked with
weightabsorption coefficient
iorthe index of refraction of the bulk substrate medium
Returns
volume closure
AI_API AI_DEVICE AtClosure AiClosureVolumeEmission ( const AtShaderGlobals sg,
const AtRGB weight 
)

Create volume emission closure, for volume shaders.

The closure weight is the emission coefficient. This coefficient is the rate at which the volume emits light along the given direction at the given point. Any ray that traverses a volume with a given emission coefficient will have radiance added at a rate of:

emission = emission_coefficient * distance_travelled

Note
The volume's emission is itself affected by the volume's attenuation.
Parameters
sgshader globals that the volume shader was invoked with
emissionemission coefficient
Returns
volume closure
AI_API AI_DEVICE AtClosure AiClosureVolumeHenyeyGreenstein ( const AtShaderGlobals sg,
const AtRGB absorption,
const AtRGB scattering,
const AtRGB emission,
float  g 
)

Create Henyey-Greenstein volume scattering closure, for volume shaders.

The scattering coefficient is the rate at which the volume in-scatters radiance along the given direction at the given point, and the 'g' parameter is the Henyey-Greenstein phase at the given point. These coefficients are used for both direct and indirect light paths, and the amount of in-scattered radiance is:

scattering = scattering_coefficient * HenyeyGreensteinPhaseFunc(g, sg->Ld, sg->Rd) * radiance * distance_travelled

The absorption and emission coefficients are the same as in the volume absorption and emission closures. Creating a single volume scattering closures with all coefficients is faster than creating separate closures for each coefficient.

Note
The volume's scattering is itself affected by the volume's attenuation.
Parameters
sgshader globals that the volume shader was invoked with
absorptionabsorption coefficient
scatteringscattering coefficient
emissionemission coefficient
gHenyey-Greenstein phase, in the open interval (-1,+1) where negative values mean backward anisotropic scattering, positive values mean forward anisotropic scattering, zero means isotropic scattering
Returns
volume closure
AI_API AI_DEVICE AtClosure AiClosureVolumeMatte ( const AtShaderGlobals sg,
const AtRGB weight 
)

Create volume matte closure, for volume shaders.

If used in place of AiClosureVolumeAbsorption(), this works the same as the matte parameter on shapes.

Parameters
sgshader globals that the volume shader was invoked with
weightabsorption coefficient
Returns
volume closure
AI_API AI_DEVICE AtClosure AiClosureVolumeAtmosphere ( const AtShaderGlobals sg,
const AtRGB emission,
const AtRGB transparent,
const AtRGB matte 
)

Create volume atmosphere closure, for legacy atmosphere shaders.

The weights are the total emission, transparency and matte transparency integrated over the volume segment with length sg->Rl. Such weights maybe be more convenient and numerically stable for legacy atmosphere shaders that cover long volume segment distances.

Parameters
sgshader globals
emissionintegrated emission, equivalent to AiClosureEmission weight for surfaces
transparentintegrated transparency, equivalent to AiClosureTransparent weight for surfaces
matteintegrated matte transparency, equivalent to AiClosureMatte weight for surfaces
Returns
volume atmosphere closure

© 2020 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com