Motion interpolation does the opposite of what I want

  • YouYouTheBoxx
  • Topic Author
More
1 year 10 months ago - 1 year 10 months ago #1 by YouYouTheBoxx Motion interpolation does the opposite of what I want was created by YouYouTheBoxx
Hello,
Recently I've been starting to make a motion interpolation shader by delaying the frames by 1. I used the technique about getting previous frames from here: reshade.me/forum/shader-discussion/69-access-to-previous-frames .
The thing is that after a lot of test I've successfully done the opposite of having interpolated frames between 2 'real' frames. If you enable my shader, it currently remove somes frames.

Can somebody help me sort this out, thanks.
Here is my shader code:
#include "ReShade.fxh"
#include "ReShadeUI.fxh"
#include "DrawText.fxh"

texture2D firstFrameTex : COLOR;
texture2D secondFrameTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; };
texture2D thirdFrameTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; };

sampler2D firstFrame { Texture = firstFrameTex; };
sampler2D secondFrame { Texture = secondFrameTex; };
sampler2D thirdFrame { Texture = thirdFrameTex; };

uniform float2 pingpong < source = "pingpong"; min = 0; max = 3; step = 1; smoothing = 0.0; >;

uniform float framecount < source = "framecount"; >;

void FullscreenTriangleVS(uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD0)
{
    texcoord.x = (id == 2) ? 2.0 : 0.0;
    texcoord.y = (id == 1) ? 2.0 : 0.0;
    position = float4(texcoord * float2(2, -2) + float2(-1, 1), 0, 1);
}

float4 DoFrameInterpolation(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
    float4 firstFrameColor = tex2D(firstFrame, texcoord);
    float4 secondFrameColor = tex2D(secondFrame, texcoord);
    float4 thirdFrameColor = tex2D(thirdFrame, texcoord);
    
    float4 currColor = float4(0f,0f,0f,1f);
    
    float fraction = 0.3;
    
    float res = 0;
    
    DrawText_Digit(float2(500.0, 500.0),32,1,texcoord,0,framecount,res);

    if ((framecount % 3) < 0.01f)
    {
        currColor = secondFrameColor;
    }
    else if ((framecount % 2) < 0.01f)
    {
        currColor = (thirdFrameColor - secondFrameColor) * fraction + secondFrameColor;
    }
    else
    {
        currColor = thirdFrameColor;
    }
    
    return currColor + res;
}

float4 PS_CopySecondFrame(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
    return tex2D(firstFrame, texcoord);
}

float4 PS_CopyThirdFrame(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
    return tex2D(secondFrame, texcoord);
}

technique MotionInterpolation <
    ui_label = "Motion interpolation";
    ui_tooltip =
        "Adds interpolated frames between 2 real frames by delaying everything by 1 real frame"
        "\n\nUnder the Creative Commons CC BY-SA 3.0 license"
        "\n(c) 2022 YouYouTheBoxx";
>
{
    pass ThirdFrameCopy
    {
        VertexShader = FullscreenTriangleVS;
        PixelShader = PS_CopyThirdFrame;
        RenderTarget = thirdFrameTex;
    }
    
    pass SecondFrameCopy
    {
        VertexShader = FullscreenTriangleVS;
        PixelShader = PS_CopySecondFrame;
        RenderTarget = secondFrameTex;
    }

    pass FrameInterpolate
    {    
        VertexShader = FullscreenTriangleVS;
        PixelShader = DoFrameInterpolation;
    }
}
Last edit: 1 year 10 months ago by YouYouTheBoxx.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.