user: How do I use Closures in Blender? Include parameters, examples, warnings and best practices.

assistant: OSL is different from, for example, RSL or GLSL, in that it does not have a light loop.
There is no access to lights in the scene,
and the material must be built from closures that are implemented in the renderer itself.
This is more limited, but also makes it possible for the renderer to do optimizations and
ensure all shaders can be importance sampled.

The available closures in Cycles correspond to the shader nodes and their sockets;
for more details on what they do and the meaning of the parameters,
see the [shader nodes manual](../../shader_nodes/shader/index.xhtml).

### BSDF

- `diffuse(N)`
- `oren_nayar(N, roughness)`
- `diffuse_ramp(N, colors[8])`
- `phong_ramp(N, exponent, colors[8])`
- `diffuse_toon(N, size, smooth)`
- `glossy_toon(N, size, smooth)`
- `translucent(N)`
- `reflection(N)`
- `refraction(N, ior)`
- `transparent()`
- `microfacet_ggx(N, roughness)`
- `microfacet_ggx_aniso(N, T, ax, ay)`
- `microfacet_ggx_refraction(N, roughness, ior)`
- `microfacet_beckmann(N, roughness)`
- `microfacet_beckmann_aniso(N, T, ax, ay)`
- `microfacet_beckmann_refraction(N, roughness, ior)`
- `ashikhmin_shirley(N, T, ax, ay)`
- `ashikhmin_velvet(N, roughness)`

### Hair

- `hair_reflection(N, roughnessu, roughnessv, T, offset)`
- `hair_transmission(N, roughnessu, roughnessv, T, offset)`
- `principled_hair(N, absorption, roughness, radial_roughness, coat, offset, IOR)`

### BSSRDF

Used to simulate subsurface scattering.

bssrdf(*method*, *N*, *radius*, *albedo*)
:   Parameters:
    :   - **method** (*string*) –

          Rendering method to simulate subsurface scattering.

          - `burley`:
            An approximation to physically-based volume scattering.
            This method is less accurate than `random_walk` however,
            in some situations this method will resolve noise faster.
          - `random_walk_skin`:
            Provides accurate results for thin and curved objects.
            Random Walk uses true volumetric scattering inside the mesh,
            which means that it works best for closed meshes.
            Overlapping faces and holes in the mesh can cause problems.
          - `random_walk`:
            Behaves similarly to `random_walk_skin` but modulates
            the *Radius* based on the *Color*, *Anisotropy*, and *IOR*.
            This method thereby attempts to retain greater surface detail and color
            than `random_walk_skin`.
        - **N** (*vector*) – Normal vector of the surface point being shaded.
        - **radius** (*vector*) – Average distance that light scatters below the surface.
          Higher radius gives a softer appearance, as light bleeds into shadows and through the object.
          The scattering distance is specified separately for the RGB channels,
          to render materials such as skin where red light scatters deeper.
          The X, Y and Z values are mapped to the R, G and B values, respectively.
        - **albedo** (*color*) – Color of the surface, or physically speaking, the probability that light is reflected for each wavelength.

### Volume

- `henyey_greenstein(g)`
- `absorption()`

### Other

- `emission()`
- `ambient_occlusion()`
- `holdout()`
- `background()`