Implementation of two transition function profiles: linear and quadratic

This commit is contained in:
brunoherbelin
2020-07-08 23:13:42 +02:00
parent cfac7107b6
commit 5957c487f1
10 changed files with 27 additions and 11 deletions

View File

@@ -261,8 +261,10 @@ set(VMIX_RSC_FILES
./rsc/images/mask_linear_right.png ./rsc/images/mask_linear_right.png
./rsc/images/vimix_256x256.png ./rsc/images/vimix_256x256.png
./rsc/images/icons.dds ./rsc/images/icons.dds
./rsc/images/gradient_0.png ./rsc/images/gradient_0_cross_linear.png
./rsc/images/gradient_1.png ./rsc/images/gradient_1_black_linear.png
./rsc/images/gradient_2_cross_quad.png
./rsc/images/gradient_3_black_quad.png
./rsc/images/transparencygrid.png ./rsc/images/transparencygrid.png
./rsc/images/shadow.dds ./rsc/images/shadow.dds
./rsc/images/glow.dds ./rsc/images/glow.dds

View File

@@ -1542,7 +1542,7 @@ void Navigator::RenderTransitionPannel()
if (ImGuiToolkit::ButtonIcon(9, 1)) Settings::application.transition.profile = 0; if (ImGuiToolkit::ButtonIcon(9, 1)) Settings::application.transition.profile = 0;
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::Combo("Curve", &Settings::application.transition.profile, "Linear\0Quadratic\0IExponent\0"); ImGui::Combo("Curve", &Settings::application.transition.profile, "Linear\0Quadratic\0");
if ( ImGui::Button( ICON_FA_PLAY " Start", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) { if ( ImGui::Button( ICON_FA_PLAY " Start", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) {
TransitionView *tv = static_cast<TransitionView *>(Mixer::manager().view(View::TRANSITION)); TransitionView *tv = static_cast<TransitionView *>(Mixer::manager().view(View::TRANSITION));
if (tv) tv->play(); if (tv) tv->play();

View File

@@ -732,8 +732,10 @@ TransitionView::TransitionView() : View(TRANSITION), transition_source_(nullptr)
// Geometry Scene background // Geometry Scene background
gradient_ = new Switch; gradient_ = new Switch;
gradient_->attach(new ImageSurface("images/gradient_0.png")); gradient_->attach(new ImageSurface("images/gradient_0_cross_linear.png"));
gradient_->attach(new ImageSurface("images/gradient_1.png")); gradient_->attach(new ImageSurface("images/gradient_1_black_linear.png"));
gradient_->attach(new ImageSurface("images/gradient_2_cross_quad.png"));
gradient_->attach(new ImageSurface("images/gradient_3_black_quad.png"));
gradient_->scale_ = glm::vec3(0.501f, 0.006f, 1.f); gradient_->scale_ = glm::vec3(0.501f, 0.006f, 1.f);
gradient_->translation_ = glm::vec3(-0.5f, -0.005f, -0.01f); gradient_->translation_ = glm::vec3(-0.5f, -0.005f, -0.01f);
scene.fg()->attach(gradient_); scene.fg()->attach(gradient_);
@@ -779,8 +781,16 @@ void TransitionView::update(float dt)
// cross fading // cross fading
if ( Settings::application.transition.cross_fade ) if ( Settings::application.transition.cross_fade )
{ {
// change alpha of session: identical coordinates in Mixing View float f = 0.f;
transition_source_->group(View::MIXING)->translation_.x = CLAMP(d, -1.f, 0.f); // change alpha of session:
if (Settings::application.transition.profile == 0)
// linear => identical coordinates in Mixing View
f = d;
else {
// quadratic => square coordinates in Mixing View
f = (d+1.f)*(d+1.f) -1.f;
}
transition_source_->group(View::MIXING)->translation_.x = CLAMP(f, -1.f, 0.f);
transition_source_->group(View::MIXING)->translation_.y = 0.f; transition_source_->group(View::MIXING)->translation_.y = 0.f;
// reset / no fading // reset / no fading
@@ -794,9 +804,13 @@ void TransitionView::update(float dt)
transition_source_->group(View::MIXING)->translation_.y = 0.f; transition_source_->group(View::MIXING)->translation_.y = 0.f;
// fade to black at 50% : fade-out [-1.0 -0.5], fade-in [-0.5 0.0] // fade to black at 50% : fade-out [-1.0 -0.5], fade-in [-0.5 0.0]
float f = ABS(2.f * d + 1.f); // linear float f = 0.f;
// d = ( 2 * d + 1.f); // quadratic if (Settings::application.transition.profile == 0)
// d *= d; f = ABS(2.f * d + 1.f); // linear
else {
f = ( 2 * d + 1.f); // quadratic
f *= f;
}
Mixer::manager().session()->setFading( 1.f - f ); Mixer::manager().session()->setFading( 1.f - f );
} }
@@ -831,7 +845,7 @@ void TransitionView::update(float dt)
void TransitionView::draw() void TransitionView::draw()
{ {
// update the GUI depending on changes in settings // update the GUI depending on changes in settings
gradient_->setActive( Settings::application.transition.cross_fade ? 0 : 1); gradient_->setActive( 2*Settings::application.transition.profile + (Settings::application.transition.cross_fade ? 0 : 1) );
// draw scene of this view // draw scene of this view
scene.root()->draw(glm::identity<glm::mat4>(), Rendering::manager().Projection()); scene.root()->draw(glm::identity<glm::mat4>(), Rendering::manager().Projection());

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB