New blending: hard light

This commit is contained in:
brunoherbelin
2021-02-22 18:26:14 +01:00
parent 27112a2b57
commit 4093170599
3 changed files with 17 additions and 9 deletions

View File

@@ -171,7 +171,8 @@ void ImGuiVisitor::visit(Shader &n)
// ImGui::SameLine(0, 5); // ImGui::SameLine(0, 5);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
int mode = n.blending; int mode = n.blending;
if (ImGui::Combo("Blending", &mode, "Normal\0Screen\0Subtract\0Multiply\0Soft light\0Soft subtract\0Lighten only\0None\0") ) { if (ImGui::Combo("Blending", &mode, "Normal\0Screen\0Subtract\0Multiply\0Soft light"
"\0Hard light\0Soft subtract\0Lighten only\0") ) {
n.blending = Shader::BlendMode(mode); n.blending = Shader::BlendMode(mode);
std::ostringstream oss; std::ostringstream oss;
@@ -189,6 +190,9 @@ void ImGuiVisitor::visit(Shader &n)
case Shader::BLEND_MULTIPLY: case Shader::BLEND_MULTIPLY:
oss<<"Multiply"; oss<<"Multiply";
break; break;
case Shader::BLEND_HARD_LIGHT:
oss<<"Hard light";
break;
case Shader::BLEND_SOFT_LIGHT: case Shader::BLEND_SOFT_LIGHT:
oss<<"Soft light"; oss<<"Soft light";
break; break;

View File

@@ -24,27 +24,30 @@ ShadingProgram *ShadingProgram::currentProgram_ = nullptr;
ShadingProgram simpleShadingProgram("shaders/simple.vs", "shaders/simple.fs"); ShadingProgram simpleShadingProgram("shaders/simple.vs", "shaders/simple.fs");
// Blending presets for matching with Shader::BlendModes: // Blending presets for matching with Shader::BlendModes:
GLenum blending_equation[8] = { GL_FUNC_ADD, // normal GLenum blending_equation[9] = { GL_FUNC_ADD, // normal
GL_FUNC_ADD, // screen GL_FUNC_ADD, // screen
GL_FUNC_REVERSE_SUBTRACT, // subtract GL_FUNC_REVERSE_SUBTRACT, // subtract
GL_FUNC_ADD, // multiply GL_FUNC_ADD, // multiply
GL_FUNC_ADD, // soft light GL_FUNC_ADD, // soft light
GL_FUNC_ADD, // hard light
GL_FUNC_REVERSE_SUBTRACT, // soft subtract GL_FUNC_REVERSE_SUBTRACT, // soft subtract
GL_MAX, // lighten only GL_MAX, // lighten only
GL_FUNC_ADD}; GL_FUNC_ADD};
GLenum blending_source_function[8] = { GL_ONE, // normal GLenum blending_source_function[9] = { GL_ONE, // normal
GL_ONE, // screen GL_ONE, // screen
GL_SRC_COLOR, // subtract (can be GL_ONE) GL_SRC_COLOR, // subtract (can be GL_ONE)
GL_DST_COLOR, // multiply : src x dst color GL_DST_COLOR, // multiply : src x dst color
GL_DST_COLOR, // soft light : src x dst color GL_DST_COLOR, // soft light : src x dst color
GL_SRC_COLOR, // hard light : src x src color
GL_DST_COLOR, // soft subtract GL_DST_COLOR, // soft subtract
GL_ONE, // lighten only GL_ONE, // lighten only
GL_ONE}; GL_ONE};
GLenum blending_destination_function[8] = {GL_ONE_MINUS_SRC_ALPHA,// normal GLenum blending_destination_function[9] = {GL_ONE_MINUS_SRC_ALPHA,// normal
GL_ONE, // screen GL_ONE, // screen
GL_ONE, // subtract GL_ONE, // subtract
GL_ONE_MINUS_SRC_ALPHA, // multiply GL_ONE_MINUS_SRC_ALPHA, // multiply
GL_ONE, // soft light GL_ONE, // soft light
GL_ONE, // hard light
GL_ONE, // soft subtract GL_ONE, // soft subtract
GL_ONE, // lighten only GL_ONE, // lighten only
GL_ZERO}; GL_ZERO};

View File

@@ -64,6 +64,7 @@ public:
BLEND_SUBTRACT, BLEND_SUBTRACT,
BLEND_MULTIPLY, BLEND_MULTIPLY,
BLEND_SOFT_LIGHT, BLEND_SOFT_LIGHT,
BLEND_HARD_LIGHT,
BLEND_SOFT_SUBTRACT, BLEND_SOFT_SUBTRACT,
BLEND_LIGHTEN_ONLY, BLEND_LIGHTEN_ONLY,
BLEND_NONE BLEND_NONE