We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › easy smooth motionblur
Page Index Toggle Pages: 1
easy smooth motionblur (Read 2947 times)
easy smooth motionblur
Apr 26th, 2007, 6:37pm
 
If your graphic card is not too old, there is a easy way for smooth motionblur with only one renderpass using the accumulation buffer. It works with the standard processing graphics.

...

// OPENGL INIT / ACCUMULATION BUFFER CLEAR

gl = (( PGraphicsOpenGL )g).gl;      
gl.glClearAccum(0.0, 0.0, 0.0, 1.0);
gl.glClear(GL.GL_ACCUM_BUFFER_BIT);

...

// DRAWING STUFF : PURE OPENGL OR NORMAL PROCESSING

...

// AFTER FINISHING DRAWING LOOP:


// LIGHT BLUR : n = 0.90
// VERY STRONG BLUR : n = 0.99

gl.glAccum( GL.GL_MULT, n );

gl.glAccum( GL.GL_ACCUM, 1-n );
gl.glAccum( GL.GL_RETURN, 1.0 );



Re: easy smooth motionblur
Reply #1 - Apr 26th, 2007, 7:08pm
 
Unfortunately, on most video cards that I've tried, the accumulation buffer is really really slow.

For example the game I'm working on, it halves the framerate.
Re: easy smooth motionblur
Reply #2 - Apr 27th, 2007, 1:36pm
 
With a Geforce 7600GT it is no problem when i blur the complete scene. By blurring only parts it slows down.

Thank you for your GLSL-class.
Re: easy smooth motionblur
Reply #3 - Apr 29th, 2007, 1:30pm
 
Could someone explain how this works in processing. I ever get this error :
Code:
GL_ERROR at top endDraw(): 0502  GL_INVALID_OPERATION 


this is my small sketch:

Quote:


import processing.opengl.*;
import javax.media.opengl.*;
import surface.*;

Surface s;
GL gl;

void setup(){
 size (500,500,OPENGL);
 gl = (( PGraphicsOpenGL )g).gl;  
 s=new SuperShapes(g,40,40);
 noStroke();
 gl.glClearAccum(0.0, 0.0, 0.0, 1.0);  
 gl.glClear(GL.GL_ACCUM_BUFFER_BIT);
}

void draw(){
 background(255);
 lights();
 translate (width/2,height/2);
 rotateX(radians(frameCount));
 s.setScale(mouseX/2f);
 s.draw();

 float n=0.99;
 gl.glAccum( GL.GL_MULT, n );
 gl.glAccum( GL.GL_ACCUM, 1-n );
 gl.glAccum( GL.GL_RETURN, 1.0 );
}


Re: easy smooth motionblur
Reply #4 - Apr 29th, 2007, 5:49pm
 
Your example worked fine with n = 0.92. I think your graphic card does not support the accumulation buffer.
Re: easy smooth motionblur
Reply #5 - Apr 29th, 2007, 7:38pm
 
Mhmm, I'm one a PPC Mac, so I'll test it on my PC.
Re: easy smooth motionblur
Reply #6 - May 2nd, 2007, 8:57am
 
eskimoblood :

Tried your code on Intel Mac but it failed to start with this error :

Quote:
/tmp/build65179.tmp/Temporary_7587_148.java:11:9:11:19: Semantic Error: Type "SuperShapes" was not found.

/tmp/build65179.tmp/Temporary_7587_148.java:22:3:22:23: Semantic Error: No accessible method with signature "setScale(float)" was found in type "surface.Surface".


Running on P124 and Java 1.5 (OS X 10.4.8)
Re: easy smooth motionblur
Reply #7 - May 2nd, 2007, 7:53pm
 
jaylfk wrote on May 2nd, 2007, 8:57am:
Tried your code on Intel Mac but it failed to start with this error ...



Be sure you have the latest version of the latest version of the surfaceLib.
Re: easy smooth motionblur
Reply #8 - May 3rd, 2007, 1:34am
 
I've updated the library and now i've got another error, the sketch is starting though :

Quote:
GL_ERROR at top endDraw(): 0502  GL_INVALID_OPERATION
Re: easy smooth motionblur
Reply #9 - May 3rd, 2007, 9:43pm
 
Then everything works well, and you're on a machine that doesn't support the accumulation buffer. Like me.
Re: easy smooth motionblur
Reply #10 - May 29th, 2007, 2:22am
 
This is neither "easy" nor "smooth" Cheesy but...

http://www.davebollinger.com/works/feedback/

...consider it a hack technique you can use to achieve similar effects in the absense of a true accumulation buffer.

However, how well it works depends a lot on your card/driver and its access to the pixel array.  Some cheapo cards do it really fast, and some otherwise super-fancy cards are complete dogs.  Who knows?  Sad

The basic technique for motion blur is to use get() at the end of draw() to capture the entire frame, then at beginning of next draw() use it as a partially transparent texture on a full-screen quad.
Page Index Toggle Pages: 1