Killing artifacts on OpenGL Shaders using Mesa3D

Today I was finally able to upgrade the MESA3D libraries using DRI HW accelleration on my Ubuntu 10.10 installation.

 

The upgrade fixed a lot of problems, in particular the rendering of the meshes now don’t have anymore the strange artifacts of polygons blinking around. Not bad, nice start.

 

Having finally apparently solved the situation I started to work in the real OpeGL ES 2.0 porting and in particular the rewriting of the Hemi Light shader, a shader that I have already successfully implemented before the move to ES20 and the absence of the matrix transformation functions.

 

The real issue I have had was the replacement of the standard built in OpenGL vertex shader functions such as the gl_NormalMatrix function which is very widely used in the common shaders.

 

I have checked around and the best I have found was that the function is the transpose of the inverse of the upper leftmost 3×3 of gl_ModelViewMatrix.

 

I have therefore implemented by own transpose matrix function considering only the leftmost 3×3 sub matrix of the 4×4 model matrix and this very simple function was created:

void PATRIA_Matrix_Transpose(PATRIA_Matrix3 *result, PATRIA_Matrix *srcA){

PATRIA_Matrix    tmp;
    tmp.m[0][0] = srcA->m[0][0];
    tmp.m[0][1] = srcA->m[1][0];
    tmp.m[0][2] = srcA->m[2][0];
    tmp.m[1][0] = srcA->m[0][1];
    tmp.m[1][1] = srcA->m[1][1];
    tmp.m[1][2] = srcA->m[2][1];
    tmp.m[2][0] = srcA->m[0][2];
    tmp.m[2][1] = srcA->m[1][2];
    tmp.m[2][2] = srcA->m[2][2];
    memcpy(result, &tmp, sizeof(PATRIA_Matrix));
}
The function as it is right now should be very very efficient.  As usual, special thanks to the samples of matrix manipulation I have found on the book OpenGL ES 2.0 Programming Guide.
Going deeper, everything started looking quite good except for some artifacts I am unable so far to explain such as the following:
TO BE CONCLUDED

 

 

 

 

What is very strange is that the artifacts are not visible on all the situations. For instance here it looks quite good:

 

 

 

Leave a comment