Frictional Games Forum

Full Version: Motion Blur
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I love the motion blur effect in Penumbra: Overture, but I felt like it lowered the FPS more than it should, so I got to poking around in the resources in the demo and found the shader in redist\core\programs\PostEffect_Motion_fp.cg, and after a little tweaking I came up with this:

Code:
void main(float4 inPos        : WPOS, //in projection space
        Â Â float4 inVtxPos        :TEX0,
        Â Â float4 inPrevVtxPos    :TEX1,
        Â Â Â Â Â Â Â Â Â Â Â Â Â Â 
        Â Â out float4 oColor : COLOR,
          
        Â Â uniform samplerRECT screenTex        : TEXUNIT0,
        Â Â uniform float2 halfScreenSize)
{
    float2 wpos = inPos.xy;
    float2 p1 = inVtxPos.xy / inVtxPos.w;
    float2 p2 = inPrevVtxPos.xy / inPrevVtxPos.w;

    float2 velocity = (p2 - p1) * halfScreenSize;

    //Sample into scene texture along motion vector
    const float samples = min( max( 1, ceil( max( abs( velocity.x ), abs( velocity.y ) ) / 2 ) ), 16 );
    const fixed w = 1.0 / samples;  // weight
    const float2 s = velocity / samples; // step
    fixed4 a = 0;

    for(float i=0; i<samples; i+=1)
    {
        a += texRECT(screenTex, wpos) * w;
        wpos += s;
    }

    oColor = a;
}

Just open PostEffect_Motion_fp.cg in Notepad and replace its contents with the above (back up your original first, just in case).I didn't do any real testing, but the framerate feels smoother with this shader anyway, and the end result is exactly the same. Basically I just removed a division and multiplication from the for loop, and made the number of blur samples dynamic based on the amount of motion at the current fragment.

I also like a little stronger blur effect, so I turned up the MotionBlurAmount value in the settings.cfg file some too.

I hope the devs don't mind me posting this - I just found it smoothed out my experience, and thought other P:O fans might like it too.

I'm looking forward to buying and playing Penumbra: Overture tomorrow! Smile
Cool, I will check this out next week and perhaps release as a lil patch later on.
looks like nothing to my untrained eye but i give it a go and see if i like it
Just tried it and it looks very nice and also much faster.

Okay if we include it in the upcoming patch? Will add your name as credit in that case, so please state what you want to be credited as.
I tried it too, the framerate was faster but it just turned off the Motion Blur for me. I reversed to the original, tried it again and double-checked to see if it was me doing something wrong. The only thing it does is turning off the motion blur, for me at least.

I also love the effect myself, it gives a great feeling to the game.


Could it be due to hardware differences? I'd love to gain a few frames and still be able to use motion blur, looks just awesome.
A yeah,

The problem with the new shader is that it has a dynamic loop. This is onöy supported on the very newest cards (with Shader model 3.0) so that is problably the problem.

I will probably change back to static and keep the other optimizations.
cant you make it an optional tweak or so? (like in a launcher)
Thomas Wrote:A yeah,

The problem with the new shader is that it has a dynamic loop. This is onöy supported on the very newest cards (with Shader model 3.0) so that is problably the problem.

I will probably change back to static and keep the other optimizations.


Yep that's gotta be it. ^^ I have an old Radeon with Shader 2.0 (9800xt) .

I can still keep the original motion blur and a decent frame rate at a lower resolution.

Cheers!
Thomas Wrote:Just tried it and it looks very nice and also much faster.

Okay if we include it in the upcoming patch? Will add your name as credit in that case, so please state what you want to be credited as.

That'd be awesome! Just put me in as "Jonathan Marston".

Also, I realized the dynamic loop was probably a SM3-only thing. Like you said though, you can keep the number of samples static and the other optimizations will still help out.

Jonathan
You mention demo, but does this method work for episode 1 as well?
Pages: 1 2