08-13-2011, 05:25 PM
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.
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.