Open Shading Language#

sólo en Cycles

It is also possible to create your own nodes using Open Shading Language (OSL). These nodes will only work with the CPU and OptiX rendering backend.

To enable it, select Open Shading Language as the shading system in the render settings.


Some OSL features are not available when using the OptiX backend. Examples include:

  • Memory usage reductions offered by features like on-demand texture loading and mip-mapping are not available.

  • Texture lookups require OSL to be able to determine a constant image file path for each texture call.

  • Some noise functions are not available. Examples include Cell, Simplex, and Gabor.

  • La función trace no funciona (valga el juego de palabras). Como resultado de esto, los nodos Oclusión ambiental y Biselar tampoco podrán funcionar.

Nodo Script#

El nodo Script.

OSL was designed for node-based shading, and each OSL shader corresponds to one node in a node setup. To add an OSL shader, add a script node and link it to a text data-block or an external file. Input and output sockets will be created from the shader parameters on clicking the update button in the Node or the Text editor.

OSL shaders can be linked to the node in a few different ways. With the Internal mode, a text data-block is used to store the OSL shader, and the OSO bytecode is stored in the node itself. This is useful for distributing a blend-file with everything packed into it.

The External mode can be used to specify a .osl file from a drive, and this will then be automatically compiled into a .oso file in the same directory. It is also possible to specify a path to a .oso file, which will then be used directly, with compilation done manually by the user. The third option is to specify just the module name, which will be looked up in the shader search path.

The shader search path is located in the same place as the scripts or configuration path, under:

C:\Users\$user\AppData\Roaming\Blender Foundation\Blender\4.1\shaders\
/Users/$USER/Library/Application Support/Blender/4.1/shaders/


For use in production, we suggest to use a node group to wrap shader script nodes, and link that into other blend-files. This makes it easier to make changes to the node afterwards as sockets are added or removed, without having to update the script nodes in all files.

Escritura de sombreadores#

For more details on how to write shaders, see the OSL Documentation.

Here is a simple example:

shader simple_material(
    color Diffuse_Color = color(0.6, 0.8, 0.6),
    float Noise_Factor = 0.5,
    output closure color BSDF = diffuse(N))
    color material_color = Diffuse_Color * mix(1.0, noise(P * 10.0), Noise_Factor);
    BSDF = material_color * diffuse(N);


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.

Ver también

Documentation on OSL’s built-in closures.


  • diffuse(N)

  • oren_nayar(N, rugosidad)

  • diffuse_ramp(N, colores[8])

  • phong_ramp(N, exponente, colores[8])

  • diffuse_toon(N, tamaño, suavizado)

  • glossy_toon(N, tamaño, suavizado)

  • translucent(N)

  • reflection(N)

  • refraction(N, ir)

  • transparent()

  • microfacet_ggx(N, rugosidad)

  • microfacet_ggx_aniso(N, T, ax, ay)

  • microfacet_ggx_refraction(N, rugosidad, ir)

  • microfacet_beckmann(N, rugosidad)

  • microfacet_beckmann_aniso(N, T, ax, ay)

  • microfacet_beckmann_refraction(N, rugosidad, ir)

  • ashikhmin_shirley(N, T, ax, ay)

  • ashikhmin_velvet(N, rugosidad)


  • hair_reflection(N, rugosidad_u, rugosidad_v, T, desplazamiento)

  • hair_transmission(N, rugosidad_u, rugosidad_v, T, desplazamiento)

  • principled_hair(N, absorción, rugosidad, rugosidad_radial, barniz, desplazamiento, ir)


Usado para simular transluminiscencia.

bssrdf(method, N, radius, albedo)#
  • method (string) –

    Métodos de procesamiento para simular la transluminiscencia.

    • 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) – Vector normal del punto de la superficie que está siendo sombreado.

  • radius (vector) – Distancia promedio que la luz atravesará por debajo de la superficie. Una radio mayor producirá una apariencia más suave, debido a que la luz se esparcirá hacia las sombras y a través del objeto. La distancia de dispersión se especifica de forma separada para cada canal RVA, para posibilitar recrear materiales tales como piel, en los cuales la luz roja se dispersa más que los otros componentes. Los valores X, Y y Z serán mapeados respectivamente a los valores de R, V y A.

  • albedo (color) – Color de la superficie o, dicho en términos físicos, la probabilidad de que la luz de las distintas longitudes de onda sea reflejada.


  • henyey_greenstein(g)

  • absorption()


  • emission()

  • ambient_occlusion()

  • holdout()

  • background()


Geometry attributes can be read through the getattribute() function. This includes UV maps, color attributes and any attributes output from geometry nodes.

The following built-in attributes are available through getattribute() as well.


Coordenadas de textura generadas automáticamente, de mallas sin deformar.


Mapa UV predefinido para el procesamiento.


Default tangent vector along surface, in object space.


Position before displacement, in object space.


For instances, generated coordinate from instancer object.


For instances, UV coordinate from instancer object.


Three vertex coordinates of the triangle.


Number of vertices in the polygon (always returns three currently).


Vertex coordinates array of the polygon (always three vertices currently).


Nombre del objeto.


Is mesh face smooth or flat shaded.


Is object a curve or not.


0..1 coordinate for point along the curve, from root to tip.


Thickness of the curve in object space.


Length of the curve in object space.


Tangent Normal of the strand.


Es un punto de una nube de puntos o no.


Radius of point in point cloud.


Center position of point in point cloud.


Random number, different for every point in point cloud.


Ray distance since last hit.


Random number, different for every object instance.


Object unique instance index.


Object location.


Material unique index number.


Particle unique instance number.


Particle age in frames.


Total lifespan of particle in frames.


Location of the particle.


Size of the particle.


Velocity of the particle.


Angular velocity of the particle.


sólo CPU

We support the trace(point pos, vector dir, ...) function, to trace rays from the OSL shader. The «shade» parameter is not supported currently, but attributes can be retrieved from the object that was hit using the getmessage("trace", ..) function. See the OSL specification for details on how to use this.

Esta función no podrá ser usada en vez de la iluminación; su propósito principal es permitir que los sombreadores «sondeen» a la geometría cercana, por ejemplo para aplicar una textura proyectada que pueda ser bloqueada por ésta, aplicar más «desgaste» a las partes expuestas de una geometría o realizar otros efectos similares a la oclusión ambiental.


Metadata on parameters controls their display in the user interface. The following metadata is supported:

[[ string label = "My Label" ]]

Name of parameter in in the user interface

[[ string widget = "null" ]]

Hide parameter in the user interface.

[[ string widget = "boolean" ]] y [[ string widget = "checkbox" ]]

Display integer parameter as a boolean checkbox.