html5 - How do you get a parallel vector on a plane that an intersecting ray just hit? -
my problem: http://i.imgur.com/fphnzcv.jpg
what have: intersect, n, p. p random point in space. n plane's normal.
what seek: w
how tried solve in shader:
"vec3 n = normalize(facenormal);", "vec3 p = vec3(1.0);", "vec3 u = p - intersect;", "vec3 absnormal = abs(n);", "vec3 v = dot(u, n) * n / (absnormal * absnormal);", "vec3 w = u - v;",
and vector doesn't become parallel plane: http://i.imgur.com/9omscb6.png
anybody see i've thought wrong?
thanks!
abs()
absolute value. should using length()
function.
"vec3 v = dot( u, n ) * n / ( length( n ) * length( n ) );",
Comments
Post a Comment