Commit Graph

276 Commits

Author SHA1 Message Date
Michael Fabian 'Xaymar' Dirks 1c072d67cb filter-transform: Validate source size each tick
Rendering happens with cached Geometry that is only updated when necessary, such as when the user changes settings. This optimization was necessary to reduce CPU and GPU usage as we can simply re-use the same geomtry instead of recalculating it.

However, the actual source size was never checked. That meant that when a source changed size through any means, the filter would not update the geomtry accordingly, and the result was a squished or stretched image.

With this, the source size is now checked each tick.

Fixes #48
2019-02-15 13:52:44 +01:00
Michael Fabian 'Xaymar' Dirks 3bf1333c84 project: Restructure of the file system
The number of files in the source directory was a little bit much and just made file naming more complex than it had to be. Therefore all files were moved into subdirectories where it matters.

Filters now reside in source/filters/, Sources in source/sources/, OBS Wrappers in obs/, OBS GS Wrappers in obs/gs/, Transitions will reside in source/transitions, Graphics Helpers will be in gfx/.
2019-02-11 04:03:57 +01:00
Michael Fabian 'Xaymar' Dirks 3e4930e6e0 filter-transform: Fix incorrect names for properties and options
MipGenerator.Strength was renamed to MipGenerator.Intensity, which better fits the actual intention of the property. Additionally all the mipmap generator options are now correctly named.
2019-02-11 04:03:56 +01:00
Michael Fabian 'Xaymar' Dirks 9f28144b0b filter-blur: Properly set Image(s) filter for path property 2019-02-01 19:58:05 +01:00
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 10f7047042 util-math: Add templated gaussian function 2019-02-01 08:35:58 +01:00
Michael Fabian 'Xaymar' Dirks 3ee815b152 filter-sdf-effects: Extend shadow range to -16...16 2019-01-31 04:53:39 +01:00
Michael Fabian 'Xaymar' Dirks cfc828f0f8 source-mirror: Fix crash with audio sources and late video sources
Source Mirror would incorrectly crash if an Audio only source was selected, as it expected a video frame to be present of any size. This fixes the problem by first testing if there is any video information to render and then just catching any exception that happens during rendering.
2019-01-31 02:57:18 +01:00
Michael Fabian 'Xaymar' Dirks f5424d1aad gs-effect: Replace OBS cached file loading with custom one
The normal OBS behavior is to cache files that are loaded from disk, however this is not the behavior we want at all, as it can miss file updates as it never checks the disk for an updated file.

So instead of relying on OBS, this implements the file reading and effect creation without the cache. If a cache is necessary, it would not be the job of this class.
2019-01-31 02:30:18 +01:00
Michael Fabian 'Xaymar' Dirks 75009c617a filter-sdf-effects: Support for scaling SDF Texture Size
This allows increasing or decreasing the accuracy of the Signed Distance Field at runtime without requiring the initial source to be resized. Use case for this would be small text where the higher quality would only be noticable on the shadow and not the text itself.
2019-01-30 03:12:12 +01:00
Michael Fabian 'Xaymar' Dirks 493ef5da23 filter-sdf-effects: Move factory definitions before instance 2019-01-30 02:39:42 +01:00
Michael Fabian 'Xaymar' Dirks 7cf3e17b9b filter-sdf-effects: Fix black border and add inverse gradient shadow
Sources were rendering with a black border around them if they had a soft fade, which is due to how the shadow calculated the image sample. With the new shader code this is now fixed and the source looks like it should be. Additionally this removes the bug where enabling any shadow would cause only the texels to draw that were above the threshold.

Additionally this adds support for inverse gradients (min > max) and negative gradients for outer shadows instead of only positive gradients. This technically allows for cleaner shadows.
2019-01-30 02:38:34 +01:00
Michael Fabian 'Xaymar' Dirks 3ebbc84ee2 filter-sdf-effects: Rename Shadow (SDF) Filter (Part 2)
This finalizes the rename started in the previous commit by changing the class name and also updating the locale strings
2019-01-29 07:35:14 +01:00
Michael Fabian 'Xaymar' Dirks a7161b51e0 filter-sdf-effects: Rename Shadow (SDF) Filter (Part 1)
The nature of this Signed Distance Field based Filter is not to only draw shadows, but to also draw an outline or even glow around a source. Therefore the name "Inner/Outer Shadow (SDF)" does not fit well with the intent of the actual Filter.
2019-01-29 04:35:12 +01:00
Michael Fabian 'Xaymar' Dirks a56cbf89a9 filter-blur: Refactoring 2019-01-28 01:08:13 +01:00
Michael Fabian 'Xaymar' Dirks 4eb3197720 gfx-source-texture: Don't create two references to the same source 2019-01-28 00:47:36 +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 97bf38633b gfx-source-texture: Release child source if add_active_child fails 2019-01-27 23:33:38 +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 fa4a81bb54 gfx-source-texture: Delete copy and move constructors and operators 2019-01-27 22:50:35 +01:00
Michael Fabian 'Xaymar' Dirks a15f1934b3 filter-custom-shader: Do not build for release
This feature is postponed until 0.6.0 for stability and UI/UX issues.
2019-01-27 22:44:45 +01:00
Michael Fabian 'Xaymar' Dirks 551cbb83b1 obs-source-tracker: Source Tracking Compatibility Layer
Allows for enumerating any kind of source, as long as it has a name and is not private. As obs_enum_scenes is a 23.x and above function, this class should be used instead to remain backwards compatible.
2019-01-27 22:43:49 +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 3ac7e46628 filter-shadow-sdf: Remove shadow_sdf namespace, rename shadow_sdf_instance to shadow_sdf 2019-01-25 00:55:40 +01:00
Michael Fabian 'Xaymar' Dirks 7708dd0792 filter-shadow-sdf: Refactoring, fix and optimize rendering
Fixes the m_source_texture = nullptr bug, which happened due to m_tick and m_last_tick both being 0, as no video_tick is called when the source is first created. Instead a boolean flag is now used that is reset to false on each video_tick.
2019-01-25 00:54:34 +01:00
Michael Fabian 'Xaymar' Dirks d29f5ce477 filter-transform: Transform to transform, ...Addon to ..._factory 2019-01-25 00:38:20 +01:00
Michael Fabian 'Xaymar' Dirks 2aa4595bd3 filter-displacement: Rename Displacement to displacement, ...Addon to ..._factory 2019-01-25 00:38:01 +01:00
Michael Fabian 'Xaymar' Dirks 7a61006d2b source-mirror: Rename Mirror to mirror, ...Addon to ..._factory 2019-01-25 00:36:54 +01:00
Michael Fabian 'Xaymar' Dirks a37d9bbb59 filter-shadow-sdf: Actually delete instances in destroy()
This fixes a memory leak discovered by @catb0t.

Related #33
2019-01-25 00:31:50 +01:00
Michael Fabian 'Xaymar' Dirks ddfb08f39e filter-displacement: Update file logic and rendering
This replaces the use of gs_texture_t* with gs::texture, further improving stability. Additionally some of the useless checks were replaced or reduced.
2019-01-25 00:28:06 +01:00
Michael Fabian 'Xaymar' Dirks 0bdf8e3bba filter-displacement: Use gs::effect instead of gs_effect_t*
The managed gs::effect class handles all acquire and release calls for us. Also slightly simplifies the video_render logic.
2019-01-25 00:28:06 +01:00
Michael Fabian 'Xaymar' Dirks fedb6e3259 filter-displacement: Further refactoring 2019-01-25 00:28:06 +01:00
Michael Fabian 'Xaymar' Dirks c1995c03a9 filter-displacement: Refactor to match new class structure 2019-01-25 00:28:05 +01:00
Cat Stevens c749f5dd62 obs-audio-capture.hpp: missing memory include 2019-01-24 23:30:42 +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 0ae120835a filter-transform: Optimize rendering, fix bad property names
The Transform filter will now no longer render the child source more than once per tick(), resulting in an overall speed up for heavy sources. This also applies to mipmapping and shape rendering. Any other calls to video_render will instead just use the cached texture.

Additionally the crash on exit has been fixed which was caused by strings.hpp containing static const char*s and using these directly in obs calls. Instead we now use #define for those property names
2019-01-24 20:20:34 +01:00
Michael Fabian 'Xaymar' Dirks e28334d27b util-memory: Fix alligned_alloc for MSVC
Microsofts _aligned_malloc has size and alignment switched around, which causes an unwanted exception.
2019-01-24 20:18:28 +01:00
Michael Fabian 'Xaymar' Dirks b3c2845d15 filter-transform: Refactoring and formatting 2019-01-24 15:57:33 +01:00
Michael Fabian 'Xaymar' Dirks e4a534fbfe plugin: Remove legacy instance references
The modern system is a self-registering system using initializers and finalizers
2019-01-24 14:26:08 +01:00
Michael Fabian 'Xaymar' Dirks 406326b378 util-math: Add 16-byte aligned version of vec2 2019-01-24 05:14:17 +01:00
Michael Fabian 'Xaymar' Dirks 98baa0d98b filter-transform: Fix order of functions 2019-01-24 04:35:22 +01:00
Michael Fabian 'Xaymar' Dirks ff6176d7bc filter-transform: Destructor comes before Constructors 2019-01-24 04:33:56 +01:00
Michael Fabian 'Xaymar' Dirks c1441e72c0 filter-transform: Refactor to match source-mirror structure 2019-01-24 04:32:14 +01:00
Michael Fabian 'Xaymar' Dirks 9d55013ec2 source-mirror: Improve rendering and add new rescaling options
Rendering will now use a cached version of the mirrored source in order to reduce rendering cost drastically for heavy sources or scenes. Additionally rescaling now uses the internal scene instead of being a custom implementation, allowing for some new things.

Rescaling now has a new option: Bounds Type! This option allows control over just how a source is scaled, by default it is set to Stretch, but there are other options that can keep the aspect ratio of the mirrored source in tact.

Additionally the ScalingMethod struct has been replaced with obs_scale_type, which means that Bilinear Low Resolution is now no longer an option.

Implements #35
2019-01-24 04:28:11 +01:00
Michael Fabian 'Xaymar' Dirks 82f64d16eb source-mirror: Refactoring and partially revert 4bb32a71bc
Initialization happens in the constructor again, as using a delayed initialization only caused update() to be slower.

Additionally refactored some variable names to make more sense.
2019-01-24 01:12:48 +01:00
Michael Fabian 'Xaymar' Dirks 144323bec3 source-mirror: Revert thread name from c5e02af178 2019-01-24 01:00:38 +01:00
Michael Fabian 'Xaymar' Dirks 6b7ef2d3ed gfx-source-texture: Allocate a render target in constructor
Can't really render without one.
2019-01-24 00:12:42 +01:00