2023-02-28 01:15:26 +00:00
|
|
|
// AUTOGENERATED COPYRIGHT HEADER START
|
|
|
|
// Copyright (C) 2019-2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
|
|
|
// AUTOGENERATED COPYRIGHT HEADER END
|
2018-11-08 12:52:43 +00:00
|
|
|
|
|
|
|
#pragma once
|
2020-04-02 15:02:01 +00:00
|
|
|
#include "common.hpp"
|
2022-11-28 08:11:55 +00:00
|
|
|
#include "gfx/gfx-util.hpp"
|
2019-02-11 02:54:16 +00:00
|
|
|
#include "obs/gs/gs-effect.hpp"
|
|
|
|
#include "obs/gs/gs-rendertarget.hpp"
|
|
|
|
#include "obs/gs/gs-sampler.hpp"
|
|
|
|
#include "obs/gs/gs-texture.hpp"
|
|
|
|
#include "obs/gs/gs-vertexbuffer.hpp"
|
2019-12-03 16:47:39 +00:00
|
|
|
#include "obs/obs-source-factory.hpp"
|
2018-11-08 12:52:43 +00:00
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
namespace streamfx::filter::sdf_effects {
|
2020-01-13 21:40:15 +00:00
|
|
|
class sdf_effects_instance : public obs::source_instance {
|
2022-11-28 08:11:55 +00:00
|
|
|
streamfx::obs::gs::effect _sdf_producer_effect;
|
|
|
|
streamfx::obs::gs::effect _sdf_consumer_effect;
|
|
|
|
std::shared_ptr<streamfx::gfx::util> _gfx_util;
|
2020-01-13 21:40:15 +00:00
|
|
|
|
|
|
|
// Input
|
2021-06-08 02:38:24 +00:00
|
|
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _source_rt;
|
|
|
|
std::shared_ptr<streamfx::obs::gs::texture> _source_texture;
|
|
|
|
bool _source_rendered;
|
2020-01-13 21:40:15 +00:00
|
|
|
|
|
|
|
// Distance Field
|
2021-06-08 02:38:24 +00:00
|
|
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _sdf_write;
|
|
|
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _sdf_read;
|
|
|
|
std::shared_ptr<streamfx::obs::gs::texture> _sdf_texture;
|
|
|
|
double_t _sdf_scale;
|
|
|
|
float_t _sdf_threshold;
|
2020-01-13 21:40:15 +00:00
|
|
|
|
|
|
|
// Effects
|
2021-06-08 02:38:24 +00:00
|
|
|
bool _output_rendered;
|
|
|
|
std::shared_ptr<streamfx::obs::gs::texture> _output_texture;
|
|
|
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _output_rt;
|
2020-01-13 21:40:15 +00:00
|
|
|
/// Inner Shadow
|
|
|
|
bool _inner_shadow;
|
|
|
|
vec4 _inner_shadow_color;
|
|
|
|
float_t _inner_shadow_range_min;
|
|
|
|
float_t _inner_shadow_range_max;
|
|
|
|
float_t _inner_shadow_offset_x;
|
|
|
|
float_t _inner_shadow_offset_y;
|
|
|
|
/// Outer Shadow
|
|
|
|
bool _outer_shadow;
|
|
|
|
vec4 _outer_shadow_color;
|
|
|
|
float_t _outer_shadow_range_min;
|
|
|
|
float_t _outer_shadow_range_max;
|
|
|
|
float_t _outer_shadow_offset_x;
|
|
|
|
float_t _outer_shadow_offset_y;
|
|
|
|
/// Inner Glow
|
|
|
|
bool _inner_glow;
|
|
|
|
vec4 _inner_glow_color;
|
|
|
|
float_t _inner_glow_width;
|
|
|
|
float_t _inner_glow_sharpness;
|
|
|
|
float_t _inner_glow_sharpness_inv;
|
|
|
|
/// Outer Glow
|
|
|
|
bool _outer_glow;
|
|
|
|
vec4 _outer_glow_color;
|
|
|
|
float_t _outer_glow_width;
|
|
|
|
float_t _outer_glow_sharpness;
|
|
|
|
float_t _outer_glow_sharpness_inv;
|
|
|
|
/// Outline
|
|
|
|
bool _outline;
|
|
|
|
vec4 _outline_color;
|
|
|
|
float_t _outline_width;
|
|
|
|
float_t _outline_offset;
|
|
|
|
float_t _outline_sharpness;
|
|
|
|
float_t _outline_sharpness_inv;
|
|
|
|
|
|
|
|
public:
|
|
|
|
sdf_effects_instance(obs_data_t* settings, obs_source_t* self);
|
|
|
|
virtual ~sdf_effects_instance();
|
|
|
|
|
|
|
|
virtual void load(obs_data_t* settings) override;
|
2020-08-10 01:29:05 +00:00
|
|
|
virtual void migrate(obs_data_t* data, uint64_t version) override;
|
2020-04-05 04:02:03 +00:00
|
|
|
virtual void update(obs_data_t* settings) override;
|
2020-01-13 21:40:15 +00:00
|
|
|
|
2020-04-24 01:54:30 +00:00
|
|
|
virtual void video_tick(float_t) override;
|
2020-01-13 21:40:15 +00:00
|
|
|
virtual void video_render(gs_effect_t*) override;
|
|
|
|
};
|
|
|
|
|
2023-05-13 12:35:46 +00:00
|
|
|
class sdf_effects_factory : public obs::source_factory<filter::sdf_effects::sdf_effects_factory, filter::sdf_effects::sdf_effects_instance> {
|
2020-01-13 21:40:15 +00:00
|
|
|
public:
|
|
|
|
sdf_effects_factory();
|
|
|
|
virtual ~sdf_effects_factory();
|
|
|
|
|
|
|
|
virtual const char* get_name() override;
|
|
|
|
|
|
|
|
virtual void get_defaults2(obs_data_t* data) override;
|
|
|
|
|
|
|
|
virtual obs_properties_t* get_properties2(filter::sdf_effects::sdf_effects_instance* data) override;
|
2020-04-05 16:52:06 +00:00
|
|
|
|
2021-04-16 23:43:30 +00:00
|
|
|
#ifdef ENABLE_FRONTEND
|
|
|
|
static bool on_manual_open(obs_properties_t* props, obs_property_t* property, void* data);
|
|
|
|
#endif
|
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
public: // Singleton
|
|
|
|
static void initialize();
|
|
|
|
|
|
|
|
static void finalize();
|
|
|
|
|
|
|
|
static std::shared_ptr<sdf_effects_factory> get();
|
2020-01-13 21:40:15 +00:00
|
|
|
};
|
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
} // namespace streamfx::filter::sdf_effects
|