2

I create my array this.kernel: it hast 48 elements and I want to pass it to my fragment shader.

When i call

 gl.uniform3fv(gl.getUniformLocation(this.program, "kernel"), 16, this.kernel);

kernel is defined in my shader:

uniform vec3 kernel[16]; 

I get an error for not enough arguments. I already looked up the specification etc, but don't find my problem -.-

void glUniform3fv(  GLint  location, GLsizei  count, const GLfloat * value);

Thanks for help

€: I converted this.kernel to a float32array but I still have this error.

€2: error in Chrome: not enough arguments

in Firefox: NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument

1 Answer 1

3

Your this.kernel needs to be a Float32Array of length 48 (=3*16). You cannot use an array of vec3s.

Also the count is not used in WebGL. The function is (from WebGL Specification)

void uniform3fv(WebGLUniformLocation? location, Float32Array v);

Example usage:

gl.uniform3fv(gl.getUniformLocation(shaderProgram, "colors"), new Float32Array([0,1,2,3,4,5]));

See a complete example here: http://jsfiddle.net/mortennobel/URvtx/

Sign up to request clarification or add additional context in comments.

2 Comments

AH ok. I changed my array this.kernel to this.kernel = new Float32Array(this.kernel); The length is exactly 48 long. Just to be clear I meant the kernel in my shader is a vec3 Still getting the error not enough arguments.
Thank you. I experimented so much but it seems I forgot this variation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.