Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motion blur shader #16301

Closed
MirceaKitsune opened this issue Feb 2, 2018 · 11 comments
Closed

Motion blur shader #16301

MirceaKitsune opened this issue Feb 2, 2018 · 11 comments

Comments

@MirceaKitsune
Copy link

MirceaKitsune commented Feb 2, 2018

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?

@Chaosus
Copy link
Member

Chaosus commented Feb 3, 2018

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

@MirceaKitsune
Copy link
Author

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.

@vnen
Copy link
Member

vnen commented Feb 3, 2018

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.

@MirceaKitsune
Copy link
Author

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.

@Zireael07
Copy link
Contributor

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.

@Bauxitedev
Copy link

Bauxitedev commented Apr 29, 2018

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.

@kaadmy
Copy link
Contributor

kaadmy commented Feb 25, 2019

@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.

@Zireael07
Copy link
Contributor

@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?

@Zireael07
Copy link
Contributor

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.

@Calinou
Copy link
Member

Calinou commented Apr 28, 2020

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

@Calinou
Copy link
Member

Calinou commented May 27, 2020

Superseded by godotengine/godot-proposals#2933.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants