How to correctly use custom PMatrix with shaders as uniform (SOLVED)

edited April 2015 in GLSL / Shaders

Hello !

I searched for a while the correct way to play with PMatrix3D as a custom uniform for a shader and I finally get it, 5 minutes ago :)

I used the code from the LowLevelGL example given in Processing

in my "draw" function, I tryed to add this code

PMatrix3D m = new PMatrix();
m.rotateX(frameCount * 0.01f);
m.rotateY(frameCount * 0.01f);`

with this code in my vertexShader

gl_Position = transform * matrix * vertex;

But it didn't work correctly. I finally got the logic when I saw that

gl_Position = vertex * transform;

is not the same than

gl_Position = transform * vertex;

(the first one doesn't work as expected)

I tryed then to write this code

gl_Position = transform * vertex;
gl_Position *= matrix;

And everything now work as expected ! :D

I'm not sure if it's a bug or not... But I don't care anymore : it works ! :)

Sign In or Register to comment.