Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Should you set a matrix as a inparameter for a shader, with the uniformMatrix4fv function? Because I try to set a matrix (see example below) and the program doesnt run after the last row. I dont get any error messages or anything, it just exits the function, seemingly without setting the Matrix inside the shader. Pseudo code:
And also, I read in a earlier post that there would be more support for shaders with lighting and such. Is there a way to get the normal transform matrix directly from the engine, or do I have to set it manually? |
||||
|
Your problem maybe is that your TestMatrix isn't in the format WebGL wants it to be. You can use the renderers internal function for converting CopperLicht matrix to a WebGL matrix: var newmatrix = renderer.getMatrixAsWebGLFloatArray(yourCLMatrix); Set it then using something like this: renderer.gl.uniformMatrix4fv(location, false, newmatrix); If you define a variable named uniform mat4 normaltransform; in your shader, copperlicht will set this for you. |
||||
|
Yes, converting the matrix into a WebGL matrix makes it work just fine! Thanks! But I still cant get the
matrix to work in the vertex shader. It seems it must be setting the value to null or so, because the object is (in this case) complete green, but with my own matrix inparameter, it displays the color values correctly. Basicly what I do with the matrix, is that I normalize it with the normal, something like this pseudo code:
I will keep on using my own matrix, since that seems to work just fine. But I just wanted to mention it to you. |
|