New Blending with pre-multiplied alpha

Finally found how to improve blending modes by pre-multiplying color by alpha in the shader, so that the blending equations can be applied on top of the apha manipulation.
This commit is contained in:
Bruno
2021-02-18 23:36:01 +01:00
parent 64071a4a55
commit f51bc1f1f4
7 changed files with 61 additions and 25 deletions

View File

@@ -171,7 +171,7 @@ void ImGuiVisitor::visit(Shader &n)
// ImGui::SameLine(0, 5);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
int mode = n.blending;
if (ImGui::Combo("Blending", &mode, "Normal\0Screen\0Inverse\0Addition\0Subtract\0") ) {
if (ImGui::Combo("Blending", &mode, "Normal\0Screen\0Subtract\0Multiply\0Soft light\0Soft subtract\0") ) {
n.blending = Shader::BlendMode(mode);
std::ostringstream oss;
@@ -180,18 +180,21 @@ void ImGuiVisitor::visit(Shader &n)
case Shader::BLEND_OPACITY:
oss<<"Normal";
break;
case Shader::BLEND_ADD:
case Shader::BLEND_SCREEN:
oss<<"Screen";
break;
case Shader::BLEND_SUBSTRACT:
oss<<"Inverse";
break;
case Shader::BLEND_LAYER_ADD:
oss<<"Addition";
break;
case Shader::BLEND_LAYER_SUBSTRACT:
oss<<"Subtract";
break;
case Shader::BLEND_MULTIPLY:
oss<<"Multiply";
break;
case Shader::BLEND_SOFT_LIGHT:
oss<<"Soft light";
break;
case Shader::BLEND_SOFT_SUBTRACT:
oss<<"Soft subtract";
break;
case Shader::BLEND_CUSTOM:
oss<<"Custom";
break;