Archive 17/01/2023.

Motion Blur like Doom4

1vanK

github.com/1vanK/Urho3DMotionBlur

Use START_DEMO.bat for launch

Bananaft

Looks really neat and smooth.
So it uses camera transform and only affected by camera motion? Or it uses full velocity vectors pass, and can blur many separated objects?

1vanK

[quote=“Bananaft”]Looks really neat and smooth.
So it uses camera transform and only affected by camera motion? Or it uses full velocity vectors pass, and can blur many separated objects?[/quote]

only camera motion

rasteron

nice.

sabotage3d

Its pretty cool. I am getting bugs on my OSX. The motion blur is jittering and there is motion blur only in some areas of the screen.

1vanK

try to turn on vsync (options -v)

1vanK

Also whether you are using the latest version of the engine?

Egorbo

Wow! looks nice, does it work on GLES iOS/Android?

1vanK

I have not tested

Cpl.Bator

Very nice ! ( with -v that work fine here ) , great job ! what the next ? dof ? :smiley:

1vanK

This shader is not finished yet (it uses an additional forward light pass for weapon and I can not solve a couple of issues). I have reworked version with mask for weapon, but additional texture affects performance

dof already implemented by monkeyfirst github.com/MonkeyFirst/urho3d-post-process-dof (but as far as I remember, there is need to improve)

1vanK

Please test updated version. Whether there is a problems WITHOUT vsync? New version render scene to texture and blurs it there, but not just in the viewport

EDIT: for launch still use START_DEMO.bat

Cpl.Bator

work fine without vsync.

1vanK

ok, but now it is impossible to turn off effect by tag, need use another renderpath without motion blur …

EDIT: although I have an idea

sabotage3d

It works properly with vsync it looks pretty cool.

1vanK

Have you problems with other shaders (Blur, Bloom) when VSync is disabled?

EDIT: a have a hypothesis that engine on some frames start showing viewport before bluring when vsync is disabled and fps is high
EDIT2: someone can test problem by using WithoutMask.bat in repo (u can change window size to 200x700 for increasing fps)

Modanung

For some reason I had to use -ap flag for the Urho3DPlayer to locate the CoreData folder and then merge the Final folder into that one and the Data folder for it to find all the resources. Then I saw a baked room (Andrew Price’s right?) and a textured pistol, but no blur.
I’m on Xubuntu Linux 64-bit using the proprietary Nvidia drivers. Which - apart from the occasional heavy frame drops - tends to outperform the open Xorg drivers. Switching back to Xorg is a pain though, otherwise I’d be happy to test with those.
I’ve tried the -v option; no help.

1vanK

[quote=“Modanung”]For some reason I had to use -ap flag for the Urho3DPlayer to locate the CoreData folder and then merge the Final folder into that one and the Data folder for it to find all the resources. Then I saw a baked room (Andrew Price’s right?) and a textured pistol, but no blur.
I’m on Xubuntu Linux 64-bit using the proprietary Nvidia drivers. Which - apart from the occasional heavy frame drops - tends to outperform the open Xorg drivers. Switching back to Xorg is a pain though, otherwise I’d be happy to test with those.
I’ve tried the -v option; no help.[/quote]

Any warnings or errors in log?

Modanung

None

1vanK

I have no ideas. Try output in shader intermediate steps.

Weapon maskt:

[code]void PS()
{
float weaponmask = texture2DProj(sDiffMap, vScreenPos).a;

gl_FragColor = vec4(weaponmask);

}
[/code]

Depth:

[code]void PS()
{
float depth = ReconstructDepth(texture2DProj(sDepthBuffer, vScreenPos).r);

gl_FragColor = vec4(depth * 20);

}
[/code]

Modanung

I am getting identical result with those pixel shaders.

Also it turns out the path argument required to be enclosed in quotation marks to get all three folders across.

WithMask: Same as Final
WithoutMask: A screen filling flickering in tones of the room with the occasional contour of a window. The gun is rendered fine.
ViewportAlpha: Like Final, but with a pitch black gun.

1vanK

Try

[code]
void PS()
{
float weaponmask = texture2DProj(sDiffMap, vScreenPos).a;

//gl_FragColor = vec4(mask);
//return;

if (weaponmask == 0)
{
    gl_FragColor = texture2DProj(sDiffMap, vScreenPos).rgba;
    return;
}

// HWDEPTH
float depth = ReconstructDepth(texture2DProj(sDepthBuffer, vScreenPos).r);



vec3 worldPos = vFarRay * depth / vScreenPos.w;
worldPos += cCameraPosPS;

vec4 oldClipPos = vec4(worldPos, 1.0) * cOldViewProj;
oldClipPos /= oldClipPos.w;

vec4 oldScreenPos = vec4(oldClipPos.x * vGBufferOffsets.z + vGBufferOffsets.x * oldClipPos.w,
                    oldClipPos.y * vGBufferOffsets.w + vGBufferOffsets.y * oldClipPos.w,
                    0.0, oldClipPos.w);

vec4 offset = (vScreenPos - oldScreenPos);
offset = offset / (cTimeStep * 20.0);

gl_FragColor = offset;

}[/code]

It should show different colors when you move a the mouse

Also try to remove all comments from shader. May be it not works with UTF8 comments

1vanK

Also are you using the latest version of the engine?

Modanung

Yep

1vanK

Repo moved to github.com/1vanK/Urho3DMotionBlur

sabotage3d

Is it possible to use the same technique for a depth of field effect?

1vanK

I think there is nothing in common. Even pixel blurring algorithm is other. Easier write a DOF shader from scratch, than try to take something useful from this