Module Material

Module Material

source code

The Blender.Material submodule.

New: access to shader data.


This module provides access to Material objects in Blender.

       import Blender
       from Blender import Material
       mat = Material.New('newMat')          # create a new Material called 'newMat'
       print mat.rgbCol                      # print its rgb color triplet sequence
       mat.rgbCol = [0.8, 0.2, 0.2]          # change its color
       mat.setAlpha(0.2)                     # mat.alpha = 0.2 -- almost transparent
       mat.emit = 0.7                        # equivalent to mat.setEmit(0.8)
       mat.mode |= Material.Modes.ZTRANSP    # turn on Z-Buffer transparency
       mat.setName('RedBansheeSkin')         # change its name
       mat.setAdd(0.8)                       # make it glow
       mat.setMode('Halo')                   # turn 'Halo' "on" and all others "off"

This object gives access to Materials in Blender.
Blender Material
Create a new Material object.
source code
Blender Material or a list of Blender Materials
Get the Material object(s) from Blender.
source code
readonly dictionary Modes
The available Material Modes.
readonly dictionary Shaders
The available Material Shaders.
Function Details


source code 
Create a new Material object.
  • name (string) - The Material name.
Returns: Blender Material
The created Material object.


source code 
Get the Material object(s) from Blender.
  • name (string) - The name of the Material.
Returns: Blender Material or a list of Blender Materials
It depends on the 'name' parameter:
  • (name): The Material object with the given name;
  • (): A list with all Material objects in the current scene.

Variables Details


The available Material Modes.

Note: Some Modes are only available when the 'Halo' mode is off and others only when it is on. But these two subsets of modes share the same numerical values in their Blender C #defines. So, for example, if 'Halo' is on, then 'NoMist' is actually interpreted as 'HaloShaded'. We marked all such possibilities in the Modes dict below: each halo-related mode that uses an already taken value is preceded by "+" and appear below the normal mode which also uses that value.
  • TRACEABLE - Make Material visible for shadow lamps.
  • SHADOW - Enable Material for shadows.
  • SHADOWBUF - Enable Material to cast shadows with shadow buffers.
  • SHADELESS - Make Material insensitive to light or shadow.
  • WIRE - Render only the edges of faces.
  • VCOL_LIGHT - Add vertex colors as extra light.
  • VCOL_PAINT - Replace basic colors with vertex colors.
  • HALO - Render as a halo.
  • ZTRANSP - Z-buffer transparent faces.
  • ZINVERT - Render with inverted Z-buffer.
  • + HALORINGS - Render rings over the basic halo.
  • ENV - Do not render Material.
  • + HALOLINES - Render star shaped lines over the basic halo.
  • ONLYSHADOW - Let alpha be determined on the degree of shadow.
  • + HALOXALPHA - Use extreme alpha.
  • TEXFACE - UV-Editor assigned texture gives color and texture info for faces.
  • TEXFACE_ALPHA - When TEXFACE is enabled, use the alpha as well.
  • + HALOSTAR - Render halo as a star.
  • NOMIST - Set the Material insensitive to mist.
  • + HALOSHADED - Let halo receive light.
  • HALOTEX - Give halo a texture.
  • HALOPUNO - Use the vertex normal to specify the dimension of the halo.
  • HALOFLARE - Render halo as a lens flare.
  • RAYMIRROR - Enables raytracing for mirror reflection rendering.
  • RAYTRANSP - Enables raytracing for transparency rendering.
  • RAYBIAS - Prevent ray traced shadow errors with Phong interpolated normals.
  • RAMPCOL - Status of colorband ramp for Material's diffuse color. This is a read-only bit.
  • RAMPSPEC - Status of colorband ramp for Material's specular color. This is a read-only bit.
  • TANGENTSTR - Uses direction of strands as normal for tangent-shading.
  • TRANSPSHADOW - Lets Material receive transparent shadows based on material color and alpha.
  • FULLOSA - Force rendering of all OSA samples.
  • TANGENT_V - Use the tangent vector in V direction for shading
  • NMAP_TS - Tangent space normal mapping.
  • GROUP_EXCLUSIVE - Light from this group even if the lights are on a hidden Layer.
readonly dictionary


The available Material Shaders.
  • DIFFUSE_LAMBERT - Make Material use the lambert diffuse shader.
  • DIFFUSE_ORENNAYAR - Make Material use the Oren-Nayer diffuse shader.
  • DIFFUSE_TOON - Make Material use the toon diffuse shader.
  • DIFFUSE_MINNAERT - Make Material use the minnaert diffuse shader.
  • SPEC_COOKTORR - Make Material use the Cook-Torr specular shader.
  • SPEC_PHONG - Make Material use the Phong specular shader.
  • SPEC_BLINN - Make Material use the Blinn specular shader.
  • SPEC_TOON - Make Material use the toon specular shader.
  • SPEC_WARDISO - Make Material use the Ward-iso specular shader.
readonly dictionary