Jump to content

  • Log In with Google      Sign In   
  • Create Account


Motion Blur with FBO


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 harshman_chris   Members   -  Reputation: 184

Like
0Likes
Like

Posted 11 April 2013 - 10:53 AM

So I am trying to come up with a way to do a motion blur effect without using the velocity vector method, this is not because I cannot do it with that, but a section of work I am working on where the requirement is to store each frame in an FBO then motion blur them.

 

Right now I pass my 4 FBO's into my shader. Then I run this fragment shader with them and output the result, I cannot seem to get this to produce any effect other than darkening or lighting the engine depending on changes to the code below. I have also tried mixing the frames together and applying weights. I think is is an issue on how many FBO frames I am holding.

 

#version 330

in vec2 uv0;

uniform sampler2D Blur1;
uniform sampler2D Blur2;
uniform sampler2D Blur3;
uniform sampler2D Blur4;

out vec4 colour;

void main()
{
	vec3 colorA = texture2D(Blur1,uv0).rgb;
	vec3 colorB = texture2D(Blur2,uv0).rgb;
	vec3 colorC = texture2D(Blur3,uv0).rgb;
	vec3 colorD = texture2D(Blur4,uv0).rgb;
	
	colour.rgb = colorA + colorB + colorC + colorD;

	colour.rgb /= 4;
}

 

 

How can I get a passable motion blur with 4 frames? I can also go up to 8 FBO frames.



Sponsor:

#2 japro   Members   -  Reputation: 887

Like
0Likes
Like

Posted 11 April 2013 - 12:37 PM

What do these 4 frames contain?



#3 harshman_chris   Members   -  Reputation: 184

Like
0Likes
Like

Posted 11 April 2013 - 01:00 PM

What do these 4 frames contain?

 

The current frame and the previous three frames



#4 powly k   Members   -  Reputation: 650

Like
0Likes
Like

Posted 11 April 2013 - 02:03 PM

Okay, since you can't actually read from an FBO but only use an FBO to render to a texture and then read that texture, here's the question: do you set up the active textures, bindings and uniforms correctly? How this should go is like this:

 

set active texture to N

bind your texture[N] to GL_TEXTURE_2D

glUniform1i(uniform N location, N)

 

N loops through 1...4, obviously. What this sounds like is you forgetting to call the gluniform1i - all the uniforms samplers are texture unit 0 unless you specify otherwise.

 

And please, do "uniform sampler2D Blur1, Blur2, Blur3, Blur4;" instead of what you do now. And to be extra sure, always set the alpha to something.



#5 harshman_chris   Members   -  Reputation: 184

Like
0Likes
Like

Posted 11 April 2013 - 02:36 PM

Okay, since you can't actually read from an FBO but only use an FBO to render to a texture and then read that texture, here's the question: do you set up the active textures, bindings and uniforms correctly? How this should go is like this:

 

set active texture to N

bind your texture[N] to GL_TEXTURE_2D

glUniform1i(uniform N location, N)

 

N loops through 1...4, obviously. What this sounds like is you forgetting to call the gluniform1i - all the uniforms samplers are texture unit 0 unless you specify otherwise.

 

And please, do "uniform sampler2D Blur1, Blur2, Blur3, Blur4;" instead of what you do now. And to be extra sure, always set the alpha to something.

 

None of those are the issue, what I need is how to blend the 4 frames together properly so it appears blurred, rather than just making the scene lighter or darker.



#6 powly k   Members   -  Reputation: 650

Like
0Likes
Like

Posted 11 April 2013 - 05:01 PM

That very much seems to be the issue, if averaging 4 images that should be different doesn't produce a blurred result. Can you actually somehow verify that the 4 samplers have different textures attached?



#7 harshman_chris   Members   -  Reputation: 184

Like
0Likes
Like

Posted 11 April 2013 - 08:09 PM

That very much seems to be the issue, if averaging 4 images that should be different doesn't produce a blurred result. Can you actually somehow verify that the 4 samplers have different textures attached?

 

Yes I use various tools to check this, I believe the issue is because I am using 4 frames that are too close together so the effect is not noticeable.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS