shader_update_lights   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm

Implementation

(bind-func shader_update_lights
  (let ((i:i32 0)
        (ca:float* (alloc 5)) ;; contant attenuation
        (la:float* (alloc 5)) ;; linear attenuation
        (qa:float* (alloc 5)) ;; quadratic attenuation
        (sa:float* (alloc 5)) ;; spot angle
        (dir:float* (alloc (* 5 4))) ;; spot dir
        (tmp:float* (alloc (* 5 4))))
    (dotimes (i 5)
      (pset! ca i 1.0) (pset! la i 0.0) (pset! qa i 0.0))
    (lambda (shader:ShaderProgram* numlights:i32 position target angle:float* power ambient diffuse specular)
      (if (> numlights 5) (set! numlights 5))
      (dotimes (i numlights) (pset! sa i (- 1.0 (/ (pref angle i) 180.0))))
      (glUniform1i (glGetUniformLocation (id shader) "numLights") numlights)
      (glUniform1fv (glGetUniformLocation (id shader) "ConstantAttenuation") numlights ca)
      (glUniform1fv (glGetUniformLocation (id shader) "LinearAttenuation") numlights la)
      (glUniform1fv (glGetUniformLocation (id shader) "QuadraticAttenuation") numlights qa)
      (glUniform1fv (glGetUniformLocation (id shader) "SpotExponent") numlights power)
      (glUniform1fv (glGetUniformLocation (id shader) "SpotAngle") numlights sa)
      (glUniform4fv (glGetUniformLocation (id shader) "LightPos") numlights position)
      (glUniform4fv (glGetUniformLocation (id shader) "LightAmbient") numlights ambient)
      (glUniform4fv (glGetUniformLocation (id shader) "LightSpecular") numlights specular)
      (glUniform4fv (glGetUniformLocation (id shader) "LightDiffuse") numlights diffuse)
      (dotimes (i numlights)
        (vvsub (pref-ptr target (* i 4))
              (pref-ptr position (* i 4))
              3
              (pref-ptr tmp (* i 4)))
        (vnormalise (pref-ptr tmp (* i 4))
               3
               (pref-ptr dir (* i 4)))
        (pset! (pref-ptr dir (* i 4)) 3 0.0))
      (glUniform4fv (glGetUniformLocation (id shader) "SpotDir") numlights dir)
      void)))


Back to Index

Similar Entries

  • Shader    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects2.xtm
  • ShaderProgram    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects2.xtm
  • ShaderProgram    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects2.xtm
  • ShaderProgram    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects2.xtm
  • ShaderProgram    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects2.xtm
  • ShaderProgram_create    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects.xtm
  • ShaderProgram_create    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects.xtm
  • ShaderProgram_create    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects.xtm
  • ShaderProgram_create    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects.xtm
  • ShaderProgram_print_info_log    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects.xtm
  • Shader_create    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects.xtm
  • Shader_id    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects.xtm
  • Shader_print_info_log    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects.xtm
  • Shader_type    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects.xtm
  • VBO_update_data    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects.xtm
  • clock:update-metro    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • clock:update-metro    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • create_arrows_shader    xtlang    /digego/extempore/tree/v0.8.9/examples/external/shader-tutorials/arrows.xtm
  • create_heatmap_shader    xtlang    /digego/extempore/tree/v0.8.9/examples/external/shader-tutorials/heatmap.xtm
  • create_particles_shader    xtlang    /digego/extempore/tree/v0.8.9/examples/external/shader-tutorials/particles.xtm
  • create_points_shader    xtlang    /digego/extempore/tree/v0.8.9/examples/external/shader-tutorials/points.xtm
  • create_post_process_shader    xtlang    /digego/extempore/tree/v0.8.9/examples/external/shader-tutorials/framebuffer.xtm
  • create_raymarcher_shader    xtlang    /digego/extempore/tree/v0.8.9/examples/external/raymarcher.xtm
  • create_shader    xtlang    /digego/extempore/tree/v0.8.9/libs/external/opengl.xtm
  • create_shader_xtm    xtlang    /digego/extempore/tree/v0.8.9/libs/external/opengl.xtm
  • create_shadertoy_shader    xtlang    /digego/extempore/tree/v0.8.9/examples/external/shader-tutorials/shadertoy.xtm
  • create_texture_shader    xtlang    /digego/extempore/tree/v0.8.9/examples/external/shader-tutorials/texture.xtm
  • create_triangle_shader    xtlang    /digego/extempore/tree/v0.8.9/examples/external/shader-tutorials/simple-triangle.xtm
  • create_triangle_shader    xtlang    /digego/extempore/tree/v0.8.9/examples/external/shader-tutorials/framebuffer.xtm
  • dict_update    xtlang    /digego/extempore/tree/v0.8.9/libs/core/adt.xtm
  • fragshader    scheme    /digego/extempore/tree/v0.8.9/examples/external/raymarcher.xtm
  • impc:ti:check-to-update-generic-vars    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:update-closure-name    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:update-var    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • kinect_update_body    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/kinect2.xtm
  • model_update    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/horde3d_knight.xtm
  • position_update    xtlang    /digego/extempore/tree/v0.8.9/examples/external/shader-tutorials/particles.xtm
  • print_shader_info_log    xtlang    /digego/extempore/tree/v0.8.9/libs/external/opengl.xtm
  • shader_prepare_draw    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_prepare_draw    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_prepare_draw    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_prepare_draw    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_prepare_draw    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_set_grid_offsets    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_setup_convolution_filter    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_update_bones    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_update_camera    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_update_envmap    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_update_light    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_update_material    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_update_material    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_update_material    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_update_matrices    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_update_matrices_lv    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_update_matrices_lvs    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_update_projection_texture    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shader_update_uvwmatrix    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • shadertoy-loop    scheme    /digego/extempore/tree/v0.8.9/examples/external/shader-tutorials/shadertoy.xtm
  • update    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects2.xtm
  • update    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects2.xtm
  • update-borders    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/kinect_fire.xtm
  • update-fluid-sym-state    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/kinect_fire.xtm
  • update_cube    xtlang    /digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects2.xtm
  • update_data_points    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/fluids_2d.xtm
  • vertshader    scheme    /digego/extempore/tree/v0.8.9/examples/external/raymarcher.xtm
  • xtm_get_lights    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • xtm_render_init_dof_shader    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • xtm_render_init_light_shader    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • xtm_render_init_quad_shader    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • xtm_render_init_simple_bone_shader    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • xtm_render_init_simple_shader    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • xtm_render_init_skybox_shader    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • xtm_update_camera    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • xtm_update_lights    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • xtm_update_matrices    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • xtmtest-update-test-result    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • xtmtest-update-test-result    scheme    /digego/extempore/tree/v0.8.9/libs/core/test.xtm