The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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


Messages In This Thread
Motion Blur - by jonathan - 03-30-2007, 12:20 AM



Users browsing this thread: 1 Guest(s)