Results 1 to 2 of 2

Thread: How to send 4x4 matrices in a texture to the vertex shader?

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    15

    How to send 4x4 matrices in a texture to the vertex shader?

    How do I send a many 4x4 matrices to the vertex shader using textures in WebGL? I would like to do this for skeletal transformations. Doing this all in the cpu kills my frame rate.

  2. #2
    Junior Member
    Join Date
    Jun 2010
    Posts
    7

    Re: How to send 4x4 matrices in a texture to the vertex shad

    How are you storing, manipulating, and sending the matrices to the shader? I see a lot of tutorials that have something like the following:

    gl.uniformMatrix4fv(modelViewMatUniform, new Float32Array(matrixArray));

    This is really not very performance friendly, because you are allocating memory, copying into the new buffer, and then deallocating with every matrix you set. A better methodology is to store the matrices as the appropriate array type to begin with (there's a couple of libraries that do that) or at the very least create the array once and maintain it for the lifetime of the page.

    Beyond that, though, we would need to see some code to help.

Similar Threads

  1. Is texture2D allowed in a *vertex* shader?
    By sharoz in forum Developers Coding:Beginner
    Replies: 4
    Last Post: 12-07-2010, 02:31 PM
  2. A Question about Vertex shader
    By Choisy in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 05-29-2005, 07:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •