Implementation of masks (double texturing ImageShader) for sources.

This commit is contained in:
brunoherbelin
2020-04-27 19:40:08 +02:00
parent d248df0567
commit 6b30674254
13 changed files with 55 additions and 3 deletions

View File

@@ -238,7 +238,14 @@ set(VMIX_RSC_FILES
./rsc/fonts/Roboto-Italic.ttf
./rsc/fonts/fa-regular-400.ttf
./rsc/fonts/fa-solid-900.ttf
./rsc/images/mask_vignette.png
./rsc/images/mask_vignette.dds
./rsc/images/mask_halo.dds
./rsc/images/mask_circle.dds
./rsc/images/mask_roundcorner.dds
./rsc/images/mask_linear_top.dds
./rsc/images/mask_linear_bottom.dds
./rsc/images/mask_linear_left.dds
./rsc/images/mask_linear_right.dds
./rsc/images/v-mix_256x256.png
./rsc/images/rgb.png
./rsc/images/busy.png

View File

@@ -1,5 +1,8 @@
#include "ImGuiVisitor.h"
#include <vector>
#include <algorithm>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/constants.hpp>
@@ -133,7 +136,25 @@ void ImGuiVisitor::visit(Shader &n)
void ImGuiVisitor::visit(ImageShader &n)
{
ImGui::PushID(n.id());
// get index of the mask used in this ImageShader
int item_current = 9; // default to Custom mask (i.e. not in the list)
auto it{ find(ImageShader::mask_presets.begin(), ImageShader::mask_presets.end(), n.mask) };
if ( it != std::end(ImageShader::mask_presets)) {
item_current = std::distance(ImageShader::mask_presets.begin(), it);
}
if (ImGuiToolkit::ButtonIcon(10, 3)) n.mask = ImageShader::mask_presets[0];;
ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(RIGHT_ALIGN);
// combo list of masks
if ( ImGui::Combo("Mask", &item_current, ImageShader::mask_names, ImageShader::mask_presets.size()) )
{
n.mask = ImageShader::mask_presets[item_current];
}
ImGui::PopID();
}
void ImGuiVisitor::visit(ImageProcessingShader &n)

View File

@@ -7,9 +7,26 @@
ShadingProgram imageShadingProgram("shaders/image.vs", "shaders/image.fs");
const char* ImageShader::mask_names[10] = { "None", "Vignette", "Halo", "Circle", "Round", "Top", "Botton", "Left", "Right", "Custom" };
std::vector< uint > ImageShader::mask_presets;
ImageShader::ImageShader()
{
// first initialization
if ( mask_presets.empty() ) {
mask_presets.push_back(Resource::getTextureWhite());
mask_presets.push_back(Resource::getTextureDDS("images/mask_vignette.dds"));
mask_presets.push_back(Resource::getTextureDDS("images/mask_halo.dds"));
mask_presets.push_back(Resource::getTextureDDS("images/mask_circle.dds"));
mask_presets.push_back(Resource::getTextureDDS("images/mask_roundcorner.dds"));
mask_presets.push_back(Resource::getTextureDDS("images/mask_linear_top.dds"));
mask_presets.push_back(Resource::getTextureDDS("images/mask_linear_bottom.dds"));
mask_presets.push_back(Resource::getTextureDDS("images/mask_linear_left.dds"));
mask_presets.push_back(Resource::getTextureDDS("images/mask_linear_right.dds"));
}
// static program shader
program_ = &imageShadingProgram;
// reset instance
reset();
}
@@ -37,7 +54,7 @@ void ImageShader::reset()
program_->enduse();
// default mask (channel1)
mask = Resource::getTextureWhite();
mask = mask_presets[0];
// no stippling
stipple = 0.f;

View File

@@ -1,6 +1,9 @@
#ifndef IMAGESHADER_H
#define IMAGESHADER_H
#include <string>
#include <map>
#include "Shader.h"
class ImageShader : public Shader
@@ -14,8 +17,12 @@ public:
void reset() override;
void accept(Visitor& v) override;
uint mask;
float stipple;
static const char* mask_names[];
static std::vector< uint > mask_presets;
};
#endif // IMAGESHADER_H

View File

@@ -206,7 +206,7 @@ void MediaSource::init()
(*node)->scale_.x = mediaplayer_->aspectRatio();
}
// mixingshader_->mask = Resource::getTextureImage("images/mask_vignette.png");
// mixingshader_->mask = ImageShader::mask_presets["Halo"];
// done init once and for all
initialized_ = true;

BIN
rsc/images/mask_circle.dds Normal file

Binary file not shown.

BIN
rsc/images/mask_halo.dds Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.