To create a simple basic blueish material, use new Material.
Each class of material is associated to a GLProgram and its GPU shaders.
The simple material SmoothMaterial allows to set an ambient, diffuse and specular color.
To which TextureMaterial adds three textures, for each kind of light.
The NormalsMaterial may be useful for debugging, it show the orientation of
the normal vectors as colors.
import gamnit::depth
var blueish_material = new Material
var redish_material = new SmoothMaterial([0.3, 0.0, 0.0],
                                         [0.6, 0.0, 0.0],
                                         [1.0, 1.0, 1.0])
var normals_material = new NormalsMaterialgamnit :: Material :: defaultinit
gamnit :: Material :: draw_depth
Optimized draw ofmodel, a part of actor, from the view of camera
			gamnit :: Material :: draw_selection
Drawactor to selection values
			core :: Object :: class_factory
Implementation used byget_class to create the specific class.
			core :: Object :: defaultinit
gamnit :: Material :: defaultinit
gamnit :: Material :: draw_depth
Optimized draw ofmodel, a part of actor, from the view of camera
			gamnit :: Material :: draw_selection
Drawactor to selection values
			core :: Object :: is_same_instance
Return true ifself and other are the same instance (i.e. same identity).
			core :: Object :: is_same_serialized
Isself the same as other in a serialization context?
			core :: Object :: is_same_type
Return true ifself and other have the same dynamic type.
			core :: Object :: output_class_name
Display class name on stdout (debug only).diffuse_texture and specular_texture
			
# Material for models, or how to draw the model
#
# To create a simple basic blueish material, use `new Material`.
#
# Each class of material is associated to a `GLProgram` and its GPU shaders.
# The simple material `SmoothMaterial` allows to set an ambient, diffuse and specular color.
# To which `TextureMaterial` adds three textures, for each kind of light.
# The `NormalsMaterial` may be useful for debugging, it show the orientation of
# the normal vectors as colors.
#
# ~~~
# import gamnit::depth
#
# var blueish_material = new Material
# var redish_material = new SmoothMaterial([0.3, 0.0, 0.0],
#                                          [0.6, 0.0, 0.0],
#                                          [1.0, 1.0, 1.0])
# var normals_material = new NormalsMaterial
# ~~~
abstract class Material
	# Draw a `model` from `actor`
	#
	# This method should be refined by subclasses as the default implementation is a no-op.
	#
	# This method is called on many materials for many `actor` and `model` at each frame.
	# It is expected to use a `GLProgram` and call an equivalent to `glDrawArrays`.
	# However, it should not call `glClear` nor `GamnitDisplay::flip`.
	fun draw(actor: Actor, model: LeafModel, camera: Camera) do end
end
					lib/gamnit/depth/depth_core.nit:143,1--172,3
				
redef class Material
	# Optimized draw of `model`, a part of `actor`, from the view of `camera`
	#
	# This drawing should only produce usable depth data. The default behavior,
	# uses `shadow_depth_program`.
	protected fun draw_depth(actor: Actor, model: LeafModel, camera: Camera)
	do
		var program = app.shadow_depth_program
		program.use
		program.mvp.uniform camera.mvp_matrix
		var mesh = model.mesh
		program.translation.uniform(actor.center.x, actor.center.y, actor.center.z, 0.0)
		program.scale.uniform actor.scale
		program.use_map_diffuse.uniform false
		program.tex_coord.array_enabled = true
		program.tex_coord.array(mesh.texture_coords, 2)
		program.coord.array_enabled = true
		program.coord.array(mesh.vertices, 3)
		program.rotation.uniform new Matrix.gamnit_euler_rotation(actor.pitch, actor.yaw, actor.roll)
		if mesh.indices.is_empty then
			glDrawArrays(mesh.draw_mode, 0, mesh.vertices.length/3)
		else
			glDrawElements(mesh.draw_mode, mesh.indices.length, gl_UNSIGNED_SHORT, mesh.indices_c.native_array)
		end
	end
end
					lib/gamnit/depth/shadow.nit:310,1--342,3
				
redef class Material
	# Draw `actor` to selection values
	protected fun draw_selection(actor: Actor, model: LeafModel, id: Int)
	do
		var program = app.selection_program
		var mesh = model.mesh
		draw_selection_texture(actor, model)
		program.translation.uniform(actor.center.x, actor.center.y, actor.center.z, 0.0)
		program.scale.uniform actor.scale
		program.coord.array_enabled = true
		program.coord.array(mesh.vertices, 3)
		program.rotation.uniform new Matrix.gamnit_euler_rotation(actor.pitch, actor.yaw, actor.roll)
		var display = app.display
		assert display != null
		var r = display.red_bits
		var g = display.green_bits
		var b = display.blue_bits
		# Build ID as a color
		var p1 = id & ((2**r)-1)
		var p2 = id >> r & ((2**g)-1)
		var p3 = id >> (r+g) & ((2**b)-1)
		program.color_id.uniform(
			p1.to_f/((2**r)-1).to_f,
			p2.to_f/((2**g)-1).to_f,
			p3.to_f/((2**b)-1).to_f, 1.0)
		if mesh.indices.is_empty then
			glDrawArrays(mesh.draw_mode, 0, mesh.vertices.length/3)
		else
			glDrawElements(mesh.draw_mode, mesh.indices.length, gl_UNSIGNED_SHORT, mesh.indices_c.native_array)
		end
	end
	private fun draw_selection_texture(actor: Actor, model: LeafModel)
	do
		var program = app.selection_program
		program.use_map_diffuse.uniform false
	end
end
					lib/gamnit/depth/selection.nit:145,1--189,3