mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
BugFix WhiteBalance Display View and Rendering window
Use of Settings whitebalance parameters for rendering both window and display preview window. Not most optimal maybe, but efficient and clear.
This commit is contained in:
@@ -44,6 +44,8 @@
|
||||
|
||||
#define WINDOW_TITLEBAR_HEIGHT 0.03f
|
||||
|
||||
FilteringProgram _whitebalance("Whitebalance", "shaders/filters/whitebalance.glsl", "", { { "Red", 1.0}, { "Green", 1.0}, { "Blue", 1.0}, { "Temperature", 0.5} });
|
||||
|
||||
|
||||
DisplaysView::DisplaysView() : View(DISPLAYS)
|
||||
{
|
||||
@@ -68,7 +70,9 @@ DisplaysView::DisplaysView() : View(DISPLAYS)
|
||||
// surface background and texture
|
||||
w->surface_ = new Surface;
|
||||
w->root_->attach(w->surface_);
|
||||
w->render_ = new Surface;
|
||||
w->shader_ = new ImageFilteringShader;
|
||||
w->shader_->setCode( _whitebalance.code().first );
|
||||
w->render_ = new Surface(w->shader_);
|
||||
w->root_->attach(w->render_);
|
||||
// icon if disabled
|
||||
w->icon_ = new Handles(Handles::EYESLASHED);
|
||||
@@ -233,7 +237,7 @@ void DisplaysView::draw()
|
||||
|
||||
if (windows_[i].render_->visible_) {
|
||||
// rendering of framebuffer in window
|
||||
if (Settings::application.windows[1].scaled) {
|
||||
if (Settings::application.windows[i+1].scaled) {
|
||||
windows_[i].render_->scale_ = glm::vec3(1.f, 1.f, 1.f);
|
||||
}
|
||||
else {
|
||||
@@ -243,6 +247,12 @@ void DisplaysView::draw()
|
||||
else
|
||||
windows_[i].render_->scale_ = glm::vec3(1.f, out_ar / output_ar, 1.f);
|
||||
}
|
||||
if (windows_[i].shader_) {
|
||||
windows_[i].shader_->uniforms_["Red"] = Settings::application.windows[i+1].whitebalance.x;
|
||||
windows_[i].shader_->uniforms_["Green"] = Settings::application.windows[i+1].whitebalance.y;
|
||||
windows_[i].shader_->uniforms_["Blue"] = Settings::application.windows[i+1].whitebalance.z;
|
||||
windows_[i].shader_->uniforms_["Temperature"] = Settings::application.windows[i+1].whitebalance.w;
|
||||
}
|
||||
}
|
||||
|
||||
// update overlay
|
||||
@@ -379,7 +389,6 @@ void DisplaysView::draw()
|
||||
if (ImGuiToolkit::IconButton(18, 4, "More windows")) {
|
||||
++Settings::application.num_output_windows;
|
||||
current_window_ = Settings::application.num_output_windows-1;
|
||||
Settings::application.windows[1+current_window_].whitebalance = Rendering::manager().outputWindow(current_window_).whiteBalance();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -437,9 +446,6 @@ void DisplaysView::draw()
|
||||
Settings::application.windows[1+current_window_].whitebalance.x = std::get<0>(c);
|
||||
Settings::application.windows[1+current_window_].whitebalance.y = std::get<1>(c);
|
||||
Settings::application.windows[1+current_window_].whitebalance.z = std::get<2>(c);
|
||||
|
||||
// set White Balance Color matrix to shader
|
||||
Rendering::manager().outputWindow(current_window_).setWhiteBalance( Settings::application.windows[1+current_window_].whitebalance );
|
||||
}
|
||||
|
||||
// White ballance temperature
|
||||
@@ -451,10 +457,7 @@ void DisplaysView::draw()
|
||||
{
|
||||
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT);
|
||||
ImGuiToolkit::Indication("9000 K", " " ICON_FA_THERMOMETER_FULL);
|
||||
if ( ImGui::VSliderFloat("##Temperature", ImVec2(30,260), &Settings::application.windows[1+current_window_].whitebalance.w, 0.0, 1.0, "") ){
|
||||
|
||||
Rendering::manager().outputWindow(current_window_).setWhiteBalance( Settings::application.windows[1+current_window_].whitebalance );
|
||||
}
|
||||
ImGui::VSliderFloat("##Temperature", ImVec2(30,260), &Settings::application.windows[1+current_window_].whitebalance.w, 0.0, 1.0, "");
|
||||
if (ImGui::IsItemHovered() || ImGui::IsItemActive() ) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("%d K", 4000 + (int) ceil(Settings::application.windows[1+current_window_].whitebalance.w * 5000.f));
|
||||
@@ -552,7 +555,9 @@ void DisplaysView::draw()
|
||||
rect.p = Mixer::manager().session()->frame()->width();
|
||||
rect.q = Mixer::manager().session()->frame()->height();
|
||||
Rendering::manager().outputWindow(current_window_).setDecoration(true);
|
||||
Rendering::manager().outputWindow(current_window_).setWhiteBalance( glm::vec4(1.f, 1.f, 1.f, 0.5f) );
|
||||
Settings::application.windows[1+current_window_].show_pattern = false;
|
||||
Settings::application.windows[1+current_window_].scaled = false;
|
||||
Settings::application.windows[1+current_window_].whitebalance = glm::vec4(1.f, 1.f, 1.f, 0.5f);
|
||||
if (Settings::application.windows[current_window_+1].fullscreen)
|
||||
Rendering::manager().outputWindow(current_window_).exitFullscreen();
|
||||
else
|
||||
|
||||
@@ -9,6 +9,7 @@ struct WindowPreview
|
||||
Group *status_;
|
||||
Surface *surface_;
|
||||
Surface *render_;
|
||||
ImageFilteringShader *shader_;
|
||||
Switch *overlays_;
|
||||
Switch *mode_;
|
||||
Handles *handles_;
|
||||
|
||||
@@ -1092,32 +1092,6 @@ void RenderingWindow::swap()
|
||||
|
||||
FilteringProgram whitebalance("Whitebalance", "shaders/filters/whitebalance.glsl", "", { { "Red", 1.0}, { "Green", 1.0}, { "Blue", 1.0}, { "Temperature", 0.5} });
|
||||
|
||||
|
||||
void RenderingWindow::setWhiteBalance(glm::vec4 colorcorrection)
|
||||
{
|
||||
if (shader_)
|
||||
shader_->uniforms_ = std::map< std::string, float >{
|
||||
{ "Red", colorcorrection.x},
|
||||
{ "Green", colorcorrection.y},
|
||||
{ "Blue", colorcorrection.z},
|
||||
{ "Temperature", colorcorrection.w}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
glm::vec4 RenderingWindow::whiteBalance() const
|
||||
{
|
||||
glm::vec4 ret(1.f, 1.f, 1.f, 0.5f);
|
||||
|
||||
if (shader_) {
|
||||
ret.x = shader_->uniforms_["Red"];
|
||||
ret.y = shader_->uniforms_["Green"];
|
||||
ret.z = shader_->uniforms_["Blue"];
|
||||
ret.w = shader_->uniforms_["Temperature"];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool RenderingWindow::draw(FrameBuffer *fb)
|
||||
{
|
||||
// cannot draw if there is no window or invalid framebuffer
|
||||
@@ -1150,14 +1124,19 @@ bool RenderingWindow::draw(FrameBuffer *fb)
|
||||
// VAO is not shared between multiple contexts of different windows
|
||||
// so we have to create a new VAO for rendering the surface in this window
|
||||
if (surface_ == nullptr) {
|
||||
|
||||
const std::pair<std::string, std::string> codes = whitebalance.code();
|
||||
// create shader that performs white balance correction
|
||||
shader_ = new ImageFilteringShader;
|
||||
shader_->setCode( codes.first );
|
||||
shader_->uniforms_ = whitebalance.parameters();
|
||||
|
||||
shader_->setCode( whitebalance.code().first );
|
||||
// create surface using the shader
|
||||
surface_ = new WindowSurface(shader_);
|
||||
}
|
||||
// update values of the shader
|
||||
if (shader_) {
|
||||
shader_->uniforms_["Red"] = Settings::application.windows[index_].whitebalance.x;
|
||||
shader_->uniforms_["Green"] = Settings::application.windows[index_].whitebalance.y;
|
||||
shader_->uniforms_["Blue"] = Settings::application.windows[index_].whitebalance.z;
|
||||
shader_->uniforms_["Temperature"] = Settings::application.windows[index_].whitebalance.w;
|
||||
}
|
||||
|
||||
// calculate scaling factor of frame buffer inside window
|
||||
const float windowAspectRatio = aspectRatio();
|
||||
|
||||
@@ -79,13 +79,9 @@ public:
|
||||
// get monitor in which the window is
|
||||
GLFWmonitor *monitor();
|
||||
|
||||
// set geometry and decoration
|
||||
void setCoordinates(glm::ivec4 rect);
|
||||
void setDecoration (bool on);
|
||||
|
||||
// set color correction
|
||||
void setWhiteBalance(glm::vec4 colorcorrection);
|
||||
glm::vec4 whiteBalance() const;
|
||||
// set geometry, color correction and decoration
|
||||
void setCoordinates (glm::ivec4 rect);
|
||||
void setDecoration (bool on);
|
||||
|
||||
// get width of rendering area
|
||||
int width();
|
||||
|
||||
@@ -330,7 +330,7 @@ struct Application
|
||||
show_tooptips = true;
|
||||
accept_connections = false;
|
||||
stream_protocol = 0;
|
||||
broadcast_port = 0;
|
||||
broadcast_port = 7070;
|
||||
recentSRT.protocol = "srt://";
|
||||
recentSRT.default_host = { "127.0.0.1", "7070"};
|
||||
loopback_camera = 0;
|
||||
@@ -343,12 +343,6 @@ struct Application
|
||||
windows = std::vector<WindowConfig>(1+MAX_OUTPUT_WINDOW);
|
||||
windows[0].w = 1600;
|
||||
windows[0].h = 900;
|
||||
windows[1].w = 1270;
|
||||
windows[1].h = 720;
|
||||
windows[2].w = 1270;
|
||||
windows[2].h = 720;
|
||||
windows[3].w = 1270;
|
||||
windows[3].h = 720;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user