FIX: black edge issue
jira: STUDIO-9954 Change-Id: Ib503039383763074947992606ac9a8f7b8409ec8 (cherry picked from commit 3870dbb980a36535f22ec8a0849546c0b1ee7b4c)
This commit is contained in:
parent
93446f05e1
commit
999bae0f53
|
@ -9,26 +9,28 @@ uniform bool svg_source;
|
|||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
vec4 svg_color()
|
||||
vec4 svg_color(vec2 uv)
|
||||
{
|
||||
// takes foreground from texture
|
||||
vec4 fore_color = texture2D(texture, tex_coord);
|
||||
vec4 fore_color = texture2D(texture, uv);
|
||||
|
||||
// calculates radial gradient
|
||||
vec3 back_color = vec3(mix(back_color_light, back_color_dark, smoothstep(0.0, 0.5, length(abs(tex_coord.xy) - vec2(0.5)))));
|
||||
vec3 back_color = vec3(mix(back_color_light, back_color_dark, smoothstep(0.0, 0.5, length(abs(uv) - vec2(0.5)))));
|
||||
|
||||
// blends foreground with background
|
||||
return vec4(mix(back_color, fore_color.rgb, fore_color.a), transparent_background ? fore_color.a : 1.0);
|
||||
}
|
||||
|
||||
vec4 non_svg_color()
|
||||
vec4 non_svg_color(vec2 uv)
|
||||
{
|
||||
// takes foreground from texture
|
||||
vec4 color = texture2D(texture, tex_coord);
|
||||
vec4 color = texture2D(texture, uv);
|
||||
return vec4(color.rgb, transparent_background ? color.a * 0.25 : color.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = svg_source ? svg_color() : non_svg_color();
|
||||
// flip uv
|
||||
vec2 uv = vec2(tex_coord.x, 1.0 - tex_coord.y);
|
||||
gl_FragColor = svg_source ? svg_color(uv) : non_svg_color(uv);
|
||||
}
|
|
@ -660,7 +660,6 @@ bool GLModel::init_model_from_poly(const std::vector<Vec2f> &triangles, float z,
|
|||
return false;
|
||||
|
||||
Vec2f inv_size = size.cwiseInverse();
|
||||
inv_size.y() *= -1.0f;
|
||||
|
||||
// vertices + indices
|
||||
unsigned int vertices_counter = 0;
|
||||
|
|
|
@ -30,6 +30,21 @@
|
|||
#include <boost/log/trivial.hpp>
|
||||
#include <wx/dcgraph.h>
|
||||
#include "FontUtils.hpp"
|
||||
namespace {
|
||||
GLenum get_gl_texture_wrap_mode(Slic3r::GUI::GLTexture::ESamplerWrapMode mode) {
|
||||
switch (mode) {
|
||||
case Slic3r::GUI::GLTexture::ESamplerWrapMode::Repeat:
|
||||
return GL_REPEAT;
|
||||
case Slic3r::GUI::GLTexture::ESamplerWrapMode::MirrorRepeat:
|
||||
return GL_MIRRORED_REPEAT;
|
||||
case Slic3r::GUI::GLTexture::ESamplerWrapMode::Border:
|
||||
return GL_CLAMP_TO_BORDER;
|
||||
case Slic3r::GUI::GLTexture::ESamplerWrapMode::Clamp:
|
||||
default:
|
||||
return GL_CLAMP_TO_EDGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
|
@ -658,6 +673,31 @@ bool GLTexture::generate_texture_from_text(const std::string& text_str, wxFont&
|
|||
return true;
|
||||
}
|
||||
|
||||
void GLTexture::set_wrap_mode_u(ESamplerWrapMode mode)
|
||||
{
|
||||
m_wrap_mode_u = mode;
|
||||
}
|
||||
|
||||
void GLTexture::set_wrap_mode_v(ESamplerWrapMode mode)
|
||||
{
|
||||
m_wrap_mode_v = mode;
|
||||
}
|
||||
|
||||
void GLTexture::bind(uint8_t stage)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + stage);
|
||||
glBindTexture(GL_TEXTURE_2D, m_id);
|
||||
|
||||
// set sampler state
|
||||
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, get_gl_texture_wrap_mode(m_wrap_mode_u)));
|
||||
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, get_gl_texture_wrap_mode(m_wrap_mode_v)));
|
||||
}
|
||||
|
||||
void GLTexture::unbind()
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
void GLTexture::render_texture(unsigned int tex_id, float left, float right, float bottom, float top)
|
||||
{
|
||||
render_sub_texture(tex_id, left, right, bottom, top, FullTextureUVs);
|
||||
|
|
|
@ -64,6 +64,13 @@ namespace GUI {
|
|||
SingleThreaded,
|
||||
MultiThreaded
|
||||
};
|
||||
enum ESamplerWrapMode : uint8_t
|
||||
{
|
||||
Repeat,
|
||||
MirrorRepeat,
|
||||
Clamp,
|
||||
Border
|
||||
};
|
||||
|
||||
struct UV
|
||||
{
|
||||
|
@ -87,6 +94,8 @@ namespace GUI {
|
|||
int m_height;
|
||||
std::string m_source;
|
||||
Compressor m_compressor;
|
||||
ESamplerWrapMode m_wrap_mode_u{ ESamplerWrapMode::Clamp };
|
||||
ESamplerWrapMode m_wrap_mode_v{ ESamplerWrapMode::Clamp };
|
||||
|
||||
public:
|
||||
GLTexture();
|
||||
|
@ -124,6 +133,10 @@ namespace GUI {
|
|||
bool unsent_compressed_data_available() const { return m_compressor.unsent_compressed_data_available(); }
|
||||
void send_compressed_data_to_gpu() { m_compressor.send_compressed_data_to_gpu(); }
|
||||
bool all_compressed_data_sent_to_gpu() const { return m_compressor.all_compressed_data_sent_to_gpu(); }
|
||||
void set_wrap_mode_u(ESamplerWrapMode mode);
|
||||
void set_wrap_mode_v(ESamplerWrapMode mode);
|
||||
void bind(uint8_t stage = 0);
|
||||
void unbind();
|
||||
|
||||
static void render_texture(unsigned int tex_id, float left, float right, float bottom, float top);
|
||||
static void render_sub_texture(unsigned int tex_id, float left, float right, float bottom, float top, const Quad_UVs& uvs);
|
||||
|
|
|
@ -517,10 +517,11 @@ void PartPlate::render_logo_texture(GLTexture &logo_texture, GLModel &logo_buffe
|
|||
glsafe(::glFrontFace(GL_CW));
|
||||
|
||||
// show the temporary texture while no compressed data is available
|
||||
GLuint tex_id = (GLuint)logo_texture.get_id();
|
||||
glsafe(::glBindTexture(GL_TEXTURE_2D, tex_id));
|
||||
logo_texture.set_wrap_mode_u(GLTexture::ESamplerWrapMode::Clamp);
|
||||
logo_texture.set_wrap_mode_v(GLTexture::ESamplerWrapMode::Clamp);
|
||||
logo_texture.bind(0);
|
||||
logo_buffer.render_geometry();
|
||||
glsafe(::glBindTexture(GL_TEXTURE_2D, 0));
|
||||
logo_texture.unbind();
|
||||
|
||||
if (bottom)
|
||||
glsafe(::glFrontFace(GL_CCW));
|
||||
|
|
Loading…
Reference in New Issue