shader_update_matrices_lv   xtlang


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

Implementation

;; when working with OpenGL
;; extempore's mmul is pre mutipled (not post as in GLSL)
;; so the same matrix mul is post in GLSL and pre in XTM (i.e. here!)
(bind-func shader_update_matrices_lv
  (let ((bias:float* (alloc 16)))
    (pfill! bias
            0.5 0.0 0.0 0.0
            0.0 0.5 0.0 0.0
            0.0 0.0 0.5 0.0
            0.5 0.5 0.5 1.0)
    (lambda (shader:ShaderProgram* m:float* v p:float* lv:float*) ;; lv light view
      (let ((mlv:float* (salloc 16))
            (mlvp:float* (salloc 16))
            (mlvpb:float* (salloc 16)))
        (mmmul m lv mlv)
        (mmmul mlv p mlvp)
        (mmmul mlvp bias mlvpb)
        (glUniformMatrix4fv (glGetUniformLocation (id shader) "LightModelViewProjectionMatrix") 1 GL_FALSE mlvpb))
      (let ((mv (salloc 48))
            (mvp (pref-ptr mv 16))
            (mn (pref-ptr mv 32)))
        ;;(mmul m 4 4 v 4 4 mv) ;; final mv set
        (mmmul m v mv) ;; final mv set
        (mtrans mv 4 4 mn) ;; using mn as a temporary here!!
        (minverse mn 4 mvp) ;; using mvp as a temporary
        (mat4_to_mat3 mvp mn)  ;; final mn set
        ;;(mmul mv 4 4 p 4 4 mvp) ;; final mvp set
        (mmmul mv p mvp) ;; final mvp set
        (glUniformMatrix4fv (glGetUniformLocation (id shader) "ModelMatrix") 1 GL_FALSE m)
        (glUniformMatrix4fv (glGetUniformLocation (id shader) "ViewMatrix") 1 GL_FALSE v)
        (glUniformMatrix4fv (glGetUniformLocation (id shader) "ProjectionMatrix") 1 GL_FALSE p)
        (glUniformMatrix3fv (glGetUniformLocation (id shader) "NormalMatrix") 1 GL_FALSE mn)
        (glUniformMatrix4fv (glGetUniformLocation (id shader) "ModelViewMatrix") 1 GL_FALSE mv)
        (glUniformMatrix4fv (glGetUniformLocation (id shader) "ModelViewProjectionMatrix") 1 GL_FALSE mvp)
        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
  • aiProcess_JoinIdenticalVertices    scheme
  • 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
  • desolve    macro
  • dict_update    xtlang
  • fluid-lin-solve    xtlang
  • fluid-lin-solve    xtlang
  • fluid_lin_solve    xtlang
  • fragshader    scheme
  • get-llvm-path    scheme
  • impc:aot:insert-ext-globalvar-binding-details    scheme
  • impc:aot:insert-globalvar-binding-details    scheme
  • impc:compiler:print-could-not-resolve-generic-type-error    scheme
  • impc:compiler:print-could-not-resolve-type-error    scheme
  • impc:compiler:print-could-not-resolve-types    scheme
  • impc:compiler:print-could-not-resolve-types_find-expr    scheme
  • impc:ir:compiler:llvm_varargs    scheme
  • impc:ti:check-to-update-generic-vars    scheme
  • impc:ti:find-unresolved-simple-types    scheme
  • impc:ti:get-globalvar-docstring    scheme
  • impc:ti:get-globalvar-type    scheme
  • impc:ti:globalvar-exists?    scheme
  • impc:ti:print-globalvar-cache    scheme
  • impc:ti:register-new-globalvar    scheme
  • impc:ti:reset-globalvar-cache    scheme
  • impc:ti:set-globalvar-docstring    scheme
  • impc:ti:try-to-resolve-named-types    scheme
  • impc:ti:update-closure-name    scheme
  • impc:ti:update-var    scheme
  • init_lv2_amp    xtlang
  • kinect_update_body    xtlang
  • lilv_activate    xtlang
  • lilv_init_world    xtlang
  • lilv_load_plugin    xtlang
  • lilv_print_all_lv2_plugins    xtlang
  • lilv_print_all_plugin_ports    xtlang
  • linsolve    macro
  • llvm:asm    macro
  • llvm:compile-ir    scheme
  • llvm:compile-ir-and-print    scheme
  • llvm:get-closure-setter    scheme
  • llvm:get-native-closure    scheme
  • llvm:get-native-function    scheme
  • llvm:ir    macro
  • model_update    xtlang
  • position_update    xtlang
  • print_shader_info_log    xtlang
  • set_instance_matrices    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_lights    xtlang
  • shader_update_material    xtlang
  • shader_update_material    xtlang
  • shader_update_material    xtlang
  • shader_update_matrices    xtlang
  • shader_update_matrices_lvs    xtlang
  • shader_update_projection_texture    xtlang
  • shader_update_uvwmatrix    xtlang
  • shadertoy-loop    scheme
  • solve    macro
  • update    xtlang
  • update    xtlang
  • update-borders    xtlang
  • update-fluid-sym-state    xtlang
  • update_cube    xtlang
  • update_data_points    xtlang
  • vertshader    scheme
  • 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
  • xtm_vg_reset_matrices    xtlang
  • xtmdoc-globalvar-handler    scheme
  • xtmtest-update-test-result    scheme
  • xtmtest-update-test-result    scheme