Commit Graph

47 Commits

Author SHA1 Message Date
Michael Fabian 'Xaymar' Dirks 43136b00c4 filter-blur: Precalculate correct filter width for Gaussian
Gaussian blur used to have a hard edge which was caused by the filter width being wider than the actual sampling range, which is what is determined by the size option. In order to fix this, we have to figure out the proper filter width for a sampling range, so that we avoid any and all hard edges.

Additionally removes the old texture method entirely.

Fixes #44
2019-02-01 08:35:58 +01:00
Michael Fabian 'Xaymar' Dirks a56cbf89a9 filter-blur: Refactoring 2019-01-28 01:08:13 +01:00
Michael Fabian 'Xaymar' Dirks c529e45cfd filter-blur: Refactoring, one-time rendering, fix mask logic
Unfortunately load is never called on filters.
2019-01-28 00:00:45 +01:00
Michael Fabian 'Xaymar' Dirks 10c0081f32 project: Refactoring Part 2 2019-01-27 23:33:12 +01:00
Michael Fabian 'Xaymar' Dirks 39b0600aa3 filter-blur: Update in load and create 2019-01-27 23:30:37 +01:00
Michael Fabian 'Xaymar' Dirks 8a64e360c4 filter-blur: Switch to obs-source-tracker
Completely eliminates the need for obs_emum_sources and obs_enum_scenes, thus improving backwards compatibility.
2019-01-27 23:19:09 +01:00
Michael Fabian 'Xaymar' Dirks d56c0d6f25 project: Refactoring Part 1 2019-01-25 17:55:36 +01:00
Cat Stevens b91700e74f filter-blur: delete pointer in destroy() (#42) 2019-01-25 17:40:59 +01:00
Michael Fabian 'Xaymar' Dirks 160ad3b5a9 locale: Replace file filters with file types
The filters are always the same for every language and should not be translated, instead only the file type should be translated. This way bad translations will not affect the options that the user can select.
2019-01-24 20:34:28 +01:00
Michael Fabian 'Xaymar' Dirks 5a54a67946 project: Remove unused parameters and fix additional warnings 2019-01-23 02:26:32 +01:00
Michael Fabian 'Xaymar' Dirks e0e2d9fe80 project: Improve Linux support (#27 and #13)
While Linux was not an original goal of the project, it should still be supported out of the box. Therefore a number of changes are contained in this changeset:

- All C++ .h files were renamed to .hpp.
- All C includes (<....h>) were replaced with C++ includes (<c...>) and missing includes were added.
- std::memset and std::memcpy was replaced with memset and memcpy.
- All anonymous structs were removed where necessary.
- `extern "C"` was removed where it wasn't needed.
- #pragma warning was placed behind an #ifdef _MSC_VER
- The macros for `min`, `max` and `clamp` were removed as they were not used.
- `-fpedantic` was added to the GCC flags for bitmask support.
- `gs::rendertarget_op` is now declared before use.
- std::exception(const char*) was replaced with std::runtime_error(const char*).
- Added aligned_alloc and aligned_free macros for GCC and MSVC support.
- Replaced use of `sprintf_s` with `snprintf`.
- Placed additional guards around windows only code.

Additonally some changes were made that do not affect Linux:
- `NOMINMAX` and `NOINOUT` were removed.

Fixes: #27
Fixes: #13
2019-01-14 22:31:35 +01:00
Michael Fabian 'Xaymar' Dirks 3952c33c60 filter-blur: Add Directional Blur (Motion Blur) and Step Scaling
Directional Blur (also known as Motion Blur in some art software) enables full control over the direction the passes are applied in, which can further be combined with the scaling option. With this very simple blur effects can have a massively bigger influence.

Step Scaling allows for improved control over individual Blur passes and can be combined with Directional Blur to imitate certain effects. It also allows smaller Blur sizes to cover a larger area, although with a drastic loss in final quality. For example, if someone is streaming at 720p and wants to have their dynamic 2160p background blurry to a very high degree, this option would allow that at next to no quality loss in the final stream. The actual values that need to be used vary for each source and encoder however, so they will have to be chosen carefully.
2018-12-23 19:54:57 +01:00
Michael Fabian 'Xaymar' Dirks ad97eeebe7 filter-blur: Fix translucent source rendering and modernize code
Translucent sources previously rendered with wrong alpha, which caused sources to look different than they should. With the new code, this is no longer the case and instead now renders the source correctly.

Additionally the modernized code should reduce any problems with rendering by reducing the amount of duplicated manually written code and instead using classes.
2018-12-23 18:27:24 +01:00
Michael Fabian 'Xaymar' Dirks a6f9451654 filter-blur: Switch to Kernel Array instead of Kernel Texture
This speeds up Gaussian Blur and Linear Gaussian Blur drastically reduces time spent reading textures and instead uses existing registers - maximizing time spent reading the actual image texture.

See Also: #21 Blur Quality
2018-12-23 02:00:30 +01:00
Michael Fabian 'Xaymar' Dirks 92c4b54177 filter-blur: Add Linear Gaussian Blur
Similar to Linear Box Blur, this version of Gaussian Blur reduces the total number of sample by up to n. This results in a total sample count (per pass) of O(n+1) for even radii and O(n+2) for odd radii. The quality sacrificed to do this is higher this time, though careful adjustment of the halfTexelDelta value can bring it much closer to normal Gaussian Blur. The current offset however had no noticable effects on visual quality.

See Also: #21 Blur Quality
2018-12-22 22:54:30 +01:00
Michael Fabian 'Xaymar' Dirks 93df9b50b8 filter-blur: Add Linear Box Blur and combine all effects
Linear Box Blur abuses the fact that with Linear Sampling we can sample up to four adjacent texels at the same time and get a correct result for Box Blur back. Using this the total number of sample for Box Blur is reduced by n, making the total either n+1 (Even Radius) or n (Odd Radius).

Additionally all blur effect files have been merged into a single blur.effect file to reduce the time required to change a single parameter name. New blur effects should be added as a new technique instead of as a new effect file.

See Also: #21 Blur Quality
2018-12-22 22:08:55 +01:00
Michael Fabian 'Xaymar' Dirks c0cb20300b filter-blur: Rename factory and instance to blur_* 2018-11-08 11:16:55 +01:00
Michael Fabian 'Xaymar' Dirks daad792eda filter-blur: Add support for scene as mask input (#14)
Adds full support for Scenes as mask input so that you can re-use your overlay scene as a blur input and have the blur follow behind your overlay.

Closes #14
2018-10-01 01:03:48 +02:00
Michael Fabian 'Xaymar' Dirks 382a217f06 filter-blur: Add support for image and source masks (#14) 2018-10-01 01:00:00 +02:00
Michael Fabian 'Xaymar' Dirks ebbc0cb1ce filter-blur: Fix Mask Type and split Color into Color and Alpha 2018-10-01 00:57:22 +02:00
Michael Fabian 'Xaymar' Dirks d56f4f9eac filter-blur: Add proper mask options
* Removes the old 'Region' fields and places them under a 'Mask' option that can do much more.
* Supported Mask types: Region, Image, Source.
* Image and Source mask types allow for a color filter and multiplier.
2018-09-30 22:48:47 +02:00
Michael Fabian 'Xaymar' Dirks 3135214a03 filter-blur: Refactor and formatting
* Now using a Factory and Instance approach to simplify and beautify the code at the same time.
* Additionally we now keep track of created filters and only load data if there is a filter active, and unload data if there are no more filters. This reduces memory and GPU overhead when no filter is active, but adds a first time filter creation overhead.
* Variables and functions now use snake_case.
2018-09-30 20:50:00 +02:00
Michael Fabian 'Xaymar' Dirks 8296af68c6 project: Rename 'Filter' to 'filter' 2018-09-30 18:49:52 +02:00
Michael Fabian 'Xaymar' Dirks c9ed74a3f9 gs-texture: Additional type safety and new methods 2018-04-29 02:59:51 +02:00
Michael Fabian 'Xaymar' Dirks af71a7cc1d filter-blur: Allow applying Blur to a sub-region of the source only
The Blur Filter can now be applied to a region inside the source itself, the inverse of that region, and/or a feathered version of that region. This allows for easier scene setups where only some parts need to be blurred, but the rest can be left as is.

Fixes #12
2018-04-29 00:14:29 +02:00
Michael Fabian 'Xaymar' Dirks 1ba9145fbd filter-blur: Use only a single Gaussian Kernel Texture 2018-04-28 14:41:18 +02:00
Michael Fabian 'Xaymar' Dirks 6c1e874369 filter-blur: Refactoring, formatting and copyright 2018-04-28 13:59:54 +02:00
Michael Fabian 'Xaymar' Dirks ec19f44f96 project: Don't prefix includes with "libobs/" 2018-04-23 17:53:27 +02:00
Michael Fabian 'Xaymar' Dirks fe05dca51e gfx, gs: Fix commits 9f518764b6 & 2adfa5765c 2018-03-20 12:50:17 +01:00
Michael Fabian 'Xaymar' Dirks 2adfa5765c gs: Rename to snake_case instead of PascalCase
This should prevent mishaps with upper/lowercase typos and fits in better with the C++ standard code, which is also in snake_case.
2018-03-20 12:44:02 +01:00
Michael Fabian 'Xaymar' Dirks b4eadc2995 filter-blur: Don't override blend mode of original source
This causes a black square to appear, since the blend mode should ideally match what the original source thought it would be.
2018-01-25 05:11:15 +01:00
Michael Fabian 'Xaymar' Dirks e9fc9e89f2 plugin: Use self-registration code everywhere 2018-01-16 11:47:24 +01:00
Michael Fabian 'Xaymar' Dirks 78ccd94639 filter-blur: Ensure that the initializer is unique 2017-12-14 08:05:06 +01:00
Michael Fabian 'Xaymar' Dirks e7bbb213a4 filter-blur: Fix Blur filter occasionally not rendering
An earlier commit changed how Blur filter rendered and thus m_technique was no longer being initialized, resulting in the check randomly failing if the memory was just right.

This also adds some more extra logging to the instance creation in case things fail and fixed one MSVC warning.

Fixes #1
2017-12-14 03:52:29 +01:00
Michael Fabian 'Xaymar' Dirks 6c4b8bbf12 filter-blur: Fix up some MSVC warnings 2017-12-14 03:00:08 +01:00
Michael Fabian 'Xaymar' Dirks 911f7696bb filter-blur: Reduce log spam on error 2017-12-14 02:35:47 +01:00
Michael Fabian 'Xaymar' Dirks 578c963a02 filter-blur: Code cleanup, fixes and more
- Fixed Gaussian Blur having color issues with radii that aren't a power of 2.
- Improved error reporting to better debug problems where Blur doesn't render.
- Switched from manual object management to managed classes.
- Lots of code cleanup for maintainability.
2017-12-14 01:39:33 +01:00
Michael Fabian 'Xaymar' Dirks 61f20a83ad filter-blur: Use self-registration feature 2017-12-14 00:24:37 +01:00
Xaymar c0aa79abbe filter-blur: Faster initialization for Gaussian Blur 2017-10-22 19:04:41 +02:00
Michael Fabian Dirks e619f03217 filter-blur: Remove unused and duplicate functions 2017-09-18 00:05:40 +02:00
Michael Fabian Dirks 4dbf414214 effects, filter-blur: Precalculated Kernel, Formatting, Rendering and more
Filter:
* Massively improved Rendering loop to reduce overhead and provide cleaner code.

Gaussian Blur:
* Added precalculated Kernels using Textures. Slightly reduced GPU load.
* Added basic attempt at a Nvidia o(n/2+1) gaussian blur implementation.
* Fix up LOD for texture sampling.

Box Blur:
* Halved loop count.
2017-08-20 00:25:05 +02:00
Michael Fabian Dirks 52c3a0171e filter-blur: Initial work on optimization 2017-07-18 16:50:30 +02:00
Michael Fabian Dirks 9967a6ebf0 filter-blur: Add Color Format option
This option allows applying the blur to other color formats such as YUV. Bilateral Blur benefits the most from this, resulting in smoother images at lower kernel sizes.
2017-07-06 06:02:41 +02:00
Michael Fabian Dirks 9c97d90cc2 filter-blur: Split off blur rendering into method 2017-07-06 05:57:57 +02:00
Michael Fabian Dirks 191b1ea23f filter-blur: Move effects to 'data/effects'
This should help reusing the same effect instead of having an effect per filter.
2017-07-06 05:52:46 +02:00
Michael Fabian Dirks 2621d4961f filter-blur: Multiple changes, see description
* Added a 'Bilateral' de-noising blur, currently very resource hungry. It also has two extra sliders called 'Smoothing' and 'Sharpness', the former controls how smooth the output is
* Updated effect loading to be global instead of per instance.
* Changed default blur size to 5px.
* Simplified render loop (see previous effect commit).
2017-07-03 07:20:15 +02:00
Michael Fabian Dirks 5cdbb127c7 filter-blur: Add Box and Gaussian Blur Filter
This is not very optimized at the moment and will take quite a bit of GPU time. Will have to spend some time later to optimize it and perhaps add directional blur ("Motion Blur" to it).
2017-07-03 02:46:45 +02:00