mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Implementation of masks (double texturing ImageShader) for sources.
This commit is contained in:
@@ -238,7 +238,14 @@ set(VMIX_RSC_FILES
|
|||||||
./rsc/fonts/Roboto-Italic.ttf
|
./rsc/fonts/Roboto-Italic.ttf
|
||||||
./rsc/fonts/fa-regular-400.ttf
|
./rsc/fonts/fa-regular-400.ttf
|
||||||
./rsc/fonts/fa-solid-900.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/v-mix_256x256.png
|
||||||
./rsc/images/rgb.png
|
./rsc/images/rgb.png
|
||||||
./rsc/images/busy.png
|
./rsc/images/busy.png
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
#include "ImGuiVisitor.h"
|
#include "ImGuiVisitor.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
#include <glm/gtc/constants.hpp>
|
#include <glm/gtc/constants.hpp>
|
||||||
@@ -133,7 +136,25 @@ void ImGuiVisitor::visit(Shader &n)
|
|||||||
|
|
||||||
void ImGuiVisitor::visit(ImageShader &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)
|
void ImGuiVisitor::visit(ImageProcessingShader &n)
|
||||||
|
|||||||
@@ -7,9 +7,26 @@
|
|||||||
|
|
||||||
ShadingProgram imageShadingProgram("shaders/image.vs", "shaders/image.fs");
|
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()
|
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;
|
program_ = &imageShadingProgram;
|
||||||
|
// reset instance
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +54,7 @@ void ImageShader::reset()
|
|||||||
program_->enduse();
|
program_->enduse();
|
||||||
|
|
||||||
// default mask (channel1)
|
// default mask (channel1)
|
||||||
mask = Resource::getTextureWhite();
|
mask = mask_presets[0];
|
||||||
|
|
||||||
// no stippling
|
// no stippling
|
||||||
stipple = 0.f;
|
stipple = 0.f;
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#ifndef IMAGESHADER_H
|
#ifndef IMAGESHADER_H
|
||||||
#define IMAGESHADER_H
|
#define IMAGESHADER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "Shader.h"
|
#include "Shader.h"
|
||||||
|
|
||||||
class ImageShader : public Shader
|
class ImageShader : public Shader
|
||||||
@@ -14,8 +17,12 @@ public:
|
|||||||
void reset() override;
|
void reset() override;
|
||||||
void accept(Visitor& v) override;
|
void accept(Visitor& v) override;
|
||||||
|
|
||||||
|
|
||||||
uint mask;
|
uint mask;
|
||||||
float stipple;
|
float stipple;
|
||||||
|
|
||||||
|
static const char* mask_names[];
|
||||||
|
static std::vector< uint > mask_presets;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IMAGESHADER_H
|
#endif // IMAGESHADER_H
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ void MediaSource::init()
|
|||||||
(*node)->scale_.x = mediaplayer_->aspectRatio();
|
(*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
|
// done init once and for all
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
|
|||||||
BIN
rsc/images/mask_circle.dds
Normal file
BIN
rsc/images/mask_circle.dds
Normal file
Binary file not shown.
BIN
rsc/images/mask_halo.dds
Normal file
BIN
rsc/images/mask_halo.dds
Normal file
Binary file not shown.
BIN
rsc/images/mask_linear_bottom.dds
Normal file
BIN
rsc/images/mask_linear_bottom.dds
Normal file
Binary file not shown.
BIN
rsc/images/mask_linear_left.dds
Normal file
BIN
rsc/images/mask_linear_left.dds
Normal file
Binary file not shown.
BIN
rsc/images/mask_linear_right.dds
Normal file
BIN
rsc/images/mask_linear_right.dds
Normal file
Binary file not shown.
BIN
rsc/images/mask_linear_top.dds
Normal file
BIN
rsc/images/mask_linear_top.dds
Normal file
Binary file not shown.
BIN
rsc/images/mask_roundcorner.dds
Normal file
BIN
rsc/images/mask_roundcorner.dds
Normal file
Binary file not shown.
BIN
rsc/images/mask_vignette.dds
Normal file
BIN
rsc/images/mask_vignette.dds
Normal file
Binary file not shown.
Reference in New Issue
Block a user