Wiki

Clone wiki

alShaders / alSurface

Overview

alSurface is a general-purpose, physically plausible surface shader. It supports diffuse, emission, subsurface, two layers of (glossy) specular and (glossy) transmission including single scattering. Other features include per-light AOV support.

When used correctly the shader is energy conserving and correctly handles fresnel per microfacet. The images below show the effect of this on a basic skin shader. Note how the alSurface render on the left does not display the dark edges and artificially bright rim highlights in the aiStandard render on the right. The render times for both images were roughly equal.

https://bitbucket.org/anderslanglands/alshaders/downloads/skin_comparison3.jpg

Light Groups

alSurface allows you to write the lighting contribution (including both direct and indirect illumination) of different lights in your scene to up to 8 separate AOVs (light_group1...8). In order to do this you need to attach an integer parameter called "lightGroup" to your lights to tell alSurface what group they are in.

In MtoA this is done by adding an int attribute called "mtoa_constant_lightGroup" to the shape node of your light and giving it a value from 1 to 8. Values outside of this range will be ignored (as will lights that do not have a lightGroup parameter).

The resulting AOVs will contain the sum of all the lights with the corresponding light group. Note that subsurface scattering does not work with light groups. This is because the scattered light has no way of communicating which source it came from to the shader.

If you would like to just output the direct lighting contribution of the light groups, uncheck the "Indirect light groups" parameter in the "Advanced" section at the bottom of the shader.

A Note on Ray Types

Unlike the standard shader, alSurface uses glossy rays for both its specular lobes. This means that the reflection samples setting in the globals has no effect on the shader, and that the specular lobes will not respond to the sky shader (you should use the skydome light instead). It also means that light sources are always visible in both specular reflection layers.


Parameters

Diffuse and Specular 1 will be your main port of call for most shaders. The shader attempts to conserve energy by attenuating the diffuse reflection according to the fresnel transmission of the Specular 1 and Specular 2 lobes. The shader also attenuates the Transmission component by the diffuse albedo (i.e. diffuseStrength * diffuseColor) in order to conserve energy.

The Specular 2 lobe goes "in between" Diffuse and Specular 1 and is useful for creating surfaces like car paint that have a clear varnish coat on top of a glossy base (Specular 1 would be the clear coat and Specular 2 would be the glossy base in this example).

The Backlight lobe is simply a reverse-diffuse lobe similar to the standard shader and is useful for doing transmissive effects through thing surfaces. Unlike the standard shader, its result is not multiplied with the diffuse color parameter.

Diffuse

Strength
Scalar multiplier on the diffuse reflectance.
Color
Color of the diffuse reflection.
Roughness
Oren-Nayar roughness control. Higher values make the surface more retro-reflective, giving a flatter, rougher appearance

Backlight

Strength
Scalar multiplier on the backlight transmittance.
Color
Color of the backlight transmission.

Subsurface scattering

Diffusion sub-surface scattering using Arnold's raytracing or pointcloud-based functions.

Mix
Blends the diffusion in with the Diffuse result. A value of 0 means no subsurface scattering, a value of 1 means no Diffuse.
Distance
How far the light travels through the surface.
Color
The color the light tends to as it travels through the surface.
Density scale
A multiplier on the units of scattering. Higher values give a denser appearance to the material.

Advanced

Extra samples
Allows you to modify the sampling rate of the lobe from the value specified in the globals. Positive numbers increase the sampling rate, negative numbers decrease it.
Enable caustics
Turning this on allows caustic paths--light that is transmitted or reflected from a specular surface before being diffusely reflected from the current surface--to contribute to the image. With caustics enabled resulting renders will be extremely noisy.

Specular 1

Strength
Scalar multiplier on the reflectance of the top specular lobe.
Color
Color of the top specular lobe.
Roughness
Roughness of the top specular lobe.
IOR
Index of refraction of the top specular lobe. Common values are ~1.34 for water, ~1.5 for common plastics, 1.5-1.8 for glass. Although not correct, values in the range 10-100 can give a reasonable approximation of metals.

Advanced

Roughness depth scale
Each successive specular bounce has its roughness multiplied by this number, effectively making surfaces deep in the ray tree appear less shiny. In some situations this can help reduce noise.
Extra samples
Allows you to modify the sampling rate of the lobe from the value specified in the globals. Positive numbers increase the sampling rate, negative numbers decrease it.
Normal
Plugging in a vector here will use it in place of the shader globals normal. This can be useful for adding a smooth coat over a bumpy diffuse layer, or adding a wet layer.

Specular 2

Strength
Scalar multiplier on the reflectance of the middle specular lobe.
Color
Color of the middle specular lobe.
Roughness
Roughness of the middle specular lobe.
IOR
Index of refraction of the middle specular lobe. Common values are ~1.34 for water, ~1.5 for common plastics, 1.5-1.8 for glass. Although not correct, values in the range 10-100 can give a reasonable approximation of metals.

Advanced

Roughness depth scale
Each successive specular bounce has its roughness multiplied by this number, effectively making surfaces deep in the ray tree appear less shiny. In some situations this can help reduce noise.
Extra samples
Allows you to modify the sampling rate of the lobe from the value specified in the globals. Positive numbers increase the sampling rate, negative numbers decrease it.
Normal
Plugging in a vector here will use it in place of the shader globals normal. This can be useful for adding a smooth coat over a bumpy diffuse layer, or adding a wet layer.

Transmission

Strength
Scalar multiplier on the transmission.
Color
Color multiplier on the transmission.
Link to spec
When this is enabled, the transmission lobe will match its roughness and IOR to the values of the Specular 1 lobe. This is essential for realism in any kind of transparent material; there should rarely be a reason for you to disable this and override the values.
Roughness
Roughness of transmission. Higher values give a frosted glass appearance.
IOR
Index of refraction for the transmission lobe. This affects both the fresnel transmission and the amount of bending of the light as it passes through the surface.

Scattering

Strength
Scalar multiplier on the single scattering result.
Balance
Balance between absorption and scattering. Lower values will give a more 'clear' result (favouring absorption), while higher values will give a more 'cloudy' result (favouring scattering).
In-scattering
When this is enabled, single in-scattering will be calculated for each transmission ray. This can be expensive. If your material has a low balance value (low scattering coefficient) you may want to disable this for faster renders.
Color
The color that the scattered light will tend to as it travels through the medium.
Density scale
Multiplier on the scale of the scattering. Higher values give the appearance of a denser medium.
Direction
Phase function control. Positive numbers give forward scattering, negative numbers back-scattering.
Specify coefficients
When this is enabled the Balance and Color parameters are ignored and you can specify the scattering and absorption coefficients directly. This is useful is you have measured data you would like to use.
Scattering
The scattering coefficient.
Absorption
The absorption coefficient.

Advanced

Roughness depth scale
Each successive transmission has its roughness multiplied by this number, effectively making surfaces deep in the ray tree appear shinier. In some situations this can help reduce noise.
Extra samples
Allows you to modify the sampling rate of the lobe from the value specified in the globals. Positive numbers increase the sampling rate, negative numbers decrease it.
Enabled internal reflections
Turning this off disables specular reflection paths before this transmission. This is similar to the Enable caustics parameter in the Diffuse section. You will want to disable this if your Roughness goes above ~0.3. You will also want to turn this off for highly scattering materials such as wine, water etc to save on render time.

Emission

Simulates light being emitted from the surface.

Strength
Scalar multiplier on the amount of emitted light.
Color
Color of the emitted light.

IDs

Plugging something into any of these inputs will result in it being directly written out to the corresponding id_X output (as listed below). This is useful for generating mattes for comp or outputting parts of the shading tree for comp or for debugging purposes.

AOVs

Options for controlling how the shader outputs AOVs.

Indirect light groups
Enable the indirect light groups feature. When this is enabled, all the bounces for each light group will be written out, as opposed to just the direct lighting. The cost of this is an increase in render time of roughly 1% on a reasonable shader network.
Write standard AOVs
When this is enabled, the shader will only write out AOVs that match the AOVs of the standard shader. In order to do this it will sum some AOVs together, notably: diffuse=diffuse+backlight, specular=specular1+specular2, refraction=refraction+single_scatter

In this section there is also a string field for every AOV that allows you to override the name of the outptu to which it writes:

  • diffuse_color
  • direct_diffuse
  • direct_diffuse_raw
  • indirect_diffuse
  • indirect_diffuse_raw
  • direct_specular
  • indirect_specular
  • direct_specular_2
  • indirect_specular_2
  • single_scatter
  • sss
  • refraction
  • emission
  • uv
  • depth
  • light_group_1
  • light_group_2
  • light_group_3
  • light_group_4
  • light_group_5
  • light_group_6
  • light_group_7
  • light_group_8
  • id_1
  • id_2
  • id_3
  • id_4
  • id_5
  • id_6
  • id_7
  • id_8

Bump

Bump mapping
Connection for a bump node.

Updated