javascript - Setting uniforms in webgl -


can explain or point me in right direction of explaination of different functions used set uniform values. in cheat sheet here this:

void uniform[1234][fi](uint location, ...) void uniform[1234][fi]v(uint location, array value) void uniformmatrix[234]fv(uint location, bool transpose, array)

but i'd know each of these doing , f's , i's for.

1234 = dimensions

f = float

i = integer

v final character, if present, v, indicating command takes array (a vector) of values rather series of individual arguments

for non array uniform difference between v , non v versions of uniform functions how provide data it:

uniform1fv(loc,[3.14159]) vs uniform1f(loc,3.14159).

uniform3fv(loc,[.5,1.,.5]) vs uniform3f(loc,.5,1.,.5)

but array uniform can set entire array using v functions

in shader

uniform float somearray[10]; 

in js

// @ init time var location = gl.getuniformlocation(prg, "somearray");  // @ render time var arraywith10values = [5, 4, 1, 3, 4, 5, 12, 0.1, 2, -1]; gl.uniform1fv(location, arraywith10values); 

to non v functions you'd have every location

var location0 = gl.getuniformlocation(prg, "somearray[0]"); var location1 = gl.getuniformlocation(prg, "somearray[1]"); var location2 = gl.getuniformlocation(prg, "somearray[2]"); var location3 = gl.getuniformlocation(prg, "somearray[3]"); var location4 = gl.getuniformlocation(prg, "somearray[4]"); ...etc...  gl.uniform1f(location0, value0); gl.uniform1f(location1, value1); gl.uniform1f(location2, value2); gl.uniform1f(location3, value3); gl.uniform1f(location4, value4); ...etc... 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -