Frictional Games Forum (read-only)
Motion Blur - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Penumbra: Overture, Black Plague & Requiem (https://www.frictionalgames.com/forum/forum-5.html)
+--- Forum: General Discussion (https://www.frictionalgames.com/forum/forum-20.html)
+--- Thread: Motion Blur (/thread-684.html)

Pages: 1 2


Motion Blur - jonathan - 03-30-2007

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


RE: Motion Blur - Thomas - 03-30-2007

Cool, I will check this out next week and perhaps release as a lil patch later on.


RE: Motion Blur - Sepai - 03-30-2007

looks like nothing to my untrained eye but i give it a go and see if i like it


RE: Motion Blur - Thomas - 04-03-2007

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.


RE: Motion Blur - Dementia - 04-04-2007

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.


RE: Motion Blur - Thomas - 04-04-2007

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.


RE: Motion Blur - Dark - 04-04-2007

cant you make it an optional tweak or so? (like in a launcher)


RE: Motion Blur - Dementia - 04-05-2007

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!


RE: Motion Blur - jonathan - 04-05-2007

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


RE: Motion Blur - dzjepp - 04-05-2007

You mention demo, but does this method work for episode 1 as well?