Fixed the inverse(mat3) polyfill for GLES2
This commit is contained in:
parent
364d019fee
commit
b02900478f
1 changed files with 9 additions and 5 deletions
|
@ -309,11 +309,15 @@ highp mat2 inverse(highp mat2 m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
highp mat3 inverse(highp mat3 m) {
|
highp mat3 inverse(highp mat3 m) {
|
||||||
highp float d = 1.0 / (m[0].x * (m[1].y * m[2].z - m[2].y * m[1].z) - m[1].x * (m[0].y * m[2].z - m[2].y * m[0].z) + m[2].x * (m[0].y * m[1].z - m[1].y * m[0].z));
|
highp float c01 = m[2].z * m[1].y - m[1].z * m[2].y;
|
||||||
return mat3(
|
highp float c11 = -m[2].z * m[1].x + m[1].z * m[2].x;
|
||||||
vec3((m[1].y * m[2].z - m[2].y * m[1].z), -(m[1].x * m[2].z - m[2].x * m[1].z), (m[1].x * m[2].y - m[2].x * m[1].y)) * d,
|
highp float c21 = m[2].y * m[1].x - m[1].y * m[2].x;
|
||||||
vec3(-(m[0].y * m[2].z - m[2].y * m[0].z), (m[0].x * m[2].z - m[2].x * m[0].z), -(m[0].x * m[2].y - m[2].x * m[0].y)) * d,
|
highp float d = 1.0 / (m[0].x * c01 + m[0].y * c11 + m[0].z * c21);
|
||||||
vec3((m[0].y * m[1].z - m[1].y * m[0].z), -(m[0].x * m[1].z - m[1].x * m[0].z), (m[0].x * m[1].y - m[1].x * m[0].y)) * d);
|
|
||||||
|
return mat3(c01, (-m[2].z * m[0].y + m[0].z * m[2].y), (m[1].z * m[0].y - m[0].z * m[1].y),
|
||||||
|
c11, (m[2].z * m[0].x - m[0].z * m[2].x), (-m[1].z * m[0].x + m[0].z * m[1].x),
|
||||||
|
c21, (-m[2].y * m[0].x + m[0].y * m[2].x), (m[1].y * m[0].x - m[0].y * m[1].x)) *
|
||||||
|
d;
|
||||||
}
|
}
|
||||||
|
|
||||||
highp mat4 inverse(highp mat4 m) {
|
highp mat4 inverse(highp mat4 m) {
|
||||||
|
|
Loading…
Reference in a new issue