shader_update_matrices_lvs   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_lvs
  (let ((i:i32 0)
        (mlvpb:float* (alloc (* 10 16)))
        (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* lights:i32 lv:float*) ;; lv is lights
      ;; view
      (dotimes (i lights)
        (let ((mlv:float* (salloc 16))
              (mlvp:float* (salloc 16)))
          (mmmul m (pref-ptr lv (* i 16)) mlv)
          (mmmul mlv p mlvp)
          (mmmul mlvp bias (pref-ptr mlvpb (* i 16)))))
      (glUniformMatrix4fv (glGetUniformLocation (id shader) "LightModelViewProjectionMatrix")
                          lights GL_FALSE mlvpb)
      (let ((mv (salloc 48))
            (mvp (pref-ptr mv 16))
            (mn (pref-ptr mv 32)))
        (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
        (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    /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
  • set_instance_matrices    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_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_lights    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_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_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
  • xtm_vg_reset_matrices    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/openvg.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