How to use Material.setParameter to pass an array of floats, vec3, vec4, etc
Can I use setParameter to assign value to uniform vec4 vertexParams[4];
or like uniform float vertexParams2[16]
. I tried them by assigning an array of numbers, but they don’t seem to work.
I did an audit. It seems it’s impossible to pass parameters to data types like: vec4
or vec4 array[]
or float array[]
to Material shader via setParameter
. Values don’t get sent at all.
In material script:
this.material.setParameter("testPosition", [1,1,1]);
this.material.setParameter("testvec4", [1,1,1,1]);
In vertex shader:
attribute vec3 position;
uniform vec4 testvec4;
uniform vec3 testPosition;
gl_Position = matrix_viewProjection * matrix_model * testvec4;
vs
gl_Position = matrix_viewProjection * matrix_model * vec4(testPosition,1);
2nd case works with vec3 parameter being used instead (testPosition
). But 1st case with vec4 testVec4
!!!
doesn’t work!.
I did an audit of the commit functions. It appears certain commit functions aren’t called for. UNIFORMTYPE_VEC4 and UNIFORMTYPE_FLOATARRAY!!) But UNIFORMTYPE_VEC3 does get called.
this.app.graphicsDevice.commitFunction[pc.UNIFORMTYPE_VEC4] = function(u) {
console.log("vec4 is called:"+u.locationId);
};
this.app.graphicsDevice.commitFunction[pc.UNIFORMTYPE_FLOATARRAY] = function(u) {
console.log("float f is called:"+u.scopeId.name);
};
this.app.graphicsDevice.commitFunction[pc.UNIFORMTYPE_VEC3] = function(u) {
console.log("vec3 f is called:"+u.scopeId.name);
};
Did you guys miss out something?