Skip to content

Commit

Permalink
feat: support straight alpha in mixer shader
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jan 21, 2025
1 parent e221039 commit c490d6b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/accelerator/ogl/image/image_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ struct image_kernel::impl
// Setup shader
shader_->use();

shader_->set("is_straight_alpha", params.pix_desc.is_straight_alpha);
shader_->set("plane[0]", texture_id::plane0);
shader_->set("plane[1]", texture_id::plane1);
shader_->set("plane[2]", texture_id::plane2);
Expand Down
6 changes: 5 additions & 1 deletion src/accelerator/ogl/image/shader.frag
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ uniform sampler2D plane[4];
uniform sampler2D local_key;
uniform sampler2D layer_key;

uniform bool is_straight_alpha;

uniform mat3 color_matrix;
uniform vec3 luma_coeff;
uniform bool has_local_key;
Expand Down Expand Up @@ -495,7 +497,7 @@ vec4 get_rgba_color()
{
float y = get_sample(plane[0], TexCoord.st / TexCoord.q).g * precision_factor[0];
float cb = get_sample(plane[1], TexCoord.st / TexCoord.q).b * precision_factor[1];
float cr = get_sample(plane[1], TexCoord.st / TexCoord.q).r * precision_factor[1];
float cr = get_sample(plane[1], TexCoord.st / TexCoord.q).r * precision_factor[1];
return ycbcra_to_rgba(y, cb, cr, 1.0);
}
}
Expand All @@ -505,6 +507,8 @@ vec4 get_rgba_color()
void main()
{
vec4 color = get_rgba_color();
if (is_straight_alpha)
color.rgb *= color.a;
if (chroma)
color = chroma_key(color);
if(levels)
Expand Down
3 changes: 2 additions & 1 deletion src/core/frame/pixel_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ struct pixel_format_desc final
{
}

pixel_format format = pixel_format::invalid;
pixel_format format = pixel_format::invalid;
bool is_straight_alpha = false;
std::vector<plane> planes;
core::color_space color_space = core::color_space::bt709;
};
Expand Down

0 comments on commit c490d6b

Please sign in to comment.