Code Monkey home page Code Monkey logo

godot-motion-blur's Introduction

Godot Motion Blur

This is a camera motion blur shader for Godot. It uses the linear and angular velocity of the camera to calculate a velocity vector per pixel, and then blurs that pixel accordingly. The velocity is automatically calculated from the way the camera moves and rotates, so it works for pretty any kind of camera animation you can think of. It can produce linear blur, angular blur, zooming blur, and any combination of them, depending on the camera's movement.

It looks like this:

Motion blur

Here's a video of it in action.

How to use it

It's really easy to use in your project! Simply:

  1. Download the repository as zip and extract it.
  2. Copy the motion_blur folder into the root folder of your project.
  3. In the scene of your game, select your camera node, and then click the chain icon above the scene tree to instance a scene, then select the motion_blur.tscn scene file.
  4. That's all!

Limitations/Known Issues

  • Only works for camera movement. When something else in the world moves it won't be blurred.
  • Additionally, when the camera moves, and another object moves at the same speed of the camera, that object will be wrongly blurred. So e.g. in a racing game you'll notice the car will be blurred in the same way as the environment. You could work around this by enabling the Transparent flag in the material of the car, and setting the Depth Draw Mode to Always (since transparent objects are not blurred - see below).
  • Transparent objects will not be blurred (since this effect uses the depth buffer, but transparent objects aren't drawn to he depth buffer, so they aren't detected)

License

MIT

godot-motion-blur's People

Contributors

bauxitedev avatar martinsh avatar rcorre avatar webnetweaver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

godot-motion-blur's Issues

Alpha support

Nice plugin!
Currently alpha transparency doesn't work if the .tscn file is attached to the camera --> object isn't rendered
Not sure how to change albedo_color to .rgba in the shader.

Quat Wrap/Jump Issue and Fix

I just noticed an issue where the cam_rot_diff value jumps when camera's euler angles flip back around for a single frame. This creates a large blur in the opposite direction for just that frame. I'm not great with math, but luckily I do know a fix from working with quats in other areas.

You simply need to compare the 2 quats you are subtracting with a dot product, and negate if the result is negative:

	var cam_rot_diff = cam_rot - cam_rot_prev
	if cam_rot.dot(cam_rot_prev) < 0.0: # Wraparound Fix
		cam_rot_diff = -cam_rot_diff;

Edit: The idea behind this is that sometimes the difference between 2 quats can be "the long way around" instead of the short. Think 350 degrees instead of -10. Negating a quat fixes this.

I hope this helps. :)

Issue 3.1

Sorry that this is such a bad issue description.

But it works really poorly on 3.1.
you should check yourself. I i have time i will add a screenshot

Extremely slow

I am not sure whether this is an issue, but I found that my FPS dropped to around 10 with this. Is there any way to make it faster?

Low FPS blurs too much

If the FPS is low (<40FPS), the blur effect becomes way too strong.

144 FPS:
image

30 FPS:
image

Maybe reduce the intensity depending on the framerate?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.