c++ - GLSL per vertex fixed size array -



c++ - GLSL per vertex fixed size array -

is possible in desktop glsl pass fixed size array of floats vertex shader attribute? if yes, how?

i want have per vertex weights character animation have next in vertex shader:

attribute float weights[25];

how fill attribute array c++ & opengl program? have seen in question attribute location of array attribute , add together index location. give illustration on pretty big array?

thanks.

let's start asked for.

on pretty much no hardware exists attribute float weights[25]; compile. while shaders can have arrays of attributes, each array index represents new attribute index. , on hardware exists, maximum number of attribute indices is... 16. you'd need 25, , that's just weights.

now, can mitigate plenty remembering can utilize vec4 attributes. thus, store every 4 array elements in single attribute. array attribute vec4 weights[7]; doable. weight-fetching logic have alter of course.

even so, don't seem taking in ramifications of mean vertex data. each attribute represents component of vertex's data. each vertex rendering phone call have same amount of data; contents of info differ, not how much data.

in order you're suggesting, every vertex in mesh need 25 floats describing weight. if stored normalized unsigned bytes, that's still 25 bytes worth of info @ minimum. that's lot. considering vast bulk of vertices, of these values 0. in worst case, you'd looking @ maybe 6-7 bones affecting single vertex.

the way skinning done in vertex shaders limit number of bones affects single vertex four. way, don't utilize array of attributes; utilize vec4 attribute weights. of course, need bone associated weight. have sec vec4 attribute specifies bone index weight.

this strikes balance. take 2 attributes (which can unsigned bytes in terms of size). , vast bulk of vertices, you'll never notice, because vertices influenced 1-3 bones. few uses 4, , fewer still utilize 5+. in cases, cutting off lowest weights , recompute weights of others proportionately.

c++ opengl glsl vertex-shader

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -