Soft shadow behind frame handles to make them more visible in contrast.

This commit is contained in:
brunoherbelin
2020-11-23 00:03:21 +01:00
parent c33796e97c
commit 30301b51d4
5 changed files with 34 additions and 0 deletions

View File

@@ -318,6 +318,7 @@ set(VMIX_RSC_FILES
./rsc/images/glow.dds
./rsc/images/checker.dds
./rsc/images/shadow_perspective.dds
./rsc/images/soft_shadow.dds
./rsc/mesh/disk.ply
./rsc/mesh/circle.ply
./rsc/mesh/shadow.ply
@@ -333,6 +334,7 @@ set(VMIX_RSC_FILES
./rsc/mesh/border_handles_overlay_filled.ply
./rsc/mesh/border_handles_sharp.ply
./rsc/mesh/border_handles_menu.ply
./rsc/mesh/border_handles_shadow.ply
./rsc/mesh/border_large_sharp.ply
./rsc/mesh/border_vertical_overlay.ply
./rsc/mesh/perspective_layer.ply

View File

@@ -8,6 +8,7 @@
#include "BoundingBoxVisitor.h"
#include "ImageShader.h"
#include "GlmToolkit.h"
#include "Resource.h"
#include "Log.h"
@@ -159,6 +160,7 @@ Handles::Handles(Type type) : Node(), type_(type)
static Mesh *handle_corner = new Mesh("mesh/border_handles_overlay.ply");
static Mesh *handle_scale = new Mesh("mesh/border_handles_scale.ply");
static Mesh *handle_restore = new Mesh("mesh/border_handles_menu.ply");
static Mesh *handle_shadow = new Mesh("mesh/border_handles_shadow.ply", "images/soft_shadow.dds");
color = glm::vec4( 1.f, 1.f, 0.f, 1.f);
if ( type_ == Handles::ROTATE ) {
@@ -175,6 +177,8 @@ Handles::Handles(Type type) : Node(), type_(type)
}
corner_ = glm::vec2(0.f, 0.f);
shadow_ = handle_shadow;
}
Handles::~Handles()
@@ -194,6 +198,8 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
if ( !initialized() ) {
if(handle_ && !handle_->initialized())
handle_->init();
if(shadow_ && !shadow_->initialized())
shadow_->init();
init();
}
@@ -279,6 +285,7 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
vec = ( modelview * glm::vec4(1.f, 1.f, 0.f, 1.f) ) + pos;
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
// 3. draw
shadow_->draw( ctm, projection );
handle_->draw( ctm, projection );
}
else if ( type_ == Handles::SCALE ){
@@ -290,6 +297,7 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
vec = ( modelview * glm::vec4(1.f, -1.f, 0.f, 1.f) ) + pos;
ctm = GlmToolkit::transform(vec, rot, glm::vec3(mirror.x, mirror.y, 1.f));
// 3. draw
shadow_->draw( ctm, projection );
handle_->draw( ctm, projection );
}
else if ( type_ == Handles::MENU ){
@@ -301,6 +309,7 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
vec = ( modelview * glm::vec4(-1.f, 1.f, 0.f, 1.f) ) + pos;
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
// 3. draw
shadow_->draw( ctm, projection );
handle_->draw( ctm, projection );
}
}

View File

@@ -52,6 +52,7 @@ public:
protected:
Primitive *handle_;
Primitive *shadow_;
glm::vec2 corner_;
Type type_;

BIN
rsc/images/soft_shadow.dds Normal file

Binary file not shown.

View File

@@ -0,0 +1,22 @@
ply
format ascii 1.0
comment Created by Blender 2.90.1 - www.blender.org
element vertex 4
property float x
property float y
property float z
property float s
property float t
property uchar red
property uchar green
property uchar blue
property uchar alpha
element face 2
property list uchar uint vertex_indices
end_header
0.1500000 -0.1500000 0.000000 1.000000 0.000000 255 255 255 45
-0.1500000 0.1500000 0.000000 0.000000 1.000000 255 255 255 45
-0.1500000 -0.1500000 0.000000 0.000000 0.000000 255 255 255 45
0.1500000 0.1500000 0.000000 1.000000 1.000000 255 255 255 45
3 0 1 2
3 0 3 1