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.
[ATTACH=CONFIG]423[/ATTACH]
I really hope you can see them :wink:
You can see them pretty good on very bright textures!

This is my multiple post processing 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:

/**
	 * 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:

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:

LwjglRenderer.createRenderableTexture();

Just creates a new texture:

/**
	 * 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 :slight_smile:

MfG, Daniel!


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.

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?

I got it :slight_smile:

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


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!