由矢量组成的旋转矩阵是否需要归一化?

时间:2016-10-18 03:35:56

标签: graphics shader gpu

最近我在一个着色器中看到了一些代码片段。

代码如下(它实际上并不重要的是着色器语言。)

float2 mv = tex2Dlod(_CameraMotionVectorsTexture, uv).rg * _Amplitude;

// Make a rotation matrix based on the motion vector.
float2x2 rot = float2x2(mv.y, mv.x, -mv.x, mv.y);

// Rotate and scale the body of the arrow.
float2 pos = mul(rot, v.vertex.zy) * _Scale.xy;

// Normalized variant of the motion vector and the rotation matrix.
float2 mv_n = normalize(mv);
float2x2 rot_n = float2x2(mv_n.y, mv_n.x, -mv_n.x, mv_n.y);

// Rotate and scale the head of the arrow.
float2 head = float2(v.vertex.x, -abs(v.vertex.x)) * 0.3;
head *= saturate(color.a);
pos += mul(rot_n, head) * _Scale.xy;

正如你的家伙所见,腐蚀矩阵是由运动矢量组成的,不能正常化。但是被称为rot_n的第二旋转矩阵的两个轴向量相反地被归一化,其在创建旋转矩阵之前仅在运动向量上归一化。我无法弄清楚为什么,在制作旋转矩阵之前,为什么代码的作者不能一直标准化运动矢量?

有人可以帮我摆脱这个问题,我真的很感激。先谢谢你!

1 个答案:

答案 0 :(得分:0)

可能涉及到规模,只是撤消它的规模。是吗?

相关问题