Hi, I'm trying to convert a function (glsl) for a Godot shader. In this code statement I get this compiling error which i can't understand:

dot(mat2(fract(sin(vec4(0.0, 1.0, 113.0, 114.0) + dot(i, vec2(1.0, 113.0)))*43758.5453))*vec2(1. - p.y, p.y), vec2(1. - p.x, p.x) );

Any suggestions? Thanks in advance. -j

Maybe I'm wrong, but the instruction is formally correct, in fact:

"dot" needs two vectors as arguments, and in the statement there is:

dot(mat2(...)*vec2, vec2) but mat2*vec2 is a vector.

am I right?

Can you give us the error message that pops up, if there is any? Edit: no wait, that's the title. :P

@jospic said: Maybe I'm wrong, but the instruction is formally correct, in fact:

"dot" needs two vectors as arguments, and in the statement there is:

dot(mat2(...)*vec2, vec2) but mat2*vec2 is a vector.

am I right?

Hmm, yes I missed it, that should afaik be correct but on closer inspection you also have a 1. in there that might be causing an issue. And same again in the second vector at the end.

edit: the documentation says:

Construction of matrix types requires vectors of the same dimension as the matrix.

Thus I guess it would need to be a mat4 to plug a vec4 into it. You can always swizzle to get the specific components you need out of it. Then again I'd expect the fract and the sine to output scalars so I'm as confused as you, I guess. :tongue:

I recon it's worth trying to fix those 1. scalars first.

Looking back at the docs, It looks to me you should construct the mat2 with two vec2's instead of a vec4.

EDIT: I meant a mat2, not mat4. The above post has been corrected.

I don't know what you mean, but using vec2's instead did the trick for me.

vec4 temp = fract(sin(vec4(0.0, 1.0, 113.0, 114.0) + dot(i, vec2(1.0, 113.0)))*43758.5453);

// the vec4 is split into two vec2s here in mat2.
dot(mat2(temp.xy, temp.zw)*vec2(1. - p.y, p.y), vec2(1. - p.x, p.x) );
2 years later