Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Dual Source Blending #1955

Merged
merged 1 commit into from Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions build/main.rs
Expand Up @@ -30,6 +30,7 @@ where
"GL_AMD_depth_clamp_separate",
"GL_APPLE_vertex_array_object",
"GL_ARB_bindless_texture",
"GL_ARB_blend_func_extended",
"GL_ARB_buffer_storage",
"GL_ARB_compute_shader",
"GL_ARB_copy_buffer",
Expand Down
21 changes: 21 additions & 0 deletions src/draw_parameters/blend.rs
Expand Up @@ -178,6 +178,22 @@ pub enum LinearBlendingFactor {
/// Multiply the source or destination component by `1.0` minus the alpha value of
/// `Blend::const_value`.
OneMinusConstantAlpha,

/// Multiply the source or destination component by its corresponding value
/// in source index one (you need to explicitly specify `layout(location=0, index=1)`
/// to bind it in your shader.
/// This is useful in Dual Source Blending
/// <https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_blend_func_extended.txt>
SourceOneColor,

/// Equivalent to `1 - SourceOneColor`.
OneMinusSourceOneColor,

/// Multiply the source or destination component by the alpha value of source index 1.
SourceOneAlpha,

/// Multiply the source or destination component by `1.0` minus the alpha value of source index 1.
OneMinusSourceOneAlpha,
}

impl LinearBlendingFactor {
Expand All @@ -198,6 +214,11 @@ impl LinearBlendingFactor {
LinearBlendingFactor::OneMinusConstantColor => gl::ONE_MINUS_CONSTANT_COLOR,
LinearBlendingFactor::ConstantAlpha => gl::CONSTANT_ALPHA,
LinearBlendingFactor::OneMinusConstantAlpha => gl::ONE_MINUS_CONSTANT_ALPHA,
LinearBlendingFactor::SourceOneColor => gl::SRC1_COLOR,
LinearBlendingFactor::OneMinusSourceOneColor => gl::ONE_MINUS_SRC1_COLOR,
LinearBlendingFactor::SourceOneAlpha => gl::SRC1_ALPHA,
LinearBlendingFactor::OneMinusSourceOneAlpha => gl::ONE_MINUS_SRC1_ALPHA,

}
}
}
Expand Down