mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Operational implementation of UV texture coordinates changes in
Appearance View.
This commit is contained in:
@@ -65,6 +65,8 @@ void FrameBuffer::init()
|
|||||||
use_alpha_ ? GL_RGBA8 : GL_RGB8, attrib_.viewport.x, attrib_.viewport.y, GL_TRUE);
|
use_alpha_ ? GL_RGBA8 : GL_RGB8, attrib_.viewport.x, attrib_.viewport.y, GL_TRUE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
|
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
|
||||||
|
|
||||||
// attach the multisampled texture to FBO (framebufferid_ currently binded)
|
// attach the multisampled texture to FBO (framebufferid_ currently binded)
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ const char* ImageProcessingShader::filter_names[12] = { "None", "Blur", "Sharpen
|
|||||||
"Erosion 3x3", "Erosion 5x5", "Erosion 7x7", "Dilation 3x3", "Dilation 5x5", "Dilation 7x7" };
|
"Erosion 3x3", "Erosion 5x5", "Erosion 7x7", "Dilation 3x3", "Dilation 5x5", "Dilation 7x7" };
|
||||||
|
|
||||||
|
|
||||||
ImageProcessingShader::ImageProcessingShader()
|
ImageProcessingShader::ImageProcessingShader(): Shader()
|
||||||
{
|
{
|
||||||
program_ = &imageProcessingShadingProgram;
|
program_ = &imageProcessingShadingProgram;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageProcessingShader::ImageProcessingShader(const ImageProcessingShader &S)
|
ImageProcessingShader::ImageProcessingShader(const ImageProcessingShader &S): Shader()
|
||||||
{
|
{
|
||||||
program_ = &imageProcessingShadingProgram;
|
program_ = &imageProcessingShadingProgram;
|
||||||
reset();
|
reset();
|
||||||
@@ -38,8 +38,6 @@ void ImageProcessingShader::use()
|
|||||||
{
|
{
|
||||||
Shader::use();
|
Shader::use();
|
||||||
|
|
||||||
// program_->setUniform("iChannelResolution[0]", iChannelResolution[0].x, iChannelResolution[0].y, iChannelResolution[0].z);
|
|
||||||
|
|
||||||
program_->setUniform("brightness", brightness);
|
program_->setUniform("brightness", brightness);
|
||||||
program_->setUniform("contrast", contrast);
|
program_->setUniform("contrast", contrast);
|
||||||
program_->setUniform("saturation", saturation);
|
program_->setUniform("saturation", saturation);
|
||||||
@@ -63,9 +61,6 @@ void ImageProcessingShader::reset()
|
|||||||
{
|
{
|
||||||
Shader::reset();
|
Shader::reset();
|
||||||
|
|
||||||
// // no texture resolution yet
|
|
||||||
// iChannelResolution[0] = glm::vec3(1.f);
|
|
||||||
|
|
||||||
// default values for image processing
|
// default values for image processing
|
||||||
brightness = 0.f;
|
brightness = 0.f;
|
||||||
contrast = 0.f;
|
contrast = 0.f;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
#include "Shader.h"
|
#include "ImageShader.h"
|
||||||
|
|
||||||
|
|
||||||
class ImageProcessingShader : public Shader
|
class ImageProcessingShader : public Shader
|
||||||
@@ -19,9 +19,6 @@ public:
|
|||||||
|
|
||||||
void operator = (const ImageProcessingShader &S);
|
void operator = (const ImageProcessingShader &S);
|
||||||
|
|
||||||
// // textures resolution
|
|
||||||
// glm::vec3 iChannelResolution[1];
|
|
||||||
|
|
||||||
// color effects
|
// color effects
|
||||||
float brightness; // [-1 1]
|
float brightness; // [-1 1]
|
||||||
float contrast; // [-1 1]
|
float contrast; // [-1 1]
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ static ShadingProgram imageShadingProgram("shaders/image.vs", "shaders/image.fs"
|
|||||||
const char* ImageShader::mask_names[11] = { "None", "Glow", "Halo", "Circle", "Round", "Vignette", "Top", "Botton", "Left", "Right", "Custom" };
|
const char* ImageShader::mask_names[11] = { "None", "Glow", "Halo", "Circle", "Round", "Vignette", "Top", "Botton", "Left", "Right", "Custom" };
|
||||||
std::vector< uint > ImageShader::mask_presets;
|
std::vector< uint > ImageShader::mask_presets;
|
||||||
|
|
||||||
ImageShader::ImageShader(): Shader(), mask(0), custom_textureindex(0), stipple(0.0), uv(0.0, 0.0, 1.0, 1.0)
|
ImageShader::ImageShader(): Shader(), mask(0), custom_textureindex(0), stipple(0.0)
|
||||||
{
|
{
|
||||||
// first initialization
|
// first initialization
|
||||||
if ( mask_presets.empty() ) {
|
if ( mask_presets.empty() ) {
|
||||||
@@ -36,20 +36,16 @@ void ImageShader::use()
|
|||||||
Shader::use();
|
Shader::use();
|
||||||
|
|
||||||
program_->setUniform("stipple", stipple);
|
program_->setUniform("stipple", stipple);
|
||||||
program_->setUniform("uv", uv);
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
if ( mask < 10 ) {
|
if ( mask < 10 )
|
||||||
glBindTexture(GL_TEXTURE_2D, mask_presets[mask]);
|
glBindTexture(GL_TEXTURE_2D, mask_presets[mask]);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
glBindTexture(GL_TEXTURE_2D, custom_textureindex);
|
glBindTexture(GL_TEXTURE_2D, custom_textureindex);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,9 +58,6 @@ void ImageShader::reset()
|
|||||||
custom_textureindex = mask_presets[0];
|
custom_textureindex = mask_presets[0];
|
||||||
// no stippling
|
// no stippling
|
||||||
stipple = 0.f;
|
stipple = 0.f;
|
||||||
// normal uv
|
|
||||||
uv = glm::vec4(0.0, 0.0, 1.0, 1.0);
|
|
||||||
// uv = glm::vec4(0.0, 0.0, 2.0, 2.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageShader::operator = (const ImageShader &S )
|
void ImageShader::operator = (const ImageShader &S )
|
||||||
@@ -74,7 +67,6 @@ void ImageShader::operator = (const ImageShader &S )
|
|||||||
mask = S.mask;
|
mask = S.mask;
|
||||||
custom_textureindex = S.custom_textureindex;
|
custom_textureindex = S.custom_textureindex;
|
||||||
stipple = S.stipple;
|
stipple = S.stipple;
|
||||||
uv = S.uv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ public:
|
|||||||
uint mask;
|
uint mask;
|
||||||
uint custom_textureindex;
|
uint custom_textureindex;
|
||||||
float stipple;
|
float stipple;
|
||||||
glm::vec4 uv;
|
|
||||||
|
|
||||||
static const char* mask_names[11];
|
static const char* mask_names[11];
|
||||||
static std::vector< uint > mask_presets;
|
static std::vector< uint > mask_presets;
|
||||||
|
|||||||
@@ -617,6 +617,8 @@ void MediaPlayer::init_texture(guint index)
|
|||||||
GL_RGBA, GL_UNSIGNED_BYTE, frame_[index].vframe.data[0]);
|
GL_RGBA, GL_UNSIGNED_BYTE, frame_[index].vframe.data[0]);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
if (!media_.isimage) {
|
if (!media_.isimage) {
|
||||||
|
|
||||||
|
|||||||
@@ -85,8 +85,16 @@ void Surface::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
if ( !initialized() )
|
if ( !initialized() )
|
||||||
init();
|
init();
|
||||||
|
|
||||||
if ( textureindex_ )
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
if ( textureindex_ ) {
|
||||||
glBindTexture(GL_TEXTURE_2D, textureindex_);
|
glBindTexture(GL_TEXTURE_2D, textureindex_);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
|
||||||
|
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // TODO add user input to select mode
|
||||||
|
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
glBindTexture(GL_TEXTURE_2D, Resource::getTextureBlack());
|
glBindTexture(GL_TEXTURE_2D, Resource::getTextureBlack());
|
||||||
|
|
||||||
@@ -97,15 +105,14 @@ void Surface::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
|
|
||||||
void Surface::setTextureUV(glm::vec4 uv)
|
void Surface::setTextureUV(glm::vec4 uv)
|
||||||
{
|
{
|
||||||
dynamic_cast<ImageShader*>(shader_)->uv = uv;
|
shader_->uv = uv;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec4 Surface::textureUV() const
|
glm::vec4 Surface::textureUV() const
|
||||||
{
|
{
|
||||||
return dynamic_cast<ImageShader*>(shader_)->uv;
|
return shader_->uv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ImageSurface::ImageSurface(const std::string& path, Shader *s) : Surface(s), resource_(path)
|
ImageSurface::ImageSurface(const std::string& path, Shader *s) : Surface(s), resource_(path)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
14
Resource.cpp
14
Resource.cpp
@@ -33,6 +33,10 @@ uint Resource::getTextureBlack()
|
|||||||
if (tex_index_black == 0) {
|
if (tex_index_black == 0) {
|
||||||
glGenTextures(1, &tex_index_black);
|
glGenTextures(1, &tex_index_black);
|
||||||
glBindTexture( GL_TEXTURE_2D, tex_index_black);
|
glBindTexture( GL_TEXTURE_2D, tex_index_black);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
unsigned char clearColor[4] = {0, 0, 0, 255};
|
unsigned char clearColor[4] = {0, 0, 0, 255};
|
||||||
// texture with one black pixel
|
// texture with one black pixel
|
||||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
|
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
|
||||||
@@ -50,6 +54,10 @@ uint Resource::getTextureWhite()
|
|||||||
if (tex_index_white == 0) {
|
if (tex_index_white == 0) {
|
||||||
glGenTextures(1, &tex_index_white);
|
glGenTextures(1, &tex_index_white);
|
||||||
glBindTexture( GL_TEXTURE_2D, tex_index_white);
|
glBindTexture( GL_TEXTURE_2D, tex_index_white);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
unsigned char clearColor[4] = {255, 255, 255, 255};
|
unsigned char clearColor[4] = {255, 255, 255, 255};
|
||||||
// texture with one black pixel
|
// texture with one black pixel
|
||||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
|
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
|
||||||
@@ -67,6 +75,10 @@ uint Resource::getTextureTransparent()
|
|||||||
if (tex_index_transparent == 0) {
|
if (tex_index_transparent == 0) {
|
||||||
glGenTextures(1, &tex_index_transparent);
|
glGenTextures(1, &tex_index_transparent);
|
||||||
glBindTexture( GL_TEXTURE_2D, tex_index_transparent);
|
glBindTexture( GL_TEXTURE_2D, tex_index_transparent);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
unsigned char clearColor[4] = {0, 0, 0, 0};
|
unsigned char clearColor[4] = {0, 0, 0, 0};
|
||||||
// texture with one black pixel
|
// texture with one black pixel
|
||||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
|
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 1);
|
||||||
@@ -265,6 +277,8 @@ uint Resource::getTextureImage(const std::string& path, float *aspect_ratio)
|
|||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, img);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, img);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
// free memory
|
// free memory
|
||||||
stbi_image_free(img);
|
stbi_image_free(img);
|
||||||
|
|||||||
@@ -431,9 +431,9 @@ void SessionLoader::visit(ImageShader &n)
|
|||||||
uniforms->QueryUnsignedAttribute("mask", &n.mask);
|
uniforms->QueryUnsignedAttribute("mask", &n.mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLElement* uvtex = xmlCurrent_->FirstChildElement("uv");
|
// XMLElement* uvtex = xmlCurrent_->FirstChildElement("uv");
|
||||||
if (uvtex)
|
// if (uvtex)
|
||||||
tinyxml2::XMLElementToGLM( uvtex->FirstChildElement("vec4"), n.uv);
|
// tinyxml2::XMLElementToGLM( uvtex->FirstChildElement("vec4"), n.uv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionLoader::visit(ImageProcessingShader &n)
|
void SessionLoader::visit(ImageProcessingShader &n)
|
||||||
|
|||||||
@@ -202,9 +202,9 @@ void SessionVisitor::visit(ImageShader &n)
|
|||||||
uniforms->SetAttribute("mask", n.mask);
|
uniforms->SetAttribute("mask", n.mask);
|
||||||
xmlCurrent_->InsertEndChild(uniforms);
|
xmlCurrent_->InsertEndChild(uniforms);
|
||||||
|
|
||||||
XMLElement *uvtex = xmlDoc_->NewElement("uv");
|
// XMLElement *uvtex = xmlDoc_->NewElement("uv");
|
||||||
uvtex->InsertEndChild( XMLElementFromGLM(xmlDoc_, n.uv) );
|
// uvtex->InsertEndChild( XMLElementFromGLM(xmlDoc_, n.uv) );
|
||||||
xmlCurrent_->InsertEndChild(uvtex);
|
// xmlCurrent_->InsertEndChild(uvtex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,6 +186,7 @@ void Shader::operator = (const Shader &S )
|
|||||||
{
|
{
|
||||||
color = S.color;
|
color = S.color;
|
||||||
blending = S.blending;
|
blending = S.blending;
|
||||||
|
uv = S.uv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shader::accept(Visitor& v) {
|
void Shader::accept(Visitor& v) {
|
||||||
@@ -205,6 +206,7 @@ void Shader::use()
|
|||||||
program_->setUniform("projection", projection);
|
program_->setUniform("projection", projection);
|
||||||
program_->setUniform("modelview", modelview);
|
program_->setUniform("modelview", modelview);
|
||||||
program_->setUniform("color", color);
|
program_->setUniform("color", color);
|
||||||
|
program_->setUniform("uv", uv);
|
||||||
|
|
||||||
iResolution = glm::vec3( Rendering::manager().currentAttrib().viewport, 0.f);
|
iResolution = glm::vec3( Rendering::manager().currentAttrib().viewport, 0.f);
|
||||||
program_->setUniform("iResolution", iResolution);
|
program_->setUniform("iResolution", iResolution);
|
||||||
@@ -237,6 +239,7 @@ void Shader::reset()
|
|||||||
modelview = glm::identity<glm::mat4>();
|
modelview = glm::identity<glm::mat4>();
|
||||||
iResolution = glm::vec3(1280.f, 720.f, 0.f);
|
iResolution = glm::vec3(1280.f, 720.f, 0.f);
|
||||||
color = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
color = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||||
|
uv = glm::vec4(0.0, 0.0, 1.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1
Shader.h
1
Shader.h
@@ -55,6 +55,7 @@ public:
|
|||||||
glm::mat4 projection;
|
glm::mat4 projection;
|
||||||
glm::mat4 modelview;
|
glm::mat4 modelview;
|
||||||
glm::vec4 color;
|
glm::vec4 color;
|
||||||
|
glm::vec4 uv;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BLEND_OPACITY = 0,
|
BLEND_OPACITY = 0,
|
||||||
|
|||||||
23
Source.cpp
23
Source.cpp
@@ -434,18 +434,19 @@ void Source::update(float dt)
|
|||||||
groups_[View::RENDERING]->translation_.z = groups_[View::LAYER]->translation_.z;
|
groups_[View::RENDERING]->translation_.z = groups_[View::LAYER]->translation_.z;
|
||||||
|
|
||||||
// MODIFY texture projection based on APPEARANCE node
|
// MODIFY texture projection based on APPEARANCE node
|
||||||
texturesurface_->translation_.x = groups_[View::APPEARANCE]->translation_.x;
|
glm::vec3 center = groups_[View::APPEARANCE]->translation_;
|
||||||
if (renderbuffer_)
|
if (renderbuffer_)
|
||||||
texturesurface_->translation_.x /= renderbuffer_->aspectRatio();
|
center.x /= renderbuffer_->aspectRatio();
|
||||||
texturesurface_->translation_.y = groups_[View::APPEARANCE]->translation_.y;
|
glm::vec3 UL = glm::vec3(-1.f, 1.f, 0.f) - center;
|
||||||
texturesurface_->rotation_.z = groups_[View::APPEARANCE]->rotation_.z;
|
glm::vec3 BR = glm::vec3(1.f, -1.f, 0.f) - center;
|
||||||
// avoid any null scale
|
UL /= groups_[View::APPEARANCE]->scale_;
|
||||||
s = groups_[View::APPEARANCE]->scale_;
|
BR /= groups_[View::APPEARANCE]->scale_;
|
||||||
s.x = CLAMP_SCALE(s.x);
|
glm::vec4 uv;
|
||||||
s.y = CLAMP_SCALE(s.y);
|
uv.x = UL.x * 0.5f + 0.5f;
|
||||||
s.z = 1.f;
|
uv.y = UL.y * -0.5f + 0.5f;
|
||||||
texturesurface_->scale_ = s;
|
uv.z = BR.x * 0.5f + 0.5f;
|
||||||
texturesurface_->update(dt);
|
uv.w = BR.y * -0.5f + 0.5f;
|
||||||
|
texturesurface_->setTextureUV(uv);
|
||||||
|
|
||||||
need_update_ = false;
|
need_update_ = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -365,7 +365,8 @@ void Stream::init_texture(guint index)
|
|||||||
GL_RGBA, GL_UNSIGNED_BYTE, frame_[index].vframe.data[0]);
|
GL_RGBA, GL_UNSIGNED_BYTE, frame_[index].vframe.data[0]);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
// set pbo image size
|
// set pbo image size
|
||||||
pbo_size_ = height_ * width_ * 4;
|
pbo_size_ = height_ * width_ * 4;
|
||||||
|
|||||||
37
View.cpp
37
View.cpp
@@ -604,6 +604,8 @@ uint MixingView::textureMixingQuadratic()
|
|||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, CIRCLE_PIXELS, CIRCLE_PIXELS, GL_BGRA, GL_UNSIGNED_BYTE, matrix);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, CIRCLE_PIXELS, CIRCLE_PIXELS, GL_BGRA, GL_UNSIGNED_BYTE, matrix);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
}
|
}
|
||||||
return texid;
|
return texid;
|
||||||
@@ -1836,41 +1838,6 @@ void AppearanceView::draw()
|
|||||||
|
|
||||||
View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair<Node *, glm::vec2> pick)
|
View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair<Node *, glm::vec2> pick)
|
||||||
{
|
{
|
||||||
// View::Cursor ret = Cursor();
|
|
||||||
// std::ostringstream info;
|
|
||||||
|
|
||||||
// // work on the given source
|
|
||||||
// if (!s)
|
|
||||||
// return ret;
|
|
||||||
|
|
||||||
// Group *sourceNode = s->group(mode_); // groups_[View::APPEARANCE]
|
|
||||||
|
|
||||||
// // grab coordinates in scene-View reference frame
|
|
||||||
// glm::vec3 scene_from = Rendering::manager().unProject(from, scene.root()->transform_);
|
|
||||||
// glm::vec3 scene_to = Rendering::manager().unProject(to, scene.root()->transform_);
|
|
||||||
// glm::vec3 scene_translation = scene_to - scene_from;
|
|
||||||
|
|
||||||
// // make sure matrix transform of stored status is updated
|
|
||||||
// s->stored_status_->update(0);
|
|
||||||
|
|
||||||
// ret.type = Cursor_ResizeAll;
|
|
||||||
// info << "UV " ;
|
|
||||||
|
|
||||||
// sourceNode->translation_ = s->stored_status_->translation_ + scene_translation;
|
|
||||||
|
|
||||||
//// ImageShader *shader = s->blendingShader ();
|
|
||||||
//// shader->uv.x += scene_translation.x;
|
|
||||||
//// shader->uv.y += scene_translation.y;
|
|
||||||
//// shader->uv.z += scene_translation.x;
|
|
||||||
//// shader->uv.w += scene_translation.y;
|
|
||||||
|
|
||||||
|
|
||||||
// // request update
|
|
||||||
// s->touch();
|
|
||||||
|
|
||||||
// // update cursor
|
|
||||||
// ret.info = info.str();
|
|
||||||
// return ret;
|
|
||||||
View::Cursor ret = Cursor();
|
View::Cursor ret = Cursor();
|
||||||
|
|
||||||
// work on the given source
|
// work on the given source
|
||||||
|
|||||||
@@ -5,13 +5,15 @@ out vec4 FragColor;
|
|||||||
in vec4 vertexColor;
|
in vec4 vertexColor;
|
||||||
in vec2 vertexUV;
|
in vec2 vertexUV;
|
||||||
|
|
||||||
|
// from General Shader
|
||||||
|
uniform vec3 iResolution; // viewport resolution (in pixels)
|
||||||
|
uniform vec4 color;
|
||||||
|
uniform vec4 uv;
|
||||||
|
|
||||||
|
// Image Shader
|
||||||
uniform sampler2D iChannel0; // input channel (texture id).
|
uniform sampler2D iChannel0; // input channel (texture id).
|
||||||
uniform sampler2D iChannel1; // input mask
|
uniform sampler2D iChannel1; // input mask
|
||||||
uniform vec3 iResolution; // viewport resolution (in pixels)
|
|
||||||
|
|
||||||
uniform vec4 color;
|
|
||||||
uniform float stipple;
|
uniform float stipple;
|
||||||
uniform vec4 uv;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|||||||
36
rsc/shaders/imageblending.fs
Normal file
36
rsc/shaders/imageblending.fs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
in vec4 vertexColor;
|
||||||
|
in vec2 vertexUV;
|
||||||
|
|
||||||
|
// from General Shader
|
||||||
|
uniform vec3 iResolution; // viewport resolution (in pixels)
|
||||||
|
uniform vec4 color;
|
||||||
|
uniform vec4 uv;
|
||||||
|
|
||||||
|
// Image Shader
|
||||||
|
uniform sampler2D iChannel0; // input channel (texture id).
|
||||||
|
uniform sampler2D iChannel1; // input mask
|
||||||
|
uniform float stipple;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// adjust UV
|
||||||
|
vec2 texcoord = vec2(uv.x, uv.y) + vertexUV * vec2(uv.z - uv.x, uv.w - uv.y);
|
||||||
|
|
||||||
|
// color is a mix of texture (manipulated with brightness & contrast), vertex and uniform colors
|
||||||
|
vec4 textureColor = texture(iChannel0, texcoord);
|
||||||
|
vec3 RGB = textureColor.rgb * vertexColor.rgb * color.rgb;
|
||||||
|
|
||||||
|
// alpha is a mix of texture alpha, vertex alpha, and uniform alpha affected by stippling
|
||||||
|
vec4 maskColor = texture(iChannel1, vertexUV);
|
||||||
|
float maskIntensity = (maskColor.r + maskColor.g + maskColor.b) / 3.0;
|
||||||
|
|
||||||
|
float A = textureColor.a * vertexColor.a * color.a * maskIntensity;
|
||||||
|
A -= stipple * ( int(gl_FragCoord.x + gl_FragCoord.y) % 2 > 0 ? 0.05 : 0.95 );
|
||||||
|
|
||||||
|
// output RGBA
|
||||||
|
FragColor = vec4(RGB, clamp(A, 0.0, 1.0) );
|
||||||
|
}
|
||||||
@@ -25,14 +25,17 @@ out vec4 FragColor;
|
|||||||
in vec4 vertexColor;
|
in vec4 vertexColor;
|
||||||
in vec2 vertexUV;
|
in vec2 vertexUV;
|
||||||
|
|
||||||
// general shader uniforms
|
vec2 texcoord;
|
||||||
uniform vec4 color;
|
|
||||||
|
|
||||||
// image processing specific
|
// image processing specific
|
||||||
uniform sampler2D iChannel0; // input channel (texture id).
|
uniform sampler2D iChannel0; // input channel (texture id).
|
||||||
//uniform vec3 iChannelResolution[1]; // replaced by textureSize(iChannel0, 0);
|
|
||||||
uniform vec3 iResolution; // viewport resolution (in pixels)
|
uniform vec3 iResolution; // viewport resolution (in pixels)
|
||||||
|
|
||||||
|
// Image shader uniforms
|
||||||
|
uniform vec4 color;
|
||||||
|
uniform vec4 uv;
|
||||||
|
|
||||||
|
// Image processing uniforms
|
||||||
uniform float contrast;
|
uniform float contrast;
|
||||||
uniform float brightness;
|
uniform float brightness;
|
||||||
uniform float saturation;
|
uniform float saturation;
|
||||||
@@ -74,47 +77,47 @@ vec3 erosion(int N, vec2 filter_step)
|
|||||||
{
|
{
|
||||||
vec3 minValue = vec3(1.0);
|
vec3 minValue = vec3(1.0);
|
||||||
|
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (0.0,0.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (0.0,0.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (0.0,-1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (0.0,-1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-1.0, 0.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-1.0, 0.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (1.0, 0.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (1.0, 0.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (0.0, 1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (0.0, 1.0) * filter_step ).rgb, minValue);
|
||||||
if (N < 1)
|
if (N < 1)
|
||||||
return minValue;
|
return minValue;
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-1.0, -2.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-1.0, -2.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (0.0,-2.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (0.0,-2.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (1.0,-2.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (1.0,-2.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-1.0,2.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-1.0,2.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (0.0, 2.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (0.0, 2.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (1.0, 2.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (1.0, 2.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-2.0, 1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-2.0, 1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-1.0, 1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-1.0, 1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 ( 1.0, 1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 ( 1.0, 1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 ( 2.0, 1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 ( 2.0, 1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-2.0, -1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-2.0, -1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-1.0, -1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-1.0, -1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 ( 1.0, -1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 ( 1.0, -1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 ( 2.0, -1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 ( 2.0, -1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-2.0, 0.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-2.0, 0.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 ( 2.0, 0.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 ( 2.0, 0.0) * filter_step ).rgb, minValue);
|
||||||
if (N < 2)
|
if (N < 2)
|
||||||
return minValue;
|
return minValue;
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-1.0, -3.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-1.0, -3.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (0.0,-3.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (0.0,-3.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (1.0,-3.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (1.0,-3.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-1.0,3.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-1.0,3.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (0.0, 3.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (0.0, 3.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (1.0, 3.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (1.0, 3.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-2.0, 2.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-2.0, 2.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 ( 2.0, 2.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 ( 2.0, 2.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-2.0, -2.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-2.0, -2.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 ( 2.0, -2.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 ( 2.0, -2.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-3.0, -1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-3.0, -1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (3.0, -1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (3.0, -1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-3.0, 1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-3.0, 1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 ( 3.0, 1.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 ( 3.0, 1.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 (-3.0, 0.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 (-3.0, 0.0) * filter_step ).rgb, minValue);
|
||||||
minValue = min(texture(iChannel0, vertexUV + vec2 ( 3.0, 0.0) * filter_step ).rgb, minValue);
|
minValue = min(texture(iChannel0, texcoord + vec2 ( 3.0, 0.0) * filter_step ).rgb, minValue);
|
||||||
|
|
||||||
return minValue;
|
return minValue;
|
||||||
}
|
}
|
||||||
@@ -123,47 +126,47 @@ vec3 dilation(int N, vec2 filter_step)
|
|||||||
{
|
{
|
||||||
vec3 maxValue = vec3(0.0);
|
vec3 maxValue = vec3(0.0);
|
||||||
|
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (0.0, 0.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (0.0, 0.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (0.0,-1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (0.0,-1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-1.0, 0.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-1.0, 0.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (1.0, 0.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (1.0, 0.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (0.0, 1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (0.0, 1.0) * filter_step ).rgb, maxValue);
|
||||||
if (N < 1)
|
if (N < 1)
|
||||||
return maxValue;
|
return maxValue;
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-1.0, -2.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-1.0, -2.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (0.0,-2.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (0.0,-2.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (1.0,-2.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (1.0,-2.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-1.0,2.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-1.0,2.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (0.0, 2.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (0.0, 2.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (1.0, 2.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (1.0, 2.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-2.0, 1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-2.0, 1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-1.0, 1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-1.0, 1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 ( 1.0, 1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 ( 1.0, 1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 ( 2.0, 1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 ( 2.0, 1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-2.0, -1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-2.0, -1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-1.0, -1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-1.0, -1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 ( 1.0, -1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 ( 1.0, -1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 ( 2.0, -1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 ( 2.0, -1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-2.0, 0.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-2.0, 0.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 ( 2.0, 0.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 ( 2.0, 0.0) * filter_step ).rgb, maxValue);
|
||||||
if (N < 2)
|
if (N < 2)
|
||||||
return maxValue;
|
return maxValue;
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-1.0, -3.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-1.0, -3.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (0.0,-3.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (0.0,-3.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (1.0,-3.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (1.0,-3.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-1.0,3.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-1.0,3.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (0.0, 3.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (0.0, 3.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (1.0, 3.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (1.0, 3.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-2.0, 2.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-2.0, 2.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 ( 2.0, 2.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 ( 2.0, 2.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-2.0, -2.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-2.0, -2.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 ( 2.0, -2.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 ( 2.0, -2.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-3.0, -1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-3.0, -1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (3.0, -1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (3.0, -1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-3.0, 1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-3.0, 1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 ( 3.0, 1.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 ( 3.0, 1.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 (-3.0, 0.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 (-3.0, 0.0) * filter_step ).rgb, maxValue);
|
||||||
maxValue = max(texture(iChannel0, vertexUV + vec2 ( 3.0, 0.0) * filter_step ).rgb, maxValue);
|
maxValue = max(texture(iChannel0, texcoord + vec2 ( 3.0, 0.0) * filter_step ).rgb, maxValue);
|
||||||
|
|
||||||
return maxValue;
|
return maxValue;
|
||||||
}
|
}
|
||||||
@@ -173,29 +176,29 @@ vec3 opening(vec2 filter_step)
|
|||||||
{
|
{
|
||||||
// 1) erosion
|
// 1) erosion
|
||||||
vec3 minValue1 = vec3(1.0);
|
vec3 minValue1 = vec3(1.0);
|
||||||
minValue1 = min(texture(iChannel0, vertexUV + vec2 (0.0, 0.0) * filter_step ).rgb, minValue1);
|
minValue1 = min(texture(iChannel0, texcoord + vec2 (0.0, 0.0) * filter_step ).rgb, minValue1);
|
||||||
minValue1 = min(texture(iChannel0, vertexUV + vec2 (0.0, 1.0) * filter_step ).rgb, minValue1);
|
minValue1 = min(texture(iChannel0, texcoord + vec2 (0.0, 1.0) * filter_step ).rgb, minValue1);
|
||||||
minValue1 = min(texture(iChannel0, vertexUV + vec2 (0.0, 2.0) * filter_step ).rgb, minValue1);
|
minValue1 = min(texture(iChannel0, texcoord + vec2 (0.0, 2.0) * filter_step ).rgb, minValue1);
|
||||||
minValue1 = min(texture(iChannel0, vertexUV + vec2 (1.0, 1.0) * filter_step ).rgb, minValue1);
|
minValue1 = min(texture(iChannel0, texcoord + vec2 (1.0, 1.0) * filter_step ).rgb, minValue1);
|
||||||
minValue1 = min(texture(iChannel0, vertexUV + vec2 (1.0, -1.0) * filter_step ).rgb, minValue1);
|
minValue1 = min(texture(iChannel0, texcoord + vec2 (1.0, -1.0) * filter_step ).rgb, minValue1);
|
||||||
vec3 minValue2 = vec3(1.0);
|
vec3 minValue2 = vec3(1.0);
|
||||||
minValue2 = min(texture(iChannel0, vertexUV + vec2 (0.0, 0.0) * filter_step ).rgb, minValue2);
|
minValue2 = min(texture(iChannel0, texcoord + vec2 (0.0, 0.0) * filter_step ).rgb, minValue2);
|
||||||
minValue2 = min(texture(iChannel0, vertexUV + vec2 (-1.0, 0.0) * filter_step ).rgb, minValue2);
|
minValue2 = min(texture(iChannel0, texcoord + vec2 (-1.0, 0.0) * filter_step ).rgb, minValue2);
|
||||||
minValue2 = min(texture(iChannel0, vertexUV + vec2 (-2.0, 0.0) * filter_step ).rgb, minValue2);
|
minValue2 = min(texture(iChannel0, texcoord + vec2 (-2.0, 0.0) * filter_step ).rgb, minValue2);
|
||||||
minValue2 = min(texture(iChannel0, vertexUV + vec2 (1.0, -1.0) * filter_step ).rgb, minValue2);
|
minValue2 = min(texture(iChannel0, texcoord + vec2 (1.0, -1.0) * filter_step ).rgb, minValue2);
|
||||||
minValue2 = min(texture(iChannel0, vertexUV + vec2 (-1.0, -1.0) * filter_step ).rgb, minValue2);
|
minValue2 = min(texture(iChannel0, texcoord + vec2 (-1.0, -1.0) * filter_step ).rgb, minValue2);
|
||||||
vec3 minValue3 = vec3(1.0);
|
vec3 minValue3 = vec3(1.0);
|
||||||
minValue3 = min(texture(iChannel0, vertexUV + vec2 (0.0, 0.0) * filter_step ).rgb, minValue3);
|
minValue3 = min(texture(iChannel0, texcoord + vec2 (0.0, 0.0) * filter_step ).rgb, minValue3);
|
||||||
minValue3 = min(texture(iChannel0, vertexUV + vec2 (0.0, -1.0) * filter_step ).rgb, minValue3);
|
minValue3 = min(texture(iChannel0, texcoord + vec2 (0.0, -1.0) * filter_step ).rgb, minValue3);
|
||||||
minValue3 = min(texture(iChannel0, vertexUV + vec2 (0.0, -2.0) * filter_step ).rgb, minValue3);
|
minValue3 = min(texture(iChannel0, texcoord + vec2 (0.0, -2.0) * filter_step ).rgb, minValue3);
|
||||||
minValue3 = min(texture(iChannel0, vertexUV + vec2 (-1.0, -1.0) * filter_step ).rgb, minValue3);
|
minValue3 = min(texture(iChannel0, texcoord + vec2 (-1.0, -1.0) * filter_step ).rgb, minValue3);
|
||||||
minValue3 = min(texture(iChannel0, vertexUV + vec2 (-1.0, 1.0) * filter_step ).rgb, minValue3);
|
minValue3 = min(texture(iChannel0, texcoord + vec2 (-1.0, 1.0) * filter_step ).rgb, minValue3);
|
||||||
vec3 minValue4 = vec3(1.0);
|
vec3 minValue4 = vec3(1.0);
|
||||||
minValue4 = min(texture(iChannel0, vertexUV + vec2 (0.0, 0.0) * filter_step ).rgb, minValue4);
|
minValue4 = min(texture(iChannel0, texcoord + vec2 (0.0, 0.0) * filter_step ).rgb, minValue4);
|
||||||
minValue4 = min(texture(iChannel0, vertexUV + vec2 (1.0, 0.0) * filter_step ).rgb, minValue4);
|
minValue4 = min(texture(iChannel0, texcoord + vec2 (1.0, 0.0) * filter_step ).rgb, minValue4);
|
||||||
minValue4 = min(texture(iChannel0, vertexUV + vec2 (2.0, 0.0) * filter_step ).rgb, minValue4);
|
minValue4 = min(texture(iChannel0, texcoord + vec2 (2.0, 0.0) * filter_step ).rgb, minValue4);
|
||||||
minValue4 = min(texture(iChannel0, vertexUV + vec2 (1.0, 1.0) * filter_step ).rgb, minValue4);
|
minValue4 = min(texture(iChannel0, texcoord + vec2 (1.0, 1.0) * filter_step ).rgb, minValue4);
|
||||||
minValue4 = min(texture(iChannel0, vertexUV + vec2 (-1.0, 1.0) * filter_step ).rgb, minValue4);
|
minValue4 = min(texture(iChannel0, texcoord + vec2 (-1.0, 1.0) * filter_step ).rgb, minValue4);
|
||||||
|
|
||||||
// 2) dilation
|
// 2) dilation
|
||||||
vec3 maxValue = vec3(0.0);
|
vec3 maxValue = vec3(0.0);
|
||||||
@@ -214,7 +217,7 @@ vec3 convolution(mat3 kernel, vec2 filter_step)
|
|||||||
|
|
||||||
for (i = 0; i<3; ++i)
|
for (i = 0; i<3; ++i)
|
||||||
for (j = 0; j<3; ++j)
|
for (j = 0; j<3; ++j)
|
||||||
sum += texture(iChannel0, vertexUV + filter_step * vec2 (i-1, j-1) ).rgb * kernel[i][j];
|
sum += texture(iChannel0, texcoord + filter_step * vec2 (i-1, j-1) ).rgb * kernel[i][j];
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
@@ -224,7 +227,7 @@ vec3 apply_filter() {
|
|||||||
vec2 filter_step = 1.f / textureSize(iChannel0, 0);
|
vec2 filter_step = 1.f / textureSize(iChannel0, 0);
|
||||||
|
|
||||||
if (filterid < 1 || filterid > 11)
|
if (filterid < 1 || filterid > 11)
|
||||||
return texture(iChannel0, vertexUV).rgb;
|
return texture(iChannel0, texcoord).rgb;
|
||||||
else if (filterid < 5)
|
else if (filterid < 5)
|
||||||
return convolution( KERNEL[filterid], filter_step);
|
return convolution( KERNEL[filterid], filter_step);
|
||||||
else if (filterid < 6)
|
else if (filterid < 6)
|
||||||
@@ -313,10 +316,12 @@ float alphachromakey(vec3 color, vec3 colorKey, float delta)
|
|||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
|
// adjust UV
|
||||||
|
texcoord = vec2(uv.x, uv.y) + vertexUV * vec2(uv.z - uv.x, uv.w - uv.y);
|
||||||
|
|
||||||
// deal with alpha separately
|
// deal with alpha separately
|
||||||
float ma = texture(iChannel0, vertexUV).a;
|
float ma = texture(iChannel0, texcoord).a;
|
||||||
// float ma = texture(maskTexture, vertexUV).a * texture(iChannel0, vertexUV).a;
|
// float ma = texture(maskTexture, texcoord).a * texture(iChannel0, texcoord).a;
|
||||||
float alpha = clamp(ma * color.a, 0.0, 1.0);
|
float alpha = clamp(ma * color.a, 0.0, 1.0);
|
||||||
|
|
||||||
// read color & apply basic filterid
|
// read color & apply basic filterid
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ out vec4 FragColor;
|
|||||||
|
|
||||||
in vec4 vertexColor;
|
in vec4 vertexColor;
|
||||||
|
|
||||||
uniform vec4 color; // drawing color
|
|
||||||
uniform vec3 iResolution; // viewport resolution (in pixels)
|
uniform vec3 iResolution; // viewport resolution (in pixels)
|
||||||
|
|
||||||
|
uniform vec4 color; // drawing color
|
||||||
|
uniform vec4 uv;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = color * vertexColor;
|
FragColor = color * vertexColor;
|
||||||
|
|||||||
Reference in New Issue
Block a user