Idea for motion blur

Hi, I have an idea for motion blur. The idea is that it takes a few samples of frames (about 6) and fades them out one after the other on top of the current frame (each with a low alpha value which decreases to 0 after 6 frames). I have no idea how to do this, so does anyone know how this can be achieved?

Thanks

Increase the fps of animation while keeping the animation timing at correct speed. Then in a video editor speed up the footage. speed up 6X should give you 6 layered frames in 1 frame. video editors vary though, some may just remove the frames and not layer then.

So if I wanted 4 layered frames I would set the fps to 120 frames per sec. then you need to slow down the timing of the animation 4X so the animation will appear in slow motion at 120 fps, or a 1/4th of a sec of animation per 1 sec in real time or per 120 fps. then speed up the footage in a video editor and set the frame rate to 30 fps. speed up 5X is using 24 fps. using 24 fps will give 5 layers.

This is the best method I can think of using open source software.

This is more or less what the full sample motion blur in blender does already, except the blurring is around the current frame, based on the shutter speed, like real film, rather than the fake cartoony ‘trailing’ kind of motion blur. If that’s what you’re after you’d have to do that like you’ve described probably.

That’s what I want, and it’s quite similar to the one in blender, but it doesn’t work with ATi/AMD GPUs

:o Oh sorry - didn’t realise you were talking game engine. Just checking recent posts

Can’t you use the built in 2D filter? Play with the passes for better results. If not, search the resources forum :slight_smile:

Been doing this for 3 months. The built-in one doesn’t work with AMD/ATi graphics since the OpenGL is too new a version (or something like that). There aren’t any motion blurs like the built-in one in the resource section.

Hmm. That’s unlikley, considering we use OpenGL2.0.

However, the problem is usually that ATI requires floats, whilst Nvidia can use integers. I would recommend finding a motion blur shader, and making sure every variable is a float (1.000) not (1)

I made a motion blur using the bge.texture (VideoTexture then) module, which worked on my ATI card. It worked pretty well, but it was pretty complex to set up. Maybe I could do it again, simpler this time… It should still be in the resource section, if you’re interested. However, agoose’s probably correct - just find a motion blur shader and change it to use floats.

Hm… Maybe I can get the original 2D filter and change all the variables? Where can I find it?

Not sure. I have the source, but the motion blur filter’s not listed in the source area, so maybe it uses a different method…? Someone like Moguri or Kupoman might know - they work with the source a lot more than I do.

trunk/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h :wink:

That’s for a normal blur, isn’t it? Not a motion blur…? In any case, here’s that file:


/*
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 * All rights reserved.
 *
 * The Original Code is: all of this file.
 *
 * Contributor(s): none yet.
 *
 * ***** END GPL LICENSE BLOCK *****
 */

/** \file RAS_Blur2DFilter.h
 *  \ingroup bgerastoglfilters
 */

#ifndef __RAS_BLUR2DFILTER
#define __RAS_BLUR2DFILTER

const char * BlurFragmentShader=STRINGIFY(
uniform sampler2D bgl_RenderedTexture;
uniform vec2 bgl_TextureCoordinateOffset[9];

void main(void)
{
    vec4 sample[9];

    for (int i = 0; i < 9; i++)
    {
        sample[i] = texture2D(bgl_RenderedTexture,
                              gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
    }

    gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] +
                    (2.0*sample[3]) + sample[4] + (2.0*sample[5]) +
                    sample[6] + (2.0*sample[7]) + sample[8]) / 13.0;
}
);
#endif



EDIT: Everything from “STRINGIFY(” down to the ending “);” is the filter.

Hmm. seems like that was the BLUR filter this one is the correct code.It looks simple and work by storing the prev. frame to the accumulation buffer?

/trunk/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp


void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
{
int state = rasterizer->GetMotionBlurState();
float motionblurvalue;
if(state)
{
motionblurvalue = rasterizer->GetMotionBlurValue();
if(state==1)
{
//bugfix:load color buffer into accum buffer for the first time(state=1)
glAccum(GL_LOAD, 1.0);
rasterizer->SetMotionBlurState(2);
}
else if(motionblurvalue>=0.0 && motionblurvalue<=1.0)
{
glAccum(GL_MULT, motionblurvalue);
glAccum(GL_ACCUM, 1-motionblurvalue);
glAccum(GL_RETURN, 1.0);
glFlush();
}

}}

The same code can be found on:

/trunk/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp