|
![](/i/fill.gif) |
Hi all, I'm once again having math trouble :(
A macro I'm writing needs to calculate reflected vectors (it simulates
reflected caustics in Superpatch, I'll probably post it soon...)
However, the function I use to calculate the reflected vectors has 2
shortcomings:
1) it doesn't work when the incoming ray is parallel/anti-parallel with the
surface normal (the vaxis_rotate function would have the rotation axis of
<0,0,0>)
2) because I use asin, the reflecion vector is incorrect when the ray hits the
surface at >=0 degrees (for example when surface normals point into the object
in CSG)
Here's the macro I use to calculate the vector; if anybody could provide a
solution to these problems or give a more optimal method, I'd be thankful
indeed.
Margus
//V - ray direction vector (from intersection to origin)
//N - surface normal
#macro v_mirror(V,N)
(
vnormalize
(
vaxis_rotate
(
(V),
vcross((V),N),
2*degrees(asin(vlength(vcross(vnormalize((V)),vnormalize(N)))))
)
)
)
#end
Post a reply to this message
|
![](/i/fill.gif) |