Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Multiple Post Processing - FBO Bug?

  1. #1
    Intern Newbie
    Join Date
    Mar 2013
    Posts
    42

    Question Multiple Post Processing - FBO Bug?

    Hallo

    I implemented a multiple post processing shader support for my game, but now, i have the following bug:
    When i use and render my post processing shaders to the fbo texture, i become some strange half transparent lines. It looks like a blur effect or something else.

    Here a screenshot (On the left side from the black lines, i've added with paint, there are the strange half transparent lines!):
    In this example, i used my cartoon edge shader, and my bloom shader.
    Click image for larger version. 

Name:	Bug.jpg 
Views:	165 
Size:	21.0 KB 
ID:	1031
    I really hope you can see them ;-)
    You can see them pretty good on very bright textures!

    This is my multiple post processing code:
    Code :
    GL11.glDrawBuffer(GL11.GL_NONE);
    		GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbo);
     
    		usePostProcessingTexture(renderer.getSceneTexture(0));
     
    		List<Filter> filters = postprocessor.getFilterList();
     
    		for (Filter filter : filters) {
    			if ((filter instanceof PostProcessable) && !(filter instanceof PreProcessable)) {
    				filter.filter(screentexture, renderer.getDepthTexture(), renderer.getNormalTexture());
    				usePostProcessingTexture(screentexture);
    				((PostProcessable) filter).unuseFilter();
    			}
    		}
     
    		GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
    		GL11.glDrawBuffer(GL11.GL_BACK);
     
    		usePostProcessingTexture(screentexture);

    The following code, renders my post processed image to the screen.
    I think, the problem might be here:
    Code :
    /**
    	 * Uses the post processing texture.
    	 */
    	private void usePostProcessingTexture(int scene) {
    		GL13.glActiveTexture(GL13.GL_TEXTURE30);
    		GL11.glBindTexture(GL11.GL_TEXTURE_2D, scene);
    		GL11.glBegin(GL11.GL_QUADS);
    		{
    			GL11.glTexCoord2f(0, 1);
    			GL11.glVertex2f(0, 0);
     
    			GL11.glTexCoord2f(0, 0);
    			GL11.glVertex2f(0, Display.getHeight());
     
    			GL11.glTexCoord2f(1, 0);
    			GL11.glVertex2f(Display.getWidth(), Display.getHeight());
     
    			GL11.glTexCoord2f(1, 1);
    			GL11.glVertex2f(Display.getWidth(), 0);
    		}
    		GL11.glEnd();
    		GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
    		GL13.glActiveTexture(GL13.GL_TEXTURE0);
    	}

    And this is my FBO initialization code:
    Code :
    screentexture = LwjglRenderer.createRenderableTexture();
     
    		fbo = GL30.glGenFramebuffers();
    		GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbo);
    		GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, screentexture, 0);
     
    		if (GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) != GL30.GL_FRAMEBUFFER_COMPLETE) {
    			throw new OpenGLException("Was not able to create framebuffer for post processing!");
    		}
     
    		GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);

    This here:
    Code :
    LwjglRenderer.createRenderableTexture();
    Just creates a new texture:
    Code :
    /**
    	 * Creates a new renderable texture.
    	 *
    	 * @return Empty texture.
    	 */
    	public static int createRenderableTexture() {
    		int texture = glGenTextures();
    		glBindTexture(GL_TEXTURE_2D, texture);
    		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, Display.getWidth(), Display.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null);
    		return texture;
    	}

    The shaders are not the problem!
    I really hope, someone of you guys can help me

    MfG, Daniel!
    Last edited by Alphaomega86; 05-20-2013 at 01:11 PM.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    746
    Code :
    GL11.glDrawBuffer(GL11.GL_NONE);
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbo);
     
    usePostProcessingTexture(renderer.getSceneTexture(0));

    This looks a bit odd to me; you disable draw buffers and then draw a full screen quad?

    Anyway, I can't tell from the code you posted, but are you reading and writing the same texture when applying your post-process filters? That does not work, you'll have to ping-pong between two textures, one to hold the output of the previous filter (read by the current filter), the other to receive the output of the current filter.

  3. #3
    Intern Newbie
    Join Date
    Mar 2013
    Posts
    42
    This looks a bit odd to me; you disable draw buffers and then draw a full screen quad?
    This was not the problem as i tried.

    Anyway, I can't tell from the code you posted, but are you reading and writing the same texture when applying your post-process filters? That does not work, you'll have to ping-pong between two textures, one to hold the output of the previous filter (read by the current filter), the other to receive the output of the current filter.
    You're right, i read and write the same texture! This might be the problem.
    But, why do i need to swap between two textures?
    Last edited by Alphaomega86; 05-21-2013 at 02:44 AM.

  4. #4
    Intern Newbie
    Join Date
    Mar 2013
    Posts
    42
    I got it

    I did not even have to swap between two textures.
    I just copy the screen to the scene texture.

    Code :
    filters.get(i).filter(scene, depth, normal);
    usePostProcessingTexture(scene);
    ((PostProcessable) filters.get(i)).unFilter();
     
    glBindTexture(GL_TEXTURE_2D, scene);
    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Display.getWidth(), Display.getHeight());
    glBindTexture(GL_TEXTURE_2D, 0);

    Thanks for your help!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •