mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
FIX: modify the shader load error for mac
Change-Id: I3e2b282b145b4d87e09c22d4fec1b88537212d60
This commit is contained in:
parent
9558ed242c
commit
b746877d70
5 changed files with 13 additions and 71 deletions
|
@ -1,14 +0,0 @@
|
||||||
#version 140
|
|
||||||
|
|
||||||
uniform vec4 uniform_color;
|
|
||||||
uniform float emission_factor;
|
|
||||||
|
|
||||||
// x = tainted, y = specular;
|
|
||||||
in vec2 intensity;
|
|
||||||
|
|
||||||
out vec4 out_color;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
out_color = uniform_color;
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
#version 140
|
|
||||||
|
|
||||||
#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 mat4 view_model_matrix;
|
|
||||||
uniform mat4 projection_matrix;
|
|
||||||
uniform mat3 view_normal_matrix;
|
|
||||||
|
|
||||||
in vec3 v_position;
|
|
||||||
in vec3 v_normal;
|
|
||||||
|
|
||||||
// x = tainted, y = specular;
|
|
||||||
out vec2 intensity;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
// First transform the normal into camera space and normalize the result.
|
|
||||||
vec3 normal = normalize(view_normal_matrix * v_normal);
|
|
||||||
|
|
||||||
// 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(normal, LIGHT_TOP_DIR), 0.0);
|
|
||||||
|
|
||||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
|
||||||
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
|
||||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
|
||||||
|
|
||||||
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
|
||||||
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
|
|
||||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
|
||||||
|
|
||||||
gl_Position = projection_matrix * position;
|
|
||||||
}
|
|
|
@ -45,9 +45,6 @@ std::pair<bool, std::string> GLShadersManager::init()
|
||||||
// used to render extrusion and travel paths as lines in gcode preview
|
// used to render extrusion and travel paths as lines in gcode preview
|
||||||
valid &= append_shader("toolpaths_lines", { "toolpaths_lines.vs", "toolpaths_lines.fs" });
|
valid &= append_shader("toolpaths_lines", { "toolpaths_lines.vs", "toolpaths_lines.fs" });
|
||||||
|
|
||||||
// used to render cut connectors
|
|
||||||
valid &= append_shader("gouraud_light_uniform", {"gouraud_light_uniform.vs", "gouraud_light_uniform.fs"});
|
|
||||||
|
|
||||||
// used to render objects in 3d editor
|
// used to render objects in 3d editor
|
||||||
//if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 0)) {
|
//if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 0)) {
|
||||||
if (0) {
|
if (0) {
|
||||||
|
|
|
@ -558,11 +558,11 @@ void GLGizmoAdvancedCut::on_render_for_picking()
|
||||||
Transform3d scale_tf = Transform3d::Identity();
|
Transform3d scale_tf = Transform3d::Identity();
|
||||||
scale_tf.scale(Vec3f(connector.radius, connector.radius, height).cast<double>());
|
scale_tf.scale(Vec3f(connector.radius, connector.radius, height).cast<double>());
|
||||||
|
|
||||||
const Transform3d view_model_matrix = camera.get_view_matrix() * translate_tf * m_rotate_matrix * scale_tf;
|
const Transform3d view_model_matrix = translate_tf * m_rotate_matrix * scale_tf;
|
||||||
|
|
||||||
|
|
||||||
std::array<float, 4> color = picking_color_component(i+1);
|
std::array<float, 4> color = picking_color_component(i+1);
|
||||||
render_connector_model(m_shapes[connectors[i].attribs], color, view_model_matrix);
|
render_connector_model(m_shapes[connectors[i].attribs], color, view_model_matrix, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1004,9 +1004,8 @@ void GLGizmoAdvancedCut::render_connectors()
|
||||||
Transform3d scale_tf = Transform3d::Identity();
|
Transform3d scale_tf = Transform3d::Identity();
|
||||||
scale_tf.scale(Vec3f(connector.radius, connector.radius, height).cast<double>());
|
scale_tf.scale(Vec3f(connector.radius, connector.radius, height).cast<double>());
|
||||||
|
|
||||||
const Transform3d view_model_matrix = camera.get_view_matrix() * translate_tf * m_rotate_matrix * scale_tf;
|
const Transform3d view_model_matrix = translate_tf * m_rotate_matrix * scale_tf;
|
||||||
|
|
||||||
//render_color = {1.f, 0.f, 0.f, 1.f};
|
|
||||||
render_connector_model(m_shapes[connector.attribs], render_color, view_model_matrix);
|
render_connector_model(m_shapes[connector.attribs], render_color, view_model_matrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1032,20 +1031,25 @@ void GLGizmoAdvancedCut::render_cut_line()
|
||||||
glDisable(GL_LINE_STIPPLE);
|
glDisable(GL_LINE_STIPPLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoAdvancedCut::render_connector_model(GLModel &model, const std::array<float, 4>& color, Transform3d view_model_matrix)
|
void GLGizmoAdvancedCut::render_connector_model(GLModel &model, const std::array<float, 4> &color, Transform3d view_model_matrix, bool for_picking)
|
||||||
{
|
{
|
||||||
GLShaderProgram *shader = wxGetApp().get_shader("gouraud_light_uniform");
|
glPushMatrix();
|
||||||
|
GLShaderProgram *shader = nullptr;
|
||||||
|
if (for_picking)
|
||||||
|
shader = wxGetApp().get_shader("cali");
|
||||||
|
else
|
||||||
|
shader = wxGetApp().get_shader("gouraud_light");
|
||||||
if (shader) {
|
if (shader) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
shader->set_uniform("view_model_matrix", view_model_matrix);
|
glsafe(::glMultMatrixd(view_model_matrix.data()));
|
||||||
shader->set_uniform("projection_matrix", wxGetApp().plater()->get_camera().get_projection_matrix());
|
|
||||||
|
|
||||||
model.set_color(-1, color);
|
model.set_color(-1, color);
|
||||||
model.render();
|
model.render();
|
||||||
|
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
}
|
}
|
||||||
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoAdvancedCut::clear_selection()
|
void GLGizmoAdvancedCut::clear_selection()
|
||||||
|
|
|
@ -200,7 +200,7 @@ private:
|
||||||
void render_connectors();
|
void render_connectors();
|
||||||
void render_clipper_cut();
|
void render_clipper_cut();
|
||||||
void render_cut_line();
|
void render_cut_line();
|
||||||
void render_connector_model(GLModel &model, const std::array<float, 4>& color, Transform3d view_model_matrix);
|
void render_connector_model(GLModel &model, const std::array<float, 4>& color, Transform3d view_model_matrix, bool for_picking = false);
|
||||||
|
|
||||||
void clear_selection();
|
void clear_selection();
|
||||||
void init_connector_shapes();
|
void init_connector_shapes();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue