Commit Graph

129 Commits

Author SHA1 Message Date
Michael Fabian 'Xaymar' Dirks a553b39a6d gfx-shader: Actually fix the thing 93207d was supposed to fix 2023-03-28 12:40:40 +02:00
Michael Fabian 'Xaymar' Dirks c2c5afd763 gfx-shader: Actually write alpha channel to render target 2023-03-28 12:40:39 +02:00
Michael Fabian 'Xaymar' Dirks a19e8d1e00 gfx-shader: Add default path for file selection 2023-03-28 12:40:37 +02:00
Michael Fabian 'Xaymar' Dirks 7a929d6af4 locale: Add missing and remove unused strings 2020-04-23 09:14:31 +02:00
Michael Fabian 'Xaymar' Dirks 5291b193e2 gfx-shader: Fix rendering at unexpected sizes and fix performance
Fixes rendering at unexpected sizes by first rendering to a render target and then rendering the contents of that render target to the frame buffer instead. This also prevent rendering twice or more, which might cause severe FPS impact.
2020-04-23 08:10:01 +02:00
Michael Fabian 'Xaymar' Dirks 908d1f0a20 project: Modernize code to proper C++ 2020-04-09 00:17:25 +02:00
Michael Fabian 'Xaymar' Dirks a138f95126 cmake: Fix clang support in native OBS Studio build 2020-04-05 06:50:21 +02:00
Michael Fabian 'Xaymar' Dirks 9ca190c96a gfx-shader: Don't use modified_properties to reload shaders
As OBS Studio locks some mutexes in a different order depending on what actions are being done, using modified_properties for GPU work causes things to freeze in place. Instead have users manually click the refresh button when they changed files in order to prevent this freeze from happening.

Fixes: #118
2020-04-03 18:54:56 +02:00
Michael Fabian 'Xaymar' Dirks cc9d3486b2 project: Fix Linux support by fixing errors and warnings
With this, GCC 8 and above should now be able to compile the project both in obs-studio and as a standalone install. Some features are currently still not fully supported and require extra work, but the majority of things are supported and work out of the box. Exact feature parity can be looked up here on the wiki: https://github.com/Xaymar/obs-StreamFX/wiki/Platform-Feature-Parity

Related: #119 #98 #30
2020-04-02 20:37:45 +02:00
Michael Fabian 'Xaymar' Dirks 59fa1d36d7 common: Common header include for improved platform support
This header includes all common data between headers used in the plugin. This should improve cross-platform compiling support whenever possible, as all platform-dependent common includes and defines can be done here.
2020-04-02 17:02:01 +02:00
Michael Fabian 'Xaymar' Dirks ac8844b305 gfx-shader: Add defaults 2020-03-31 22:34:22 +02:00
Michael Fabian 'Xaymar' Dirks 79406b0b08 gfx-shader: Additional stable time values
'Time.x' gets inaccurate if OBS Studio is running for more than two hours, therefore we have to do something to fix it. By allowing the shader code to control when things loop using 'Time.y' (0..1) and 'Time.z' (the number of times 'Time.y' wrapped back to 0), a much more stable animation can be achieved.
2020-03-28 22:17:33 +01:00
Michael Fabian 'Xaymar' Dirks 6ae9904e13 gfx-shader: Support for filters and transitions
Due to render logic required for transitions, some of the render logic is split into an additional function called 'prepare_render'. Additionally the storage for some temporary objects has been removed as it these objects usually do not outlive their rendering time anyway.

Related: #96 #95 #94 #5
2020-03-28 18:37:00 +01:00
Michael Fabian 'Xaymar' Dirks 0a16ce07dc project: Merged FFmpeg Encoders Step 2 2020-01-13 22:40:15 +01:00
Michael Fabian 'Xaymar' Dirks 3062d3b331 gfx-shader: Better logging, and ViewSize parameter 2020-01-01 04:21:02 +01:00
Michael Fabian 'Xaymar' Dirks 3e02857d39 gfx-shader-param: Initialize all variables 2020-01-01 02:59:02 +01:00
Michael Fabian 'Xaymar' Dirks 26a58645a7 gfx-shader-param-basic: Support for scaling and fix enumerations
Scaling is now fully supported for Floats and Integers, which allows much higher precision inputs, or upscaling to a different range. Complex functions for scaling are not supported as those would be a scripting thing and should be kept as that (OBS Studio has built in Lua scripting).

Additionally, enumerations are now correctly loaded with data.

Related #5
2020-01-01 02:58:45 +01:00
Michael Fabian 'Xaymar' Dirks ce15bc6abc gfx-shader-param: Fix is_visible 2019-12-25 20:10:09 +01:00
Michael Fabian 'Xaymar' Dirks f79502b9b0 gfx-shader: Deal with remaining compile errors 2019-12-25 19:18:44 +01:00
Michael Fabian 'Xaymar' Dirks 731a22e1ea gfx-shader-param-basic: Automatically resize min/max/step/scale buffers 2019-12-25 19:10:56 +01:00
Michael Fabian 'Xaymar' Dirks 975d2e293e gfx-shader-param-basic: Add Integers, Enumerations, Arrays 2019-12-25 19:10:01 +01:00
Michael Fabian 'Xaymar' Dirks 903d416607 gfx-shader-param: Fix get_parameter 2019-12-25 19:09:30 +01:00
Michael Fabian 'Xaymar' Dirks 1902d005e9 gfx-shader-param: Add support for automatic parameters
Allows other parameters to be a seed to these parameters.
2019-12-25 10:14:04 +01:00
Michael Fabian 'Xaymar' Dirks 907216f143 gfx-shader: Don't show parameters that are invisible 2019-12-25 10:10:06 +01:00
Michael Fabian 'Xaymar' Dirks 4acbfedd40 gfx-shader-param: Support for input, slider, enum and more 2019-12-25 10:09:56 +01:00
Michael Fabian 'Xaymar' Dirks 777556f4f6 gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.

Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.

The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 22:02:37 +01:00
Michael Fabian 'Xaymar' Dirks eab3ae4fbc gfx-shader-param: Add support for order and overall name/desc 2019-12-24 08:38:01 +01:00
Michael Fabian 'Xaymar' Dirks 9696f836e0 gfx-shader: Fix startup and select crash if file is missing 2019-12-24 08:37:37 +01:00
Michael Fabian 'Xaymar' Dirks 4c5a7018a3 gfx-shader: Add file watching and dynamic UI updates
Thanks to the workaround in obs::tools, gfx::shader::shader now supports dynamically rebuilding the properties with new properties without crashing OBS Studio. This effectively allows you to have an up to date view of the current parameters for the shader technique.

Additionally with file watching, live development of shaders is possible at very little cost. Currently only file times and size is looked at every 333ms, but in the future it is possible to also watch for file renames and more.
2019-12-22 06:14:26 +01:00
Michael Fabian 'Xaymar' Dirks bd6b4f2d2a gfx-shader-param-basic: Add support for defaults function 2019-12-22 06:07:54 +01:00
Michael Fabian 'Xaymar' Dirks 672c6d39af gfx-shader-param: Split setting defaults from properties 2019-12-22 06:07:37 +01:00
Michael Fabian 'Xaymar' Dirks 9ef60cc2f9 gfx-shader: Add support for validating file differences
Removes the stutter when re-opening the properties dialog which was caused by recompiling the same exact shader every time this happened. Also paves the way for simple file watching.
2019-12-21 18:23:26 +01:00
Michael Fabian 'Xaymar' Dirks cbada3e438 obs-source: Deprecate obs::source due to stability issues
This should be replaced with a class inheriting from std::shared_ptr.
2019-12-21 17:43:12 +01:00
Michael Fabian 'Xaymar' Dirks 7e5cbe18cf project: Apply clang-format 2019-12-21 17:05:53 +01:00
Michael Fabian 'Xaymar' Dirks d13778b017 gfx-shader: Fix some crash/problematic locations 2019-12-18 07:49:56 +01:00
Michael Fabian 'Xaymar' Dirks 24edee795a gfx-shader-param: FIXME Don't create parameters for invisible 2019-12-18 07:49:43 +01:00
Michael Fabian 'Xaymar' Dirks de473f0c2e gfx-shader-param-basic: Fix incorrect float properties 2019-12-18 07:49:19 +01:00
Michael Fabian 'Xaymar' Dirks f1b9a1a712 gfx-shader: Initial code 2019-12-18 06:39:07 +01:00
Michael Fabian 'Xaymar' Dirks 0a761b97a2 gfx-shader-param*: Initial code 2019-12-18 06:39:07 +01:00
Michael Fabian 'Xaymar' Dirks 3b66860a8f gfx-blur-gaussian*: Update to new API 2019-12-18 06:39:07 +01:00
Michael Fabian 'Xaymar' Dirks 47dc948861 gfx-blur-gaussian: Remove left over obs_enter_graphics (#83)
This single line causes OBS to freeze in place, and is not needed as the Graphics Context is already locked by gs::context().

Fixes #83
2019-12-17 23:53:21 +01:00
Michael Fabian 'Xaymar' Dirks b54e95527a gs-effect*: Finish up refactoring onto std::shared_ptr
This is most likely not the last refactor, the entire obs/gs stuff is very very basic right now and likely needs a complete rewrite.
2019-12-15 12:55:19 +01:00
Michael Fabian 'Xaymar' Dirks 0ad896e905 gfx-shader: Rename from gfx-effect-source 2019-12-15 09:09:11 +01:00
Michael Fabian 'Xaymar' Dirks ba71b43a39 gfx-source-texture: Add debug markers 2019-10-18 22:32:54 +02:00
Michael Fabian 'Xaymar' Dirks 03c2a68846 gfx-effect-source: Catch exceptions as const 2019-10-13 07:28:59 +02:00
Michael Fabian 'Xaymar' Dirks 5a4d38d249 project: Fix a massive list of dangerous warnings
This is a massive improvement to stability and safety when using the plugin, as all exceptions should now no longer be leaked into C controlled code, which can't actually handle exceptions at all.

Warnings fixed:

* Potentially throwing exception during library load.
* Possibly throwing function passed to C.
* Statement does nothing.
* Variable is initialized but not referenced.
* Variable overloads variable in parent scope.
2019-09-05 18:42:28 +02:00
Michael Fabian 'Xaymar' Dirks 82faab4380 project: Re-apply formatting 2019-09-04 03:03:41 +02:00
Michael Fabian 'Xaymar' Dirks ce7e4c97d4 project: Don't use non-standard strcmpi 2019-09-04 03:02:19 +02:00
Michael Fabian 'Xaymar' Dirks 03c704de1a project: Correct usage of exceptions and include stdexcept 2019-09-04 02:59:04 +02:00
Michael Fabian 'Xaymar' Dirks f27320c6c9 project: Remove use of P_INITIALIZER
Does not support cross-platform very well and breaks on Apple for no apparent reason.

Add resolution scale to shader filter.
2019-09-04 02:47:27 +02:00
Michael Fabian 'Xaymar' Dirks deeb6719c4 project: Apply formatting 2019-08-24 12:59:32 +02:00
Michael Fabian 'Xaymar' Dirks 250dc97603 gfx-effect-source: enumerate child sources correctly 2019-08-07 20:40:04 +02:00
Michael Fabian 'Xaymar' Dirks a04d102568 gfx-effect-source: Support for textures and some crash resistance 2019-08-07 20:22:12 +02:00
Michael Fabian 'Xaymar' Dirks 90699f6b6f gfx-effect-source: Implement defaults for bool, value and matrix 2019-08-07 19:19:56 +02:00
Michael Fabian 'Xaymar' Dirks 9be36d5ec4 gfx-effect-source: Add function to get "default" value 2019-08-07 18:42:54 +02:00
Michael Fabian 'Xaymar' Dirks 2b2f87e6fc gfx-effect-source: Fix validity check
Had the check inverted oops.
2019-08-07 18:16:20 +02:00
Michael Fabian 'Xaymar' Dirks c88535c7ab gfx-effect-source: Remove/replace old defines 2019-08-07 18:11:46 +02:00
Michael Fabian 'Xaymar' Dirks 1b34e5210a gfx-effect-source: Expose defines to set default file and technique 2019-08-07 18:06:24 +02:00
Michael Fabian 'Xaymar' Dirks 98a18480d0 gfx-effect-source: Fix UI mode detection 2019-08-07 17:45:32 +02:00
Michael Fabian 'Xaymar' Dirks 335847945d gfx-effect-source: Allow overriding value and visibility of parameters 2019-08-07 17:37:34 +02:00
Michael Fabian 'Xaymar' Dirks bde4e278bf gfx-effect-source: Further work on rewrite
This partially implements most behavior to an acceptable degree for use right now.
2019-08-07 17:14:44 +02:00
Michael Fabian 'Xaymar' Dirks 1092dc1de1 gfx-effect-source: Complete rewrite from scratch 2019-08-07 12:42:25 +02:00
Michael Fabian 'Xaymar' Dirks 71b223dcb5 gs-effect: Add ::create for shared_ptr and remove default constructor 2019-08-04 23:19:38 +02:00
Michael Fabian 'Xaymar' Dirks 0c447f4055 gs-effect: Use std::shared_ptr and track effect lifetime
This fixes the case where the effect vanishes, but we still hold an invalid pointer to a parameter of that effect. With the new code, the effect will not vanish as long as an effect pointer exists.

However, all effects must be created either through std::shared_ptr or std::make_shared. If they were not made through one of those means, the code will crash on the ->shared_from_this() call.
2019-08-04 23:12:30 +02:00
Michael Fabian 'Xaymar' Dirks 9be02e6f2b project: Fix up previous commit 2019-08-04 20:29:04 +02:00
Michael Fabian 'Xaymar' Dirks 0e350415b3 project: Apply new coding guidelines 2019-08-04 16:20:26 +02:00
Michael Fabian 'Xaymar' Dirks f8e685cf42 project: Apply clang-format manually again 2019-04-19 20:40:07 +02:00
Michael Fabian 'Xaymar' Dirks be4d42312d project: Fix all remaining portability issues
Clang on Windows and Clang on Linux behave differently, and of course GCC on Windows (MinGW) and GCC on Linux do too. This is the point where using either compiler on either platform should successfully compile the project without any issues.

Clang and GCC have a ton of warnings however, which definitely need to be fixed in the near future. Some of them are great warnings, like old C style casts, others are non-sense like suggest brackets.

Fixes #47
Fixes #60
2019-04-19 14:18:29 +02:00
Michael Fabian 'Xaymar' Dirks aac52f736d project: Clang support
Lots and lots of errors and warnings fixed with this single commit, in the name of clang support.

Related #60, #47.
2019-04-19 09:42:15 +02:00
Michael Fabian 'Xaymar' Dirks 721bdaf642 project: Reapply clang-format globally 2019-04-03 00:19:01 +02:00
Michael Fabian 'Xaymar' Dirks b1d7814c64 gs-helper: Add managed obs graphics context
To further distance the code from having to do too much manually, the graphics context is now available as a managed class. All places that previously used obs_enter_graphics and obs_leave_graphics are now using the new gs::context class instead.
2019-04-03 00:16:13 +02:00
Michael Fabian 'Xaymar' Dirks 7c4d46c1fe gfx/blur/dual-filtering: Implement Dual Filtering Blur
Dual Filtering (or Dual Kawase) is an approximation of Gaussian Blur that can reach much higher Blur sizes at a much lower cost. However it is locked to a 2^n size, which means that currently it isn't possible to use it for blur sizes like 19, 24 and 31.

The Blur works by using the linear sampling of a GPU, combined with down- and upsampling and carefully placed sampling points. This means that there is no need for a linear optimized version of this Blur.

Related: #45, #6
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks b6d45ce73c gfx/blur/gaussian-linear: Refactor Linear Gaussian Blur
While Gaussian Blur is not a Blur type that really benefits much from linear sampling, it can be used for a slight quality and gpu usage reduction. However for Area and Directional Blur there is a better alternative: Dual Filtering Blur. And as with all other currently implement Linear versions of Blur, only Area and Directional Blur are supported.

This type of Gaussian Blur also has the loading hitch that exists in normal Gaussian Blur.

Related: #45, #6
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks fedc8e075c gfx/blur/gaussian: Refactor Gaussian Blur
Gaussian Blur is another Blur that now supports the new system, increasing the maxium Blur size to 128 and adding support for Rotational and Zoom blur. Various optimizations were done to the actual shader code which further reduced the GPU usage.

Currently the Gaussian curve is recalculated when the blur is first created, which can lead to a short hitch due to it having to search for the correct kernels. This is currently unavoidable and expected behavior until a better solution is found.

Related: #45, #6
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks 68a8fb9224 gfx/blur/box-linear: Refactor Linear Box Blur
Box Blur is a prime candidate for Linear optimizations, and as such reducing the total necessary samples by about half. However due to the reduction in samples, only Area and Directional Blur are supported.

Related: #45, #6
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks 8c5dc3c630 gfx/blur/box: Refactor Box Blur
Box Blur is the first to be on the new system and has received all the new features and optimizations available. The maximum Blur size has been increased to 128, Rotational and Zoom Blur are supported and a small optimization has been done to the shader.

Related: #45, #6
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks 395e284a37 gfx/blur/base: Newly refactored blur code base
This is the new code base for blur effects, which is much more effective at being re-usable than the old code base. It allows for much better extendable behavior and uses an interface and factory pattern, instead of hardcoding supported features.
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks ba00fbb97e project: Fix even more warnings 2019-03-01 12:00:30 +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