如果我有一个四边形,由6个顶点组成,我如何将光矢量投影到这6个顶点的平面上?
我目前有6个顶点,两个四边形,
要点是
A X C.
B Y D
点X,Y来自两个射线向下投射。
C = X + RightVector
D = Y + RightVector
A = X- RightVector
B = Y - RightVector
现在我想基于lightDirectionVector翻译顶点,我该怎么做? 我有一个定向灯,两个四边形的网格充当阴影四边形。
Vector3 lightDir = mDirectionalLight.transform.forward;
Vector3 normLight = lightDir.normalized;
normaLight.y = 0;
答案 0 :(得分:1)
首先是一些定义
现在好了怎么做:
N' = (P1-P0) x (P2-P1); // or any other non-zero vector combination.
N = N' / |N'|; // it is better if normal is unit vector
L = L' / |L'|; // the same goes for light
// now you need some temporary vector n which is L projected onto N
n = N * (N.L)
// now the shift direction (lie on the Quad plane)
D' = L - N
// and now scale by d - perpendicular distance of Quad or point to projection source (light)
D = D' * d
// the rest is easy
Qi = Pi + D