Godot: Motion blur shader

Created on 2 Feb 2018  路  11Comments  路  Source: godotengine/godot

I noticed that despite offering support for a variety of common post-processing shaders (bloom, depth-of-field, etc) Godot 3.0 doesn't have builtin support for motion blur yet. I believe this to be an important effect for photorealism, and would like to suggest it as a camera or environment option if possible.

For clarification: My suggestion doesn't refer to the conventional method of simulating motion blur, which relies on fading previous frames across the screen (also known as "ghosting"). The modern approach includes directional blurring of textures on surfaces based on the velocity of the camera, which offers a much more immersive and realistic effect. DirectX based engines have had this ability for over a decade, with the Need For Speed series (starting with NFS - Carbon, released in 2006) offering a good example... as far as open-source and OpenGL are concerned, this shader has been implemented into the Ogre based racing sim Stuntrally which may offer an useful example.

I briefly discussed this on IRC. I was told that a reason for the setback in supporting motion blur for Godot 3.0 is the OpenGL version, which is older than the one adding the necessary GLSL functions. Perhaps this can be implemented as more renderer backends are made available in the project settings, thus offered as an option to projects using OpenGL >= 3.2?

archived discussion feature proposal rendering

Most helpful comment

Here's my attempt at a motion blur shader. Note that it only works when the camera moves. For per-object motion blur I think we need some kind of deferred rendering, so we can store linear velocity per pixel.

All 11 comments

Godot have Vulkan support in roadmap, maybe after its implementation, all modern things including Motion blur will be implemented.

Motion blur should definitely be possible in OpenGL too, at least version >= 3.2 to my understanding. Just saying it doesn't need to be a Vulkan specific feature, which I'd find a bit weird personally... if it otherwise has to come after implementing Vulkan for compatibility or priority reasons, that makes sense.

Just to clarify, Godot uses the OpenGL ES 3.0 standard, which is equivalent to OpenGL 3.3 on desktop platforms. Vulkan is in mind but don't expect it to come anytime soon.

Does OpenGL ES 3.0 contain the GLSL functions needed for spatial motion blur? It sounds like it should, since like I said DirectX games got it working over a decade ago.

I think the only function missing to implement a modern motion blur (https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch27.html) is the ability to get previous inverted projection matrix in addition to the current one.

Here's my attempt at a motion blur shader. Note that it only works when the camera moves. For per-object motion blur I think we need some kind of deferred rendering, so we can store linear velocity per pixel.

@Zireael07 Since OpenGL 3.1/GLSL 140 (I think?), matrices must be explicitly passed to the shader (OpenGL matrices are deprecated). Either way, GLSL has an inverse function to invert a matrix since GLSL 140.

@Bauxitedev's motion blur shader is fairly good but it suffers from the same limitation as all other screen-reading shaders - they happen before alpha pass.

Somehow, though, built-in postprocess like DOF Near and Far Blur also work on alpha pass. Can we please get some velocity parameter to simulate motion blur using those?

Found a workaround, but it would have to be used on all alpha things you want to be seen when motion blur is on: https://www.reddit.com/r/godot/comments/bxfyws/heres_a_dithered_opacity_aka_hashed_transparency/ so it's not that tenable for larger projects.

I think @reduz plans to add a built-in per-object motion blur effect using motion vectors in 4.0 (or maybe 4.1).

Note that this feature is planned in some way for Godot 4.0 (no guarantees, though).


Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!

Was this page helpful?
0 / 5 - 0 ratings