mirror of
https://github.com/recp/cglm.git
synced 2025-12-24 20:34:58 +00:00
fix refract
This commit is contained in:
@@ -792,7 +792,7 @@ TEST_IMPL(GLM_PREFIX, vec2_refract) {
|
||||
r = GLM(vec2_refract)(v, N, eta, dest);
|
||||
// In 2D, we expect a similar bending behavior as in 3D, so we check dest[1]
|
||||
if (!(dest[0] == 0.0f && dest[1] == 0.0f)) {
|
||||
ASSERT(dest[1] < -sqrtf(0.5f)); // Refracted ray bends away from the normal
|
||||
ASSERT(dest[1] < -0.3f); // Refracted ray bends away from the normal
|
||||
ASSERT(r == true);
|
||||
} else {
|
||||
ASSERT(dest[0] == 0.0f && dest[1] == 0.0f); // Total internal reflection
|
||||
@@ -809,7 +809,7 @@ TEST_IMPL(GLM_PREFIX, vec2_refract) {
|
||||
eta = 1.5f / 1.33f;
|
||||
r = GLM(vec2_refract)(v, N, eta, dest);
|
||||
ASSERT(r == true);
|
||||
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal, less bending than air to glass
|
||||
ASSERT(dest[1] < -0.6f); // Expect bending towards the normal, less bending than air to glass
|
||||
|
||||
/* Diamond to Air (eta = 2.42 / 1.0) */
|
||||
eta = 2.42f / 1.0f;
|
||||
|
||||
@@ -1901,7 +1901,7 @@ TEST_IMPL(GLM_PREFIX, vec3_refract) {
|
||||
eta = 1.33f / 1.0f;
|
||||
r = GLM(vec3_refract)(v, N, eta, dest);
|
||||
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f)) {
|
||||
ASSERT(dest[1] < -sqrtf(0.5f));
|
||||
ASSERT(dest[1] < -0.3f);
|
||||
ASSERT(r == true);
|
||||
} else {
|
||||
ASSERT(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f);
|
||||
@@ -1922,7 +1922,7 @@ TEST_IMPL(GLM_PREFIX, vec3_refract) {
|
||||
|
||||
/* Expect bending towards the normal, less bending than air to glass */
|
||||
ASSERT(r == true);
|
||||
ASSERT(dest[1] < -sqrtf(0.5f));
|
||||
ASSERT(dest[1] < -0.6f);
|
||||
|
||||
/* Diamond to Air (eta = 2.42 / 1.0) */
|
||||
eta = 2.42f / 1.0f;
|
||||
|
||||
@@ -1586,7 +1586,7 @@ TEST_IMPL(GLM_PREFIX, vec4_refract) {
|
||||
eta = 1.33f / 1.0f;
|
||||
r = GLM(vec4_refract)(v, N, eta, dest);
|
||||
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f)) {
|
||||
ASSERT(dest[1] < -sqrtf(0.5f));
|
||||
ASSERT(dest[1] < -0.3f);
|
||||
ASSERT(r == true);
|
||||
} else {
|
||||
ASSERT(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f);
|
||||
@@ -1603,7 +1603,7 @@ TEST_IMPL(GLM_PREFIX, vec4_refract) {
|
||||
eta = 1.5f / 1.33f;
|
||||
r = GLM(vec4_refract)(v, N, eta, dest);
|
||||
ASSERT(r == true);
|
||||
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal, less bending than air to glass
|
||||
ASSERT(dest[1] < -0.6f); // Expect bending towards the normal, less bending than air to glass
|
||||
|
||||
/* Diamond to Air (eta = 2.42 / 1.0) */
|
||||
eta = 2.42f / 1.0f;
|
||||
|
||||
Reference in New Issue
Block a user