Changed Mixing alpha transition function (less abrupt on the sides).

This commit is contained in:
brunoherbelin
2021-01-17 00:28:45 +01:00
parent f7e1ff14d9
commit 56dc299fc9
3 changed files with 45 additions and 5 deletions

View File

@@ -456,7 +456,9 @@ float quad_(float x, float y) {
} }
float sin_quad(float x, float y) { float sin_quad(float x, float y) {
return 0.5f + 0.5f * cos( M_PI * CLAMP( ( ( x * x ) + ( y * y ) ), 0.f, 1.f ) ); float D = sqrt( ( x * x ) + ( y * y ) );
return 0.5f + 0.5f * cos( M_PI * CLAMP( D * sqrt(D), 0.f, 1.f ) );
// return 0.5f + 0.5f * cos( M_PI * CLAMP( ( ( x * x ) + ( y * y ) ), 0.f, 1.f ) );
} }
void Source::update(float dt) void Source::update(float dt)
@@ -472,7 +474,7 @@ void Source::update(float dt)
// ADJUST alpha based on MIXING node // ADJUST alpha based on MIXING node
// read position of the mixing node and interpret this as transparency of render output // read position of the mixing node and interpret this as transparency of render output
glm::vec2 dist = glm::vec2(groups_[View::MIXING]->translation_); glm::vec2 dist = glm::vec2(groups_[View::MIXING]->translation_);
// use the prefered transfer function // use the sinusoidal transfer function
blendingshader_->color = glm::vec4(1.0, 1.0, 1.0, sin_quad( dist.x, dist.y )); blendingshader_->color = glm::vec4(1.0, 1.0, 1.0, sin_quad( dist.x, dist.y ));
mixingshader_->color = blendingshader_->color; mixingshader_->color = blendingshader_->color;

View File

@@ -230,9 +230,7 @@ void View::select(glm::vec2 A, glm::vec2 B)
} }
// set the selection with list of picked (overlaped) sources // set the selection with list of picked (overlaped) sources
Mixer::selection().set(selection); Mixer::selection().set(selection);
} }
} }
@@ -357,6 +355,35 @@ void MixingView::centerSource(Source *s)
} }
void MixingView::select(glm::vec2 A, glm::vec2 B)
{
// unproject mouse coordinate into scene coordinates
glm::vec3 scene_point_A = Rendering::manager().unProject(A);
glm::vec3 scene_point_B = Rendering::manager().unProject(B);
// picking visitor traverses the scene
PickingVisitor pv(scene_point_A, scene_point_B);
scene.accept(pv);
// reset selection
Mixer::selection().clear();
// picking visitor found nodes in the area?
if ( !pv.empty()) {
// create a list of source matching the list of picked nodes
SourceList selection;
// loop over the nodes and add all sources found.
for(std::vector< std::pair<Node *, glm::vec2> >::const_reverse_iterator p = pv.rbegin(); p != pv.rend(); p++){
Source *s = Mixer::manager().findSource( p->first );
if (s && !s->locked())
selection.push_back( s );
}
// set the selection with list of picked (overlaped) sources
Mixer::selection().set(selection);
}
}
void MixingView::selectAll() void MixingView::selectAll()
{ {
for(auto sit = Mixer::manager().session()->begin(); for(auto sit = Mixer::manager().session()->begin();
@@ -433,6 +460,14 @@ std::pair<Node *, glm::vec2> MixingView::pick(glm::vec2 P)
// capture this pick // capture this pick
pick = { nullptr, glm::vec2(0.f) }; pick = { nullptr, glm::vec2(0.f) };
} }
else {
// get if a source was picked
Source *s = Mixer::manager().findSource(pick.first);
if (s != nullptr && s->locked()) {
if ( !UserInterface::manager().ctrlModifier() )
pick = { nullptr, glm::vec2(0.f) };
}
}
return pick; return pick;
} }
@@ -572,7 +607,9 @@ void MixingView::setAlpha(Source *s)
//#define CIRCLE_PIXEL_RADIUS 262144.0 //#define CIRCLE_PIXEL_RADIUS 262144.0
float sin_quad_texture(float x, float y) { float sin_quad_texture(float x, float y) {
return 0.5f + 0.5f * cos( M_PI * CLAMP( ( ( x * x ) + ( y * y ) ) / CIRCLE_PIXEL_RADIUS, 0.f, 1.f ) ); // return 0.5f + 0.5f * cos( M_PI * CLAMP( ( ( x * x ) + ( y * y ) ) / CIRCLE_PIXEL_RADIUS, 0.f, 1.f ) );
float D = sqrt( ( x * x )/ CIRCLE_PIXEL_RADIUS + ( y * y )/ CIRCLE_PIXEL_RADIUS );
return 0.5f + 0.5f * cos( M_PI * CLAMP( D * sqrt(D), 0.f, 1.f ) );
} }
uint MixingView::textureMixingQuadratic() uint MixingView::textureMixingQuadratic()

1
View.h
View File

@@ -106,6 +106,7 @@ public:
void resize (int) override; void resize (int) override;
int size () override; int size () override;
void centerSource(Source *) override; void centerSource(Source *) override;
void select(glm::vec2, glm::vec2) override;
void selectAll() override; void selectAll() override;
std::pair<Node *, glm::vec2> pick(glm::vec2) override; std::pair<Node *, glm::vec2> pick(glm::vec2) override;