lkang2 / glmatrix

Automatically exported from code.google.com/p/glmatrix
0 stars 0 forks source link

mat4.scale + mat4.inverse #29

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Props on that library! the API is graceful! But I have a bug with the matrix 
scaling :

What steps will reproduce the problem?
1. Scale a ModelView Matrix
2. Inverse and Transpose for the Normal Matrix
3. Specular Lights on normal mapped model looks wrong

What is the expected output? What do you see instead?
There are lights aberations that are not appearing when I don't touch the scale

Original issue reported on code.google.com by diagne.c...@gmail.com on 31 Jul 2010 at 4:44

GoogleCodeExporter commented 8 years ago
mat4.scale = function(mat, vec, dest) {
        var x = vec[0], y = vec[1], z = vec[2];

        if(!dest || mat == dest) {
                mat[0] *= x;
                mat[4] *= x;
                mat[8] *= x;
                mat[12] *= x;
                mat[1] *= y;
                mat[5] *= y;
                mat[9] *= y;
                mat[13] *= y;
                mat[2] *= z;
                mat[6] *= z;
                mat[10] *= z;
                mat[14] *= z;
                return mat;
        }

        dest[0] = mat[0]*x;
        dest[4] = mat[4]*x;
        dest[8] = mat[8]*x;
        dest[12] = mat[12]*x;
        dest[1] = mat[1]*y;
        dest[5] = mat[5]*y;
        dest[9] = mat[9]*y;
        dest[13] = mat[13]*y;
        dest[2] = mat[2]*z;
        dest[6] = mat[6]*z;
        dest[10] = mat[10]*z;
        dest[14] = mat[14]*z;
        dest[3] = mat[3];
        dest[7] = mat[7];
        dest[11] = mat[11];
        dest[15] = mat[15];
        return dest;
};

this should fix it 

        return dest;
};

Original comment by jeroom832@gmail.com on 1 Aug 2010 at 5:01

GoogleCodeExporter commented 8 years ago
Thanks for spotting that, and thank you jeroom for the fix. I'll get on this 
soon.

Original comment by Tojiro@gmail.com on 1 Aug 2010 at 5:43

GoogleCodeExporter commented 8 years ago
Fix implemented. Need to add unit test for it

Original comment by Tojiro@gmail.com on 12 Aug 2010 at 6:53

GoogleCodeExporter commented 8 years ago

Original comment by Tojiro@gmail.com on 27 Feb 2011 at 6:18