opengl es - How effectively interpolate between many color attributes in GLSL ES 2.0 -


i'm working on project opengl es 2.0. every vertex in mesh has fixed number of color attributes (lets 5). final per-vertex color computed interpolation between 2 selected color attributes.

in implementation, choice of 2 colors based on 2 given indexes. i'm aware if statement may big performance hit choose put attributes 1 array , use indexing retrieve wanted colors. still see significant performance drop.

attribute vec4 a_position; //the glsl es 2.0 specification states attributes cannot declared arrays. attribute vec4 a_color; attribute vec4 a_color1; attribute vec4 a_color2; attribute vec4 a_color3; attribute vec4 a_color4;  uniform mat4 u_projtrans; uniform int u_index; uniform int u_index1; uniform float u_interp;  varying vec4 v_color;   void main() {    vec4 colors[5];    colors[0] = a_color;    colors[1] = a_color1;    colors[2] = a_color2;    colors[3] = a_color3;    colors[4] = a_color4;     v_color = mix(colors[u_index], colors[u_index1], u_interp);     gl_position =  u_projtrans * a_position; } 

is there better more efficient way of computing final color interpolation? or @ least better way choose interpolation colors?

the indices use here uniforms. means every vertex in each rendering command uses same indices. if that's case... why bother fetching stuff in vs @ all?

you should have 2 color input values. use glvertexattribpointer pick 2 arrays interpolated between.

your "significant performance drop" has nothing how fetch such values, , fact you're sending lots of per-vertex data never gets used anything.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -