Luecxjee

08-08-2016, 09:44 AM

Dear forum,

I got a problem i am not able to solve alone with my geometry shader.

I never really worked with them so i've read some tutorials but sadly, my code seems not to be working.

Below is my code of my vs, gs and fs. In the vs and fs i did not copy the whole code and calculation because i think, that i not needed for finding the problem due the fact

that my code is working perfectly without a geometry shader.

VS:

#version 400 core

in vec3 position;

in vec2 textureCoords;

in vec3 normal;

in vec3 tangent;

out vec2 pass_textureCoords;

out vec3 toLightVector[4];

out vec3 toCameraVector;

out float fogFactor;

uniform mat4 transformationMatrix;

uniform mat4 projectionMatrix;

uniform mat4 viewMatrix;

uniform vec3 lightPositionEyeSpace[4];

uniform float textureStretch;

uniform float fogGradient;

uniform float fogDensity;

void main(void) {........}

GS:

#version 150

layout(triangles) in;

layout (triangle_strip, max_vertices=6) out;

in VertexData {

vec2 pass_textureCoords;

vec3 toLightVector[4];

vec3 toCameraVector;

float fogFactor;

} VertexIn[3];

out VertexData {

vec2 pass_textureCoords;

vec3 toLightVector[4];

vec3 toCameraVector;

float fogFactor;

} VertexOut;

void main()

{

for(int i = 0; i < gl_in.length(); i++)

{

// copy attributes

gl_Position = gl_in[i].gl_Position;

VertexOut.pass_textureCoords = vec2(1,1);

VertexOut.toLightVector = VertexIn[i].toLightVector;

VertexOut.toCameraVector = VertexIn[i].toCameraVector;

VertexOut.fogFactor = VertexIn[i].fogFactor;

// done with the vertex

EmitVertex();

}

EndPrimitive();

}

And finally the FS:

#version 400 core

in vec3 toLightVector[4];

in vec2 pass_textureCoords;

in vec3 toCameraVector;

in float fogFactor;

out vec4 out_Color;

uniform sampler2D modelTexture;

uniform sampler2D normalMap;

uniform vec3 lightColour[4];

uniform vec3 attenuation[4];

uniform float shineDamper;

uniform float reflectivity;

uniform float useLighting;

uniform vec3 fogColor;

uniform float fog;

void main(void) {.......}

My render method looks like this:

GL11.glDrawElements(GL11.GL_TRIANGLES, model.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);

Befor i load the uniform variables i call these methods:

GL11.glEnable (GL11.GL_BLEND);

GL11.glBlendFunc (GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

GL11.glEnable(GL11.GL_DEPTH_TEST);

It would be great if someone could take his time and find my problem :)

I got a problem i am not able to solve alone with my geometry shader.

I never really worked with them so i've read some tutorials but sadly, my code seems not to be working.

Below is my code of my vs, gs and fs. In the vs and fs i did not copy the whole code and calculation because i think, that i not needed for finding the problem due the fact

that my code is working perfectly without a geometry shader.

VS:

#version 400 core

in vec3 position;

in vec2 textureCoords;

in vec3 normal;

in vec3 tangent;

out vec2 pass_textureCoords;

out vec3 toLightVector[4];

out vec3 toCameraVector;

out float fogFactor;

uniform mat4 transformationMatrix;

uniform mat4 projectionMatrix;

uniform mat4 viewMatrix;

uniform vec3 lightPositionEyeSpace[4];

uniform float textureStretch;

uniform float fogGradient;

uniform float fogDensity;

void main(void) {........}

GS:

#version 150

layout(triangles) in;

layout (triangle_strip, max_vertices=6) out;

in VertexData {

vec2 pass_textureCoords;

vec3 toLightVector[4];

vec3 toCameraVector;

float fogFactor;

} VertexIn[3];

out VertexData {

vec2 pass_textureCoords;

vec3 toLightVector[4];

vec3 toCameraVector;

float fogFactor;

} VertexOut;

void main()

{

for(int i = 0; i < gl_in.length(); i++)

{

// copy attributes

gl_Position = gl_in[i].gl_Position;

VertexOut.pass_textureCoords = vec2(1,1);

VertexOut.toLightVector = VertexIn[i].toLightVector;

VertexOut.toCameraVector = VertexIn[i].toCameraVector;

VertexOut.fogFactor = VertexIn[i].fogFactor;

// done with the vertex

EmitVertex();

}

EndPrimitive();

}

And finally the FS:

#version 400 core

in vec3 toLightVector[4];

in vec2 pass_textureCoords;

in vec3 toCameraVector;

in float fogFactor;

out vec4 out_Color;

uniform sampler2D modelTexture;

uniform sampler2D normalMap;

uniform vec3 lightColour[4];

uniform vec3 attenuation[4];

uniform float shineDamper;

uniform float reflectivity;

uniform float useLighting;

uniform vec3 fogColor;

uniform float fog;

void main(void) {.......}

My render method looks like this:

GL11.glDrawElements(GL11.GL_TRIANGLES, model.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);

Befor i load the uniform variables i call these methods:

GL11.glEnable (GL11.GL_BLEND);

GL11.glBlendFunc (GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

GL11.glEnable(GL11.GL_DEPTH_TEST);

It would be great if someone could take his time and find my problem :)