Save current frame to renderTarget

I want to make freeze frame effect. Idea is to mix current frame with previous frame which I save to renderTarget.
Trying to use CopyFrameBuffer.xml renderPath, but it is always black.

<renderpath>
    <rendertarget  name="freezeFrame" sizedivisor="1 1" format="rgba" filter="true" />
    <command type="quad" vs="MyCopyFramebuffer" ps="MyCopyFramebuffer" output="freezeFrame" tag="freezeFrame">
        <texture unit="diffuse" name="viewport" />
        <texture unit="normal" name="freezeFrame"/>
    </command>
    <command type="quad" vs="CopyFramebuffer" ps="CopyFramebuffer" output="viewport">
        <texture unit="diffuse" name="freezeFrame" />
    </command>
</renderpath>    
1 Like

AutoExposure post process does pretty much what you need, check it out.
You need persistent RT, otherwise it’s not preserved between frames.

1 Like

Ok, now I set renderTarget to persistent and get the result, kind of. Now everything is gray). MyCopyFrameBuffer just use mix with ratio 0.5.

<renderpath>
    <rendertarget  name="freezeFrame" tag="FreezeFrame"  sizedivisor="1 1" format="rgba" filter="false" persistent="true"/>
    <rendertarget  name="prevFreezeFrame" tag="FreezeFrame"  sizedivisor="1 1" format="rgba" filter="false"/>

    <command type="quad" tag="FreezeFrame" vs="CopyFramebuffer" ps="CopyFramebuffer" output="prevFreezeFrame">
        <texture unit="diffuse" name="freezeFrame" />
    </command>

    <command type="quad" tag="FreezeFrame" vs="MyCopyFramebuffer" ps="MyCopyFramebuffer" output="viewport">
        <texture unit="diffuse" name="viewport" />
        <texture unit="diffuse" name="prevFreezeFrame" />
    </command>

    <command type="quad" tag="FreezeFrame" vs="CopyFramebuffer" ps="CopyFramebuffer" output="freezeFrame">
        <texture unit="diffuse" name="viewport" />
    </command>

</renderpath>    

This looks suspicious to me

You have two things that are both claiming to be the diffuse texture unit.

1 Like

Changed to normal.
You saved me)

1 Like