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

Request add Soft shadow and motion blur function #4710

Closed
chuiliuyiyi opened this issue May 10, 2022 · 1 comment · Fixed by #9924
Closed

Request add Soft shadow and motion blur function #4710

chuiliuyiyi opened this issue May 10, 2022 · 1 comment · Fixed by #9924
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible

Comments

@chuiliuyiyi
Copy link

chuiliuyiyi commented May 10, 2022

Request add Soft shadow and motion blur function。

@chuiliuyiyi chuiliuyiyi added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels May 10, 2022
@chuiliuyiyi chuiliuyiyi changed the title Soft shadow and motion blur function Request add Soft shadow and motion blur function May 10, 2022
@jakobhellermann
Copy link
Contributor

There's more information about soft shadows in #3628

@jakobhellermann jakobhellermann added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels May 10, 2022
github-merge-queue bot pushed a commit that referenced this issue Apr 25, 2024
https://github.com/bevyengine/bevy/assets/2632925/e046205e-3317-47c3-9959-fc94c529f7e0

# Objective

- Adds per-object motion blur to the core 3d pipeline. This is a common
effect used in games and other simulations.
- Partially resolves #4710

## Solution

- This is a post-process effect that uses the depth and motion vector
buffers to estimate per-object motion blur. The implementation is
combined from knowledge from multiple papers and articles. The approach
itself, and the shader are quite simple. Most of the effort was in
wiring up the bevy rendering plumbing, and properly specializing for HDR
and MSAA.
- To work with MSAA, the MULTISAMPLED_SHADING wgpu capability is
required. I've extracted this code from #9000. This is because the
prepass buffers are multisampled, and require accessing with
`textureLoad` as opposed to the widely compatible `textureSample`.
- Added an example to demonstrate the effect of motion blur parameters.

## Future Improvements

- While this approach does have limitations, it's one of the most
commonly used, and is much better than camera motion blur, which does
not consider object velocity. For example, this implementation allows a
dolly to track an object, and that object will remain unblurred while
the background is blurred. The biggest issue with this implementation is
that blur is constrained to the boundaries of objects which results in
hard edges. There are solutions to this by either dilating the object or
the motion vector buffer, or by taking a different approach such as
https://casual-effects.com/research/McGuire2012Blur/index.html
- I'm using a noise PRNG function to jitter samples. This could be
replaced with a blue noise texture lookup or similar, however after
playing with the parameters, it gives quite nice results with 4 samples,
and is significantly better than the artifacts generated when not
jittering.

---

## Changelog

- Added: per-object motion blur. This can be enabled and configured by
adding the `MotionBlurBundle` to a camera entity.

---------

Co-authored-by: Torstein Grindvik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants