[lwjgl][solved] Geometry shader issue

So I am currently using a geometry shader in an attempt to create textured squares for my particle system , however they appear to have an extremely odd effect when I generate them and instead of just creating two triangle_strips they fill the right side of the screen with triangles aswell. I am baffled as everything looks right to me help would be appreciated.
Here is what happens

Here is my vert shader code:


uniform float alpha;
uniform float time;
uniform vec2 spawn;
uniform float decay;
uniform vec2 dimension;
uniform float size;
attribute vec3 vecin;
attribute vec2 texin;

void main(){
	float x_move,y_move;
	x_move = ((time * (vecin.x - spawn.x)) - ((((time-decay)/10000) * (time) * (vecin.x - spawn.x))) );
	y_move = ((time * (vecin.y - spawn.y)) - ((((time-decay)/10000) * (time) * (vecin.y - spawn.y)))  );
	x_move/= 10000;
	y_move/= 10000;
   	gl_Position = vec4(vecin.x + x_move,vecin.y + y_move,texin.x,texin.y);
   
}

Geometry shader


#version 330
//uses an 8 by 8 spritesheet make sure you use it!

layout (points) in;
layout (triangle_strip) out;
layout (max_vertices = 4) out;
uniform vec2 dimension;
uniform float size;
out vec2 texcoord;
void main(){
   vec2 size_adjust = vec2(size/dimension.x,size/dimension.y);
   float eigth = (1/8);
    gl_Position = vec4(gl_in[0].gl_Position.x,gl_in[0].gl_Position.y,1,1);
    texcoord = vec2(gl_in[0].gl_Position.z,gl_in[0].gl_Position.w + eigth);
    EmitVertex();
    gl_Position = vec4(gl_in[0].gl_Position.x,gl_in[0].gl_Position.y + size_adjust.y,1,1);
    texcoord = vec2(gl_in[0].gl_Position.z,gl_in[0].gl_Position.w);
    EmitVertex();
    gl_Position = vec4(gl_in[0].gl_Position.x + size_adjust.x,gl_in[0].gl_Position.y,1,1);
    texcoord = vec2(gl_in[0].gl_Position.z + (1/8),gl_in[0].gl_Position.w + (1/8));
    EmitVertex();
    gl_Position = vec4(gl_in[0].gl_Position.x + size_adjust.x,gl_in[0].gl_Position.y + size_adjust.y,1,1);
    texcoord = vec2(gl_in[0].gl_Position.z + eigth,gl_in[0].gl_Position.w);
    EmitVertex();

    EndPrimitive();
}

and my frag shader


uniform sampler2D texture;
uniform float alpha;
in vec2 texcoord;
void main(){
	gl_FragColor = vec4(texture2D(texture,texcoord).rgb,alpha);
}

Thanks.

I’m not too familiar with geometry shaders but if your particles are small enough (<= 64 pixels wide on most graphics cards) you could look into point sprites, which give the same effect and would also (supposedly) be more efficient than geometry shaders.

I would rather use this type of setup, its my first attempt at efficient particle so this is the way I would like to stick with it.

After doing some testing it seems like one of my other shaders is interffering with it and its then modifying it back. It seems like all the data is being sent through the geometry shader instead of just the data that I would like, here is the shader code and the initialization of the variables.
shader class


public class Shaderclass {
	public int programID;
    
    int vertexShaderID;
    int fragmentShaderID;
    int geometryShaderID = -1;
  
    public Shaderclass()
    {
        programID = glCreateProgram();
    }
    
   
    public void attachVertexShader(String name)
    {
        String vertexShaderSource = FileBuilder.gettext(name);
        vertexShaderID = glCreateShader(GL_VERTEX_SHADER);
        glShaderSource(vertexShaderID, vertexShaderSource);
        glCompileShader(vertexShaderID);
        if (glGetShaderi(vertexShaderID, GL_COMPILE_STATUS) == GL_FALSE)
        {
            System.err.println("Unable to create vertex shader:");
            dispose();
           
        }
        glAttachShader(programID, vertexShaderID);
    }
  
    public void attachFragmentShader(String name)
    {
        String fragmentShaderSource = FileBuilder.gettext(name);
        fragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
        glShaderSource(fragmentShaderID, fragmentShaderSource);
        glCompileShader(fragmentShaderID);
        if (glGetShaderi(fragmentShaderID, GL_COMPILE_STATUS) == GL_FALSE)
        {
            System.err.println("Unable to create fragment shader:");
            dispose();
        }
        glAttachShader(programID, fragmentShaderID);
    }
    public void attachGeometryShader(String name)
    {
       
        String geometryShaderSource = FileBuilder.gettext(name);
        geometryShaderID = glCreateShader(GL_GEOMETRY_SHADER);
        glShaderSource(geometryShaderID, geometryShaderSource);

        glCompileShader(geometryShaderID);

        if (glGetShaderi(geometryShaderID, GL_COMPILE_STATUS) == GL_FALSE)
        {
            System.err.println("Unable to create Geometry shader:");
            dispose();

        }

        glAttachShader(programID, geometryShaderID);
    }
    
 
    public void link()
    {
        glLinkProgram(programID);
        if (glGetProgrami(programID, GL_LINK_STATUS) == GL_FALSE)
        {
            System.err.println("Unable to link shader program:");
            dispose();
           
        }
    }
  
    public void bind()
    {
        glUseProgram(programID);
    }

    public static void unbind()
    {
        glUseProgram(0);
    }

    public void dispose()
    {
        unbind();
        glDetachShader(programID, vertexShaderID);
        glDetachShader(programID, fragmentShaderID);
        glDeleteShader(vertexShaderID);
        glDeleteShader(fragmentShaderID);
        if(geometryShaderID != -1){
        	glDeleteShader(geometryShaderID);
        }
        glDeleteProgram(programID);
    }
}

and the coreVBO class



package com.lcass.graphics;

import org.lwjgl.opengl.GL20;

public class CoreVBO {
	public static int locationtime,locationbloom,locationtransform, locationzoom, locationrotatepos,locationdimension,locationrotate;
	public static int shader_id,vert_id,tex_id,particle_shader,particle_vert,particle_tex,particle_geom;
	public static int locationattribtex, locationattribvertex;
	public static int location_color;
	public static int particle_dimension,particle_time,particleattribvert,particleattribtex,particle_spawn,particle_decay,particle_alpha,particle_size;
	private Shaderclass shaderclass,line_shader_class,particle_shader_class;
	public CoreVBO(){
		shaderclass = new Shaderclass();
		shaderclass.attachFragmentShader("./src/shaders/default_frag.frag");
		shaderclass.attachVertexShader("./src/shaders/default_vert.vert");
		line_shader_class = new Shaderclass();
		line_shader_class.attachFragmentShader("./src/shaders/line_frag.frag");
		line_shader_class.attachVertexShader("./src/shaders/default_vert.vert");
		particle_shader_class = new Shaderclass();
		particle_shader_class.attachFragmentShader("./src/shaders/particle_frag.frag");
		particle_shader_class.attachVertexShader("./src/shaders/particle_vert.vert");
		particle_shader_class.attachGeometryShader("./src/shaders/particle_geom.geom");
		particle_shader_class.link();
		shaderclass.link();
		line_shader_class.link();
		
		
		shader_id = shaderclass.programID;
		vert_id = shaderclass.vertexShaderID;
		tex_id = shaderclass.fragmentShaderID;
		particle_shader = particle_shader_class.programID;
		particle_vert = particle_shader_class.vertexShaderID;
		particle_tex = particle_shader_class.fragmentShaderID;
		particle_geom = particle_shader_class.geometryShaderID;
		locationrotatepos = GL20.glGetUniformLocation(shader_id, "rotpos");
		locationtime = GL20.glGetUniformLocation(shader_id, "timein");
		locationbloom = GL20.glGetUniformLocation(shader_id, "bloomval");
		locationtransform = GL20.glGetUniformLocation(shader_id, "transform");
		locationzoom = GL20.glGetUniformLocation(shader_id,"zoom");
		
		locationdimension = GL20.glGetUniformLocation(shader_id,"dimension");
		locationrotate = GL20.glGetUniformLocation(shader_id,"rotation");
		locationattribtex = GL20.glGetAttribLocation(shader_id,"texin");
		locationattribvertex = GL20.glGetAttribLocation(shader_id, "position");

		particle_size = GL20.glGetUniformLocation(particle_shader, "size");
		particle_dimension = GL20.glGetUniformLocation(particle_shader,"dimension");
		particle_time = GL20.glGetUniformLocation(particle_shader,"time");
		particle_spawn = GL20.glGetUniformLocation(particle_shader, "spawn");
		particle_decay = GL20.glGetUniformLocation(particle_shader, "decay");
		particle_alpha = GL20.glGetUniformLocation(particle_shader,"alpha");
		particleattribvert = GL20.glGetAttribLocation(particle_shader, "vecin");
		particleattribtex = GL20.glGetAttribLocation(particle_shader, "texin");
		System.out.println(particle_size);
		
		
	}
	public void bind_shader(){
		shaderclass.bind();
	}
	public void un_bind_shader(){
		shaderclass.unbind();
	}
	public void bind_particle(){
		particle_shader_class.bind();
	}
	public void un_bind_particle(){
		particle_shader_class.unbind();
	}
	public void dispose(){
		particle_shader_class.dispose();
		line_shader_class.dispose();
		shaderclass.dispose();
	}
}

UGh resolved!
Turns out I had forgotten to make it disable standard rendering so it was trying to rendering triangles and points at the same time. So trivial yet such an easy mistake!

in the shader on line 12, [icode]float eigth = (1/8);[/icode] is a bit dangerous. try [icode]float eigth = (1.0/8.0);[/icode] instead.

I would use 0.125 instead. I’ve never been sure if the program automatically changes things like that. So I just do it myself.