aboutsummaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorMostafa Saad <moustapha.saad.abdelhamed@gmail.com>2023-03-17 00:29:50 +0200
committerMostafa Saad <moustapha.saad.abdelhamed@gmail.com>2023-03-17 00:29:50 +0200
commit5fdc9fa3b6a8c53ee98cefc4df47d2bd243d8976 (patch)
treee017a294cc514ed0e658fa72ee038103f502645d /core/math
parentbfb231fb8adeea282a51e6903ac2e6c0d2656dda (diff)
Fix #2389
Diffstat (limited to 'core/math')
-rw-r--r--core/math/linalg/extended.odin8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/math/linalg/extended.odin b/core/math/linalg/extended.odin
index b78697cbd..9dee12eb9 100644
--- a/core/math/linalg/extended.odin
+++ b/core/math/linalg/extended.odin
@@ -429,11 +429,11 @@ reflect :: proc(I, N: $T) -> (out: T) where IS_ARRAY(T), IS_FLOAT(ELEM_TYPE(T))
b := N * (2 * dot(N, I))
return I - b
}
-refract :: proc(I, N: $T) -> (out: T) where IS_ARRAY(T), IS_FLOAT(ELEM_TYPE(T)) {
- dv := dot(N, I)
- k := 1 - eta*eta - (1 - dv*dv)
+refract :: proc(I, Normal: $V/[$N]$E, eta: E) -> (out: V) where IS_ARRAY(V), IS_FLOAT(ELEM_TYPE(V)) {
+ dv := dot(Normal, I)
+ k := 1 - eta*eta * (1 - dv*dv)
a := I * eta
- b := N * eta*dv*math.sqrt(k)
+ b := Normal * (eta*dv+math.sqrt(k))
return (a - b) * E(int(k >= 0))
}