Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Motion Blur
jonathan Offline
Junior Member

Posts: 4
Threads: 1
Joined: Mar 2007
Reputation: 0
#1
Motion Blur

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:

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
03-30-2007, 12:20 AM
Find Reply
Thomas Offline
Frictional Games

Posts: 2,634
Threads: 184
Joined: Apr 2006
Reputation: 68
#2
RE: Motion Blur

Cool, I will check this out next week and perhaps release as a lil patch later on.
03-30-2007, 12:30 AM
Find Reply
Sepai Offline
Member

Posts: 179
Threads: 10
Joined: Dec 2006
Reputation: 0
#3
RE: Motion Blur

looks like nothing to my untrained eye but i give it a go and see if i like it
03-30-2007, 07:14 AM
Find Reply
Thomas Offline
Frictional Games

Posts: 2,634
Threads: 184
Joined: Apr 2006
Reputation: 68
#4
RE: Motion Blur

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.
04-03-2007, 11:35 AM
Find Reply
Dementia Offline
Junior Member

Posts: 2
Threads: 0
Joined: Apr 2007
Reputation: 0
#5
RE: Motion Blur

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.
04-04-2007, 03:56 AM
Find Reply
Thomas Offline
Frictional Games

Posts: 2,634
Threads: 184
Joined: Apr 2006
Reputation: 68
#6
RE: Motion Blur

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.
04-04-2007, 06:18 AM
Find Reply
Dark Offline
Senior Member

Posts: 701
Threads: 20
Joined: Jul 2006
Reputation: 0
#7
RE: Motion Blur

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

[Image: elfenliednx4.jpg]
04-04-2007, 09:07 AM
Find Reply
Dementia Offline
Junior Member

Posts: 2
Threads: 0
Joined: Apr 2007
Reputation: 0
#8
RE: Motion Blur

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!
04-05-2007, 01:54 AM
Find Reply
jonathan Offline
Junior Member

Posts: 4
Threads: 1
Joined: Mar 2007
Reputation: 0
#9
RE: Motion Blur

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
04-05-2007, 02:46 AM
Find Reply
dzjepp Offline
Junior Member

Posts: 10
Threads: 2
Joined: Apr 2007
Reputation: 0
#10
RE: Motion Blur

You mention demo, but does this method work for episode 1 as well?
04-05-2007, 04:58 AM
Find Reply




Users browsing this thread: 1 Guest(s)