Blender Materials: hardness

hardness
  • get/set the sharpness of the specular reflection

Type:
  • integer
Range: 
  • 1 to 511
Note:
  • Properties menu >> Material >> Specular >> Hardness
Sample Code

################## get the sharpness of the specular reflection

# import bge
import bge

# get the current controller
controller = bge.logic.getCurrentController()

# get object that owns this controller
obj = controller.owner
 
# There's only one mesh on my model
mesh = obj.meshes[0]

# And only one material on the mesh
mat = mesh.materials[0]

# get specular reflection sharpness
spec_sharp = mat.hardness

Sample Code

################## set sharpness of specular reflection

# import bge
import bge

# get the current controller
controller = bge.logic.getCurrentController()

# get object that owns this controller
obj = controller.owner
 
# There's only one mesh on my model
mesh = obj.meshes[0]

# And only one material on the mesh
mat = mesh.materials[0]

# set sharpness of specular reflection
mat.hardness = 50