Hello,
This is been really bugging me, the resource I’ve been using to learn from, the book of shaders (written in glsl) uses a technique for rotation that I haven’t been able to translate with success.
It’s using a rotation matrix, cos,sin,-sin,cos something like that, the return value is a mat2 in glsl, but the function is set up with a vec2, which doesn’t make sense to me when turning into hlsl, I don’t know how it’s returning a different type.
vec2 rotate(vec2 p, float angle)
{
float c = cos(angle);
float s = sin(angle);
return mat2(c,s,-s,c) * p;
}
my ghetto way was just to chop off the end like this below, doesn’t really work if you want to make something specific like a rotating tunnel.
float2 rotate(float2 p, float angle)
{
float c = cos(angle);
float s = sin(angle);
return float2(c,s) * p;
}
Does anyone have nay ideas of what to change it to? I know it should be float2x2, but haven’t managed to get it to work, says type mismatch. I’m not quite sure what to do, any thoughts?