Matrix multiplication affect textures coordinates in Geometry Shader, too much code?

Hello,

I’m using a Geometry Shader to create cubes from points sent by the Vertex Shader. It does a big job, like testing which triangles must be sent to the Fragment Buffer or computing textures coordinates. I use transparent cubes so I must render cubes and faces of the cubes in the right order.
With a lot of if() conditions the program reach 1000+ instruction lines, but it still works fine.
I wanted to add rotation possibility for my cubes, so I added a if() part like this :


#version 330 core

layout(points) in;
layout(triangle_strip, max_vertices=36) out;

in VertexData {
	vec3 sto; // size, type and other data
	vec3 texcoord; // textures coordinates
	bool faces[6]; // precomputed data about faces to render or not
	vec4 lf1; // precomputed data about light by point (4 first points of the cube)
	vec4 lf2; // (4 last points of the cube)
} VertexIn[1];

out VertexData {
	vec4 texCoord; // text coord x, y, type, face
	vec3 pos; // original position (to test with lights)
	float lf; // non per-fragment light but precomputed per point light
} VertexOut;

// Values that stay constant for the whole mesh.
uniform mat4 MVP;
uniform vec3 eye;

// functions for drawing faces of the cubes
pX(...)
{
// emit 2 triangles
}
mX(...)
...
// functions for drawing faces of the cubes with rotation
pXr(..., mat4 matRot)
mXr(..., mat4 matRot)
...
main()
{
    if(rotation)
    {
        if(rotation and transparent)
        {
            // several conditions to draw in order with rotation matrix
        }
        else if(no rotation but still transparent)
        {
            // several conditions to draw in order
        }
        else
        {
            // just sending triangles in any order
        }
    }
}

But since I do that, every time I use the rotation matrix (the multiplication is called 4 times in 6 functions) computed by : translationMatrix1 * rotationXMatrix * rotationYMatrix * rotationZMatrix * translationMatrix2
the textures coordinates sent by the vertex shader become just random crap. If I take the same code but without rotation (like defining my rotation matrix to mat4(1.0f)) it isn’t bugging anymore.
EDIT : An important thing I forgot to say, it messes up ALL the textures coordinates that are going by this shader, even if the condition where matrix are used is impossible to enter in.

So do you have any leads for me to search ?
Using OpenGL 3.2 or more doesn’t change anything, like using GLSL 330 or another one. I have an AMD Radeon HD 6970M. Driver up-to-date.

I have found this topic
opengl dot org/discussion_boards/showthread.php/179119-Cg-shader-crash-at-runtime-maximum-instructions-reached?highlight=geometry+shader
where he/she has a similar problem but he’s got an error and I don’t.

Thanks
Don’t hesitate to ask me if I’m not clear, I tried to put the minimum of information to not overload the topic.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.