Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glm_vec4_refract #1221

Open
gottfriedleibniz opened this issue Jan 17, 2024 · 0 comments · May be fixed by #1251
Open

glm_vec4_refract #1221

gottfriedleibniz opened this issue Jan 17, 2024 · 0 comments · May be fixed by #1251

Comments

@gottfriedleibniz
Copy link

glm_vec4_refract incorrectly computes k. Per GLSL:

k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))

Stepping through the function:

glm_vec4 const dot0 = glm_vec4_dot(N, I);                  // dot(N, I)
glm_vec4 const mul0 = _mm_mul_ps(eta, eta);                // eta * eta
glm_vec4 const mul1 = _mm_mul_ps(dot0, dot0);              // dot(N, I) * dot(N, I)
glm_vec4 const sub0 = _mm_sub_ps(_mm_set1_ps(1.0f), mul0); // 1.0 - eta * eta
glm_vec4 const sub1 = _mm_sub_ps(_mm_set1_ps(1.0f), mul1); // 1.0 - dot(N, I) * dot(N, I)
glm_vec4 const mul2 = _mm_mul_ps(sub0, sub1);              // k = (1.0 - eta * eta) * (1.0 - dot(N, I) * dot(N, I))

Which is incorrect. Additionally, the _mm_movemask_ps logic is confusing (_mm_cmplt_ss only sets the lowest element while _mm_movemask_ps creates a mask from all four elements).

@christophe-lunarg christophe-lunarg linked a pull request Feb 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants