ENABLE_GCODE_VIEWER -> Removed options_120_solid shader
This commit is contained in:
parent
af200e47c1
commit
d91fc7b8ab
5 changed files with 5 additions and 112 deletions
|
@ -1,89 +0,0 @@
|
|||
// version 120 is needed for gl_PointCoord
|
||||
#version 120
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
uniform vec3 uniform_color;
|
||||
|
||||
uniform ivec4 viewport;
|
||||
uniform float point_size;
|
||||
uniform mat4 inv_proj_matrix;
|
||||
|
||||
varying vec3 eye_center;
|
||||
// x = tainted, y = specular;
|
||||
vec2 intensity;
|
||||
|
||||
float radius = 0.5 * point_size;
|
||||
|
||||
vec3 eye_position_from_fragment()
|
||||
{
|
||||
// Convert screen coordinates to normalized device coordinates (NDC)
|
||||
vec4 ndc = vec4((gl_FragCoord.x / viewport.z - 0.5) * 2.0,
|
||||
(gl_FragCoord.y / viewport.w - 0.5) * 2.0,
|
||||
(gl_FragCoord.z - 0.5) * 2.0,
|
||||
gl_FragCoord.w);
|
||||
// Convert NDC throuch inverse clip coordinates to view coordinates
|
||||
vec4 clip = inv_proj_matrix * ndc;
|
||||
return clip.xyz;
|
||||
}
|
||||
|
||||
vec3 eye_position_on_sphere(vec3 eye_fragment_position)
|
||||
{
|
||||
vec3 eye_dir = normalize(eye_fragment_position);
|
||||
float a = dot(eye_dir, eye_dir);
|
||||
float b = 2.0 * dot(-eye_center, eye_dir);
|
||||
float c = dot(eye_center, eye_center) - radius * radius;
|
||||
float discriminant = b * b - 4 * a * c;
|
||||
float t = -(b + sqrt(discriminant)) / (2.0 * a);
|
||||
return t * eye_dir;
|
||||
}
|
||||
|
||||
vec4 on_sphere_color(vec3 eye_on_sphere_position)
|
||||
{
|
||||
vec3 eye_normal = normalize(eye_on_sphere_position - eye_center);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(eye_on_sphere_position), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
return vec4(intensity.y + uniform_color.rgb * intensity.x, 1.0);
|
||||
}
|
||||
|
||||
float fragment_depth(vec3 eye_pos)
|
||||
{
|
||||
vec4 clip_pos = gl_ProjectionMatrix * vec4(eye_pos, 1.0);
|
||||
float ndc_depth = clip_pos.z / clip_pos.w;
|
||||
return ((gl_DepthRange.far - gl_DepthRange.near) * ndc_depth + gl_DepthRange.near + gl_DepthRange.far) / 2.0;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 pos = (gl_PointCoord - 0.5) * 2.0;
|
||||
float radius = length(pos);
|
||||
if (radius > 1.0)
|
||||
discard;
|
||||
|
||||
vec3 eye_on_sphere_position = eye_position_on_sphere(eye_position_from_fragment());
|
||||
|
||||
// gl_FragDepth = fragment_depth(eye_on_sphere_position);
|
||||
gl_FragColor = on_sphere_color(eye_on_sphere_position);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#version 120
|
||||
|
||||
uniform float zoom;
|
||||
uniform float point_size;
|
||||
uniform float near_plane_height;
|
||||
|
||||
varying vec3 eye_center;
|
||||
|
||||
void main()
|
||||
{
|
||||
eye_center = (gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
gl_Position = ftransform();
|
||||
gl_PointSize = (gl_Position.w == 1.0) ? zoom * near_plane_height * point_size : near_plane_height * point_size / gl_Position.w;
|
||||
}
|
|
@ -2479,8 +2479,8 @@ void GCodeViewer::render_statistics() const
|
|||
void GCodeViewer::render_shaders_editor() const
|
||||
{
|
||||
auto set_shader = [this](const std::string& shader) {
|
||||
unsigned char begin_id = buffer_id(GCodeProcessor::EMoveType::Retract);
|
||||
unsigned char end_id = buffer_id(GCodeProcessor::EMoveType::Custom_GCode);
|
||||
unsigned char begin_id = buffer_id(EMoveType::Retract);
|
||||
unsigned char end_id = buffer_id(EMoveType::Custom_GCode);
|
||||
for (unsigned char i = begin_id; i <= end_id; ++i) {
|
||||
m_buffers[i].shader = shader;
|
||||
}
|
||||
|
@ -2497,7 +2497,6 @@ void GCodeViewer::render_shaders_editor() const
|
|||
if (ImGui::TreeNode("GLSL version")) {
|
||||
ImGui::RadioButton("1.10 (low end PCs)", &m_shaders_editor.points.shader_version, 0);
|
||||
ImGui::RadioButton("1.20 flat (billboards) [default]", &m_shaders_editor.points.shader_version, 1);
|
||||
ImGui::RadioButton("1.20 solid (spheres)", &m_shaders_editor.points.shader_version, 2);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
|
@ -2505,7 +2504,6 @@ void GCodeViewer::render_shaders_editor() const
|
|||
{
|
||||
case 0: { set_shader("options_110"); break; }
|
||||
case 1: { set_shader("options_120_flat"); break; }
|
||||
case 2: { set_shader("options_120_solid"); break; }
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Options")) {
|
||||
|
|
|
@ -33,7 +33,7 @@ class GCodeViewer
|
|||
CustomGCodes
|
||||
};
|
||||
|
||||
// vbo buffer containing vertices data for a specific toolpath type
|
||||
// vbo buffer containing vertices data used to rendder a specific toolpath type
|
||||
struct VBuffer
|
||||
{
|
||||
enum class EFormat : unsigned char
|
||||
|
@ -65,7 +65,7 @@ class GCodeViewer
|
|||
void reset();
|
||||
};
|
||||
|
||||
// ibo buffer containing indices data for a specific toolpath type
|
||||
// ibo buffer containing indices data (triangles) used to render a specific toolpath type
|
||||
struct IBuffer
|
||||
{
|
||||
// ibo id
|
||||
|
|
|
@ -35,10 +35,8 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||
valid &= append_shader("printbed", { "printbed.vs", "printbed.fs" });
|
||||
// used to render options in gcode preview
|
||||
valid &= append_shader("options_110", { "options_110.vs", "options_110.fs" });
|
||||
if (GUI::wxGetApp().is_glsl_version_greater_or_equal_to(1, 20)) {
|
||||
if (GUI::wxGetApp().is_glsl_version_greater_or_equal_to(1, 20))
|
||||
valid &= append_shader("options_120_flat", { "options_120_flat.vs", "options_120_flat.fs" });
|
||||
valid &= append_shader("options_120_solid", { "options_120_solid.vs", "options_120_solid.fs" });
|
||||
}
|
||||
// used to render extrusion and travel paths in gcode preview
|
||||
valid &= append_shader("toolpaths", { "toolpaths.vs", "toolpaths.fs" });
|
||||
// used to render objects in 3d editor
|
||||
|
|
Loading…
Reference in a new issue