gamnit :: SmoothMaterial :: setup_lights
private fun setup_lights(camera: Camera, program: BlinnPhongProgram)
do
# TODO use a list of lights
# Light, for Lambert and Blinn-Phong
var light = app.light
if light isa ParallelLight then
program.light_kind.uniform 1
# Vector parallel to the light source
program.light_center.uniform(
-light.pitch.sin * light.yaw.sin,
light.pitch.cos,
-light.yaw.cos)
else if light isa PointLight then
program.light_kind.uniform 2
# Position of the light source
program.light_center.uniform(app.light.position.x, app.light.position.y, app.light.position.z)
else
program.light_kind.uniform 0
end
# Draw projected shadows?
if not light isa LightCastingShadows or not app.shadow_depth_texture_available then
program.use_shadows.uniform false
return
else program.use_shadows.uniform true
# Light point of view
program.light_mvp.uniform light.camera.mvp_matrix
# Depth texture
glActiveTexture gl_TEXTURE4
glBindTexture(gl_TEXTURE_2D, app.shadow_context.depth_texture)
program.depth_texture.uniform 4
program.depth_texture_size.uniform app.shadow_resolution.to_f
program.depth_texture_taps.uniform 2 # TODO make configurable
end
lib/gamnit/depth/more_materials.nit:103,2--141,4