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
  • ShaderProgram    xtlang
  • ShaderProgram    xtlang
  • ShaderProgram    xtlang
  • ShaderProgram    xtlang
  • ShaderProgram_create    xtlang
  • ShaderProgram_create    xtlang
  • ShaderProgram_create    xtlang
  • ShaderProgram_create    xtlang
  • ShaderProgram_print_info_log    xtlang
  • Shader_create    xtlang
  • Shader_id    xtlang
  • Shader_print_info_log    xtlang
  • Shader_type    xtlang
  • VBO_update_data    xtlang
  • clock:update-metro    scheme
  • clock:update-metro    scheme
  • create_arrows_shader    xtlang
  • create_heatmap_shader    xtlang
  • create_particles_shader    xtlang
  • create_points_shader    xtlang
  • create_post_process_shader    xtlang
  • create_raymarcher_shader    xtlang
  • create_shader    xtlang
  • create_shader_xtm    xtlang
  • create_shadertoy_shader    xtlang
  • create_texture_shader    xtlang
  • create_triangle_shader    xtlang
  • create_triangle_shader    xtlang
  • dict_update    xtlang
  • fragshader    scheme
  • impc:ti:check-to-update-generic-vars    scheme
  • impc:ti:update-closure-name    scheme
  • impc:ti:update-var    scheme
  • kinect_update_body    xtlang
  • model_update    xtlang
  • position_update    xtlang
  • print_shader_info_log    xtlang
  • shader_prepare_draw    xtlang
  • shader_prepare_draw    xtlang
  • shader_prepare_draw    xtlang
  • shader_prepare_draw    xtlang
  • shader_prepare_draw    xtlang
  • shader_set_grid_offsets    xtlang
  • shader_setup_convolution_filter    xtlang
  • shader_update_bones    xtlang
  • shader_update_camera    xtlang
  • shader_update_envmap    xtlang
  • shader_update_light    xtlang
  • shader_update_material    xtlang
  • shader_update_material    xtlang
  • shader_update_material    xtlang
  • shader_update_matrices    xtlang
  • shader_update_matrices_lv    xtlang
  • shader_update_matrices_lvs    xtlang
  • shader_update_projection_texture    xtlang
  • shader_update_uvwmatrix    xtlang
  • shadertoy-loop    scheme
  • update    xtlang
  • update    xtlang
  • update-borders    xtlang
  • update-fluid-sym-state    xtlang
  • update_cube    xtlang
  • update_data_points    xtlang
  • vertshader    scheme
  • xtm_get_lights    xtlang
  • xtm_render_init_dof_shader    xtlang
  • xtm_render_init_light_shader    xtlang
  • xtm_render_init_quad_shader    xtlang
  • xtm_render_init_simple_bone_shader    xtlang
  • xtm_render_init_simple_shader    xtlang
  • xtm_render_init_skybox_shader    xtlang
  • xtm_update_camera    xtlang
  • xtm_update_lights    xtlang
  • xtm_update_matrices    xtlang
  • xtmtest-update-test-result    scheme
  • xtmtest-update-test-result    scheme