Forums > Gen

how to create and use a mat2 mat3 mat4 in codebox


Jul 04 2016 | 4:19 am

Hi everyone,

Making steady progress with converting shadertoy examples into jit.gl.pix with codebox.
So heres the next thing I’m stuck on.
How to create the equivalent of a mat2, mat3, mat4 in codebox ?

The book of shaders has the following explanation: link -http://thebookofshaders.com/glossary/?search=mat3

————————————————–
Mat3

3×3 floating point matrix

Declaration
mat3 aMat3 = mat3(1.0, 0.0, 0.0, // 1. column
0.0, 1.0, 0.0, // 2. column
0.0, 0.0, 1.0); // 3. column
mat3 bMat3 = mat3(1.0);

mat3 cMat3 = mat3(aVec3, bVec3, cVec3);
mat3 dMat3 = mat3(aVec4, aVec3, bVec4, aFloat);

————————————————–

How would I go about implementing this in codebox ?
I’d like to keep everything on the GPU so I don’t want to be creating small jit.matrix objects to send into the jit.gl.pix object.
Any pointers ?
Thanks !

Jul 05 2016 | 2:12 am

Okay, so I got it working with a 2d rotation, The patch is below.
Do’s anyone know any good references which can give clear code based examples for mat3 and mat4, I also see that a mat3 can be converted to a vec2 and so on.

— Pasted Max Patch, click to expand. —
Jul 08 2016 | 3:18 am

bump.

Jul 08 2016 | 10:07 am

which example are you trying to convert?

you should be able to perform mat3 math simply using 3 vec3’s as storing each row of the matrix.

Viewing 4 posts - 1 through 4 (of 4 total)

Forums > Gen