mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-07-31 03:51:59 +08:00

jira: STUDIO-5985 most of code from OrcaSlicer,thanks for OrcaSlicer and enricoturri1966 commit 28d0147d0988917a8b9d85441b8836453e0f222e Author: enricoturri1966 <enricoturri@seznam.cz> Date: Fri Oct 20 15:41:26 2023 +0800 Introduction of classes ColorRGB and ColorRGBA to unify color data definition and manipulation Change-Id: I94ff38d9a03b4b91183b150617d6407a8ffa279e
34 lines
939 B
GLSL
34 lines
939 B
GLSL
#version 110
|
|
|
|
const vec3 back_color_dark = vec3(0.235, 0.235, 0.235);
|
|
const vec3 back_color_light = vec3(0.365, 0.365, 0.365);
|
|
|
|
uniform sampler2D texture;
|
|
uniform bool transparent_background;
|
|
uniform bool svg_source;
|
|
|
|
varying vec2 tex_coord;
|
|
|
|
vec4 svg_color()
|
|
{
|
|
// takes foreground from texture
|
|
vec4 fore_color = texture2D(texture, tex_coord);
|
|
|
|
// 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)))));
|
|
|
|
// 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()
|
|
{
|
|
// takes foreground from texture
|
|
vec4 color = texture2D(texture, tex_coord);
|
|
return vec4(color.rgb, transparent_background ? color.a * 0.25 : color.a);
|
|
}
|
|
|
|
void main()
|
|
{
|
|
gl_FragColor = svg_source ? svg_color() : non_svg_color();
|
|
} |