mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-19 01:36:12 +08:00
libobs: Add 'solid' effect for basic primitives
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
uniform float4x4 ViewProj;
|
||||
uniform float4 color = {1.0, 1.0, 1.0, 1.0};
|
||||
|
||||
struct SolidVertInOut {
|
||||
float4 pos : POSITION;
|
||||
};
|
||||
|
||||
SolidVertInOut VSSolid(SolidVertInOut vert_in)
|
||||
{
|
||||
SolidVertInOut vert_out;
|
||||
vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj);
|
||||
return vert_out;
|
||||
}
|
||||
|
||||
float4 PSSolid(SolidVertInOut vert_in) : TARGET
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
struct SolidColoredVertInOut {
|
||||
float4 pos : POSITION;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
SolidColoredVertInOut VSSolidColored(SolidColoredVertInOut vert_in)
|
||||
{
|
||||
SolidColoredVertInOut vert_out;
|
||||
vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj);
|
||||
vert_out.color = vert_in.color;
|
||||
return vert_out;
|
||||
}
|
||||
|
||||
float4 PSSolidColored(SolidColoredVertInOut vert_in) : TARGET
|
||||
{
|
||||
return vert_in.color * color;
|
||||
}
|
||||
|
||||
technique Solid
|
||||
{
|
||||
pass
|
||||
{
|
||||
vertex_shader = VSSolid(vert_in);
|
||||
pixel_shader = PSSolid(vert_in);
|
||||
}
|
||||
}
|
||||
|
||||
technique SolidColored
|
||||
{
|
||||
pass
|
||||
{
|
||||
vertex_shader = VSSolidColored(vert_in);
|
||||
pixel_shader = PSSolidColored(vert_in);
|
||||
}
|
||||
}
|
||||
@@ -218,6 +218,11 @@ static bool obs_init_graphics(struct obs_video_info *ovi)
|
||||
NULL);
|
||||
bfree(filename);
|
||||
|
||||
filename = find_libobs_data_file("solid.effect");
|
||||
video->solid_effect = gs_create_effect_from_file(filename,
|
||||
NULL);
|
||||
bfree(filename);
|
||||
|
||||
filename = find_libobs_data_file("format_conversion.effect");
|
||||
video->conversion_effect = gs_create_effect_from_file(filename,
|
||||
NULL);
|
||||
@@ -225,6 +230,8 @@ static bool obs_init_graphics(struct obs_video_info *ovi)
|
||||
|
||||
if (!video->default_effect)
|
||||
success = false;
|
||||
if (!video->solid_effect)
|
||||
success = false;
|
||||
if (!video->conversion_effect)
|
||||
success = false;
|
||||
}
|
||||
@@ -342,6 +349,7 @@ static void obs_free_graphics(void)
|
||||
gs_entercontext(video->graphics);
|
||||
|
||||
effect_destroy(video->default_effect);
|
||||
effect_destroy(video->solid_effect);
|
||||
effect_destroy(video->conversion_effect);
|
||||
video->default_effect = NULL;
|
||||
|
||||
@@ -964,6 +972,12 @@ effect_t obs_get_default_effect(void)
|
||||
return obs->video.default_effect;
|
||||
}
|
||||
|
||||
effect_t obs_get_solid_effect(void)
|
||||
{
|
||||
if (!obs) return NULL;
|
||||
return obs->video.solid_effect;
|
||||
}
|
||||
|
||||
signal_handler_t obs_signalhandler(void)
|
||||
{
|
||||
if (!obs) return NULL;
|
||||
|
||||
@@ -317,6 +317,9 @@ EXPORT char *obs_find_plugin_file(const char *file);
|
||||
/** Returns the default effect for generic RGB/YUV drawing */
|
||||
EXPORT effect_t obs_get_default_effect(void);
|
||||
|
||||
/** Returns the solid effect for drawing solid colors */
|
||||
EXPORT effect_t obs_get_solid_effect(void);
|
||||
|
||||
/** Returns the primary obs signal handler */
|
||||
EXPORT signal_handler_t obs_signalhandler(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user