From f39fce13e3303286ee03046a69c99c2036f2eb58 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 15 Mar 2019 13:36:36 +0100 Subject: [PATCH 1/6] Remove remaining #version from compatibility glsl and use compatibility shaders in basic_viewer --- .../include/CGAL/Qt/Basic_viewer_qt.h | 107 +++++++++++++++++- .../heat_intensity_shader.frag | 2 +- .../heat_intensity_shader.vert | 2 +- .../compatibility_shaders/shader_c3t3.frag | 2 +- .../shader_c3t3_edges.frag | 2 +- .../shader_no_light_no_selection.frag | 2 +- .../shader_old_flat.frag | 2 +- .../shader_plane_two_faces.frag | 2 +- .../shader_with_light.frag | 2 +- .../shader_with_texture.frag | 2 +- .../shader_with_textured_edges.frag | 2 +- .../shader_without_light.frag | 2 +- 12 files changed, 115 insertions(+), 14 deletions(-) diff --git a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h index 2799c1c5790..944aa973fcf 100644 --- a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h +++ b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h @@ -141,6 +141,89 @@ const char fragment_source_p_l[] = "} \n" "\n" }; + +//------------------------------------------------------------------------------ +// compatibility shaders + +const char vertex_source_color_comp[] = + { + "attribute highp vec4 vertex;\n" + "attribute highp vec3 normal;\n" + "attribute highp vec3 color;\n" + + "uniform highp mat4 mvp_matrix;\n" + "uniform highp mat4 mv_matrix; \n" + + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" + "varying highp vec4 fColor; \n" + + "uniform highp float point_size; \n" + "void main(void)\n" + "{\n" + " fP = mv_matrix * vertex; \n" + " fN = mat3(mv_matrix)* normal; \n" + " fColor = vec4(color, 1.0); \n" + " gl_PointSize = point_size;\n" + " gl_Position = mvp_matrix * vertex;\n" + "}" + }; + +const char fragment_source_color_comp[] = + { + "varying highp vec4 fP; \n" + "varying highp vec3 fN; \n" + "varying highp vec4 fColor; \n" + "uniform vec4 light_pos; \n" + "uniform vec4 light_diff; \n" + "uniform vec4 light_spec; \n" + "uniform vec4 light_amb; \n" + "uniform float spec_power ; \n" + + "void main(void) { \n" + + " vec3 L = light_pos.xyz - fP.xyz; \n" + " vec3 V = -fP.xyz; \n" + + " vec3 N = normalize(fN); \n" + " L = normalize(L); \n" + " V = normalize(V); \n" + + " vec3 R = reflect(-L, N); \n" + " vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n" + " vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" + + "gl_FragColor = light_amb*fColor + diffuse ; \n" + "} \n" + "\n" + }; + +const char vertex_source_p_l_comp[] = + { + "attribute highp vec4 vertex;\n" + "attribute highp vec3 color;\n" + "uniform highp mat4 mvp_matrix;\n" + "varying highp vec4 fColor; \n" + "uniform highp float point_size; \n" + "void main(void)\n" + "{\n" + " gl_PointSize = point_size;\n" + " fColor = vec4(color, 1.0); \n" + " gl_Position = mvp_matrix * vertex;\n" + "}" + }; + +const char fragment_source_p_l_comp[] = + { + "varying highp vec4 fColor; \n" + "void main(void) { \n" + "gl_FragColor = fColor; \n" + "} \n" + "\n" + }; + + + //------------------------------------------------------------------------------ inline CGAL::Color get_random_color(CGAL::Random& random) { @@ -344,12 +427,21 @@ protected: } // Vertices and segments shader + + const char* source_ = isOpenGL_4_3() + ? vertex_source_p_l + : vertex_source_p_l_comp; + QOpenGLShader *vertex_shader_p_l = new QOpenGLShader(QOpenGLShader::Vertex); - if(!vertex_shader_p_l->compileSourceCode(vertex_source_p_l)) + if(!vertex_shader_p_l->compileSourceCode(source_)) { std::cerr<<"Compiling vertex source FAILED"<compileSourceCode(fragment_source_p_l)) + if(!fragment_shader_p_l->compileSourceCode(source_)) { std::cerr<<"Compiling fragmentsource FAILED"<compileSourceCode(vertex_source_color)) + if(!vertex_shader_face->compileSourceCode(source_)) { std::cerr<<"Compiling vertex source FAILED"<compileSourceCode(fragment_source_color)) { std::cerr<<"Compiling fragmentsource FAILED"< Date: Fri, 15 Mar 2019 15:38:44 +0100 Subject: [PATCH 2/6] Dont call mat3() constructor --- GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h index 944aa973fcf..c809ab05e8a 100644 --- a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h +++ b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h @@ -162,7 +162,11 @@ const char vertex_source_color_comp[] = "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" - " fN = mat3(mv_matrix)* normal; \n" + " mat3 mv_matrix_3; \n" + " mv_matrix_3[0] = mv_matrix[0].xyz; \n" + " mv_matrix_3[1] = mv_matrix[1].xyz; \n" + " mv_matrix_3[2] = mv_matrix[2].xyz; \n" + " fN = mv_matrix_3* normals; \n" " fColor = vec4(color, 1.0); \n" " gl_PointSize = point_size;\n" " gl_Position = mvp_matrix * vertex;\n" From 0059f9232635818673b661a506ae7ec1eb3b2b7d Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 15 Mar 2019 16:07:52 +0100 Subject: [PATCH 3/6] Fix normals to normal --- GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h index c809ab05e8a..034909624da 100644 --- a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h +++ b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h @@ -166,7 +166,7 @@ const char vertex_source_color_comp[] = " mv_matrix_3[0] = mv_matrix[0].xyz; \n" " mv_matrix_3[1] = mv_matrix[1].xyz; \n" " mv_matrix_3[2] = mv_matrix[2].xyz; \n" - " fN = mv_matrix_3* normals; \n" + " fN = mv_matrix_3* normal; \n" " fColor = vec4(color, 1.0); \n" " gl_PointSize = point_size;\n" " gl_Position = mvp_matrix * vertex;\n" From 1761c62087a882790b5a8f1bb637cffe401f4871 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 18 Mar 2019 09:24:01 +0100 Subject: [PATCH 4/6] Fix forgotten compileSoureShader --- GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h index 034909624da..aca57cd2ba9 100644 --- a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h +++ b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h @@ -470,7 +470,7 @@ protected: : fragment_source_color_comp; QOpenGLShader *fragment_shader_face= new QOpenGLShader(QOpenGLShader::Fragment); - if(!fragment_shader_face->compileSourceCode(fragment_source_color)) + if(!fragment_shader_face->compileSourceCode(source_)) { std::cerr<<"Compiling fragmentsource FAILED"< Date: Mon, 18 Mar 2019 09:33:22 +0100 Subject: [PATCH 5/6] add misisng highp in compatibility shaders --- .../include/CGAL/Qt/Basic_viewer_qt.h | 28 +++++++++---------- .../shader_with_light.frag | 10 +++---- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h index aca57cd2ba9..6f81ab8035d 100644 --- a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h +++ b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h @@ -162,12 +162,12 @@ const char vertex_source_color_comp[] = "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" - " mat3 mv_matrix_3; \n" + " highp mat3 mv_matrix_3; \n" " mv_matrix_3[0] = mv_matrix[0].xyz; \n" " mv_matrix_3[1] = mv_matrix[1].xyz; \n" " mv_matrix_3[2] = mv_matrix[2].xyz; \n" " fN = mv_matrix_3* normal; \n" - " fColor = vec4(color, 1.0); \n" + " fColor = highp vec4(color, 1.0); \n" " gl_PointSize = point_size;\n" " gl_Position = mvp_matrix * vertex;\n" "}" @@ -178,24 +178,24 @@ const char fragment_source_color_comp[] = "varying highp vec4 fP; \n" "varying highp vec3 fN; \n" "varying highp vec4 fColor; \n" - "uniform vec4 light_pos; \n" - "uniform vec4 light_diff; \n" - "uniform vec4 light_spec; \n" - "uniform vec4 light_amb; \n" - "uniform float spec_power ; \n" + "uniform highp vec4 light_pos; \n" + "uniform highp vec4 light_diff; \n" + "uniform highp vec4 light_spec; \n" + "uniform highp vec4 light_amb; \n" + "uniform highp float spec_power ; \n" "void main(void) { \n" - " vec3 L = light_pos.xyz - fP.xyz; \n" - " vec3 V = -fP.xyz; \n" + " highp vec3 L = light_pos.xyz - fP.xyz; \n" + " highp vec3 V = -fP.xyz; \n" - " vec3 N = normalize(fN); \n" + " highp vec3 N = normalize(fN); \n" " L = normalize(L); \n" " V = normalize(V); \n" - " vec3 R = reflect(-L, N); \n" - " vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n" - " vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" + " highp vec3 R = reflect(-L, N); \n" + " highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n" + " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" "gl_FragColor = light_amb*fColor + diffuse ; \n" "} \n" @@ -212,7 +212,7 @@ const char vertex_source_p_l_comp[] = "void main(void)\n" "{\n" " gl_PointSize = point_size;\n" - " fColor = vec4(color, 1.0); \n" + " fColor = highp vec4(color, 1.0); \n" " gl_Position = mvp_matrix * vertex;\n" "}" }; diff --git a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_light.frag b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_light.frag index d00eb11a9a2..9a2c7d552dd 100644 --- a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_light.frag +++ b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_light.frag @@ -44,7 +44,7 @@ void main(void) { gl_FragColor = vec4(d,d,d,1.0); else { - vec4 my_color = vec4(color.xyz, 1.0); + highp vec4 my_color = highp vec4(color.xyz, 1.0); highp vec3 L = light_pos.xyz - fP.xyz; highp vec3 V = -fP.xyz; highp vec3 N; @@ -55,16 +55,16 @@ void main(void) { L = normalize(L); V = normalize(V); highp vec3 R = reflect(-L, N); - vec4 diffuse; + highp vec4 diffuse; if(is_two_side == 1) diffuse = abs(dot(N,L)) * light_diff * color; else diffuse = max(dot(N,L), 0.0) * light_diff * my_color; highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; - vec4 ret_color = vec4((my_color*light_amb).xyz + diffuse.xyz + specular.xyz,1); + vec4 ret_color = highp vec4((my_color*light_amb).xyz + diffuse.xyz + specular.xyz,1); if(is_selected) - gl_FragColor = vec4(ret_color.r+70.0/255.0, ret_color.g+70.0/255.0, ret_color.b+70.0/255.0, alpha); + gl_FragColor = highp vec4(ret_color.r+70.0/255.0, ret_color.g+70.0/255.0, ret_color.b+70.0/255.0, alpha); else - gl_FragColor = vec4(ret_color.xyz, alpha); + gl_FragColor = highp vec4(ret_color.xyz, alpha); } } From 660ebe9e815355cb3c5e185dcaccd64e76a1bed8 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 5 Aug 2019 13:12:44 +0200 Subject: [PATCH 6/6] Add missing highp and remove unwanted highp --- Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp | 20 +++++----- .../demo/Circular_kernel_3/Viewer.cpp | 20 +++++----- .../include/CGAL/Qt/Basic_viewer_qt.h | 24 +++++------ GraphicsView/include/CGAL/Qt/qglviewer_impl.h | 12 +++--- .../Linear_cell_complex/basic_viewer.h | 40 +++++++++---------- .../demo/Periodic_3_triangulation_3/Scene.cpp | 14 +++---- .../heat_intensity_shader.frag | 4 +- .../compatibility_shaders/shader_c3t3.frag | 10 ++--- .../shader_c3t3_spheres.vert | 2 +- .../shader_instanced.vert | 2 +- .../shader_no_light_no_selection.frag | 2 +- .../shader_old_flat.frag | 14 +++---- .../shader_plane_two_faces.frag | 2 +- .../shader_with_light.frag | 10 ++--- .../shader_with_texture.vert | 34 ++++++++-------- .../resources/heat_intensity_shader.frag | 4 +- .../Polyhedron/resources/shader_flat.frag | 4 +- .../demo/Triangulation_3/Viewer.cpp | 16 ++++---- 18 files changed, 117 insertions(+), 117 deletions(-) diff --git a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp index e903ab64bea..9069e592943 100644 --- a/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp +++ b/Alpha_shapes_3/demo/Alpha_shapes_3/Viewer.cpp @@ -51,24 +51,24 @@ void Viewer::compile_shaders() "varying highp vec4 fP; \n" "varying highp vec3 fN; \n" "uniform highp vec4 color; \n" - "uniform vec4 light_pos; \n" - "uniform vec4 light_diff; \n" - "uniform vec4 light_spec; \n" - "uniform vec4 light_amb; \n" + "uniform highp vec4 light_pos; \n" + "uniform highp vec4 light_diff; \n" + "uniform highp vec4 light_spec; \n" + "uniform highp vec4 light_amb; \n" "uniform float spec_power ; \n" "void main(void) { \n" - " vec3 L = light_pos.xyz - fP.xyz; \n" - " vec3 V = -fP.xyz; \n" + " highp vec3 L = light_pos.xyz - fP.xyz; \n" + " highp vec3 V = -fP.xyz; \n" - " vec3 N = normalize(fN); \n" + " highp vec3 N = normalize(fN); \n" " L = normalize(L); \n" " V = normalize(V); \n" - " vec3 R = reflect(-L, N); \n" - " vec4 diffuse = abs(dot(N,L)) * light_diff * color; \n" - " vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" + " highp vec3 R = reflect(-L, N); \n" + " highp vec4 diffuse = abs(dot(N,L)) * light_diff * color; \n" + " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" "gl_FragColor = light_amb*color + diffuse + specular ; \n" "} \n" diff --git a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp index 2e53e260c8a..6cb777920fc 100644 --- a/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp +++ b/Circular_kernel_3/demo/Circular_kernel_3/Viewer.cpp @@ -56,24 +56,24 @@ void Viewer::compile_shaders() "varying highp vec4 fP; \n" "varying highp vec3 fN; \n" "uniform highp vec4 color; \n" - "uniform vec4 light_pos; \n" - "uniform vec4 light_diff; \n" - "uniform vec4 light_spec; \n" - "uniform vec4 light_amb; \n" + "uniform highp vec4 light_pos; \n" + "uniform highp vec4 light_diff; \n" + "uniform highp vec4 light_spec; \n" + "uniform highp vec4 light_amb; \n" "uniform float spec_power ; \n" "void main(void) { \n" - " vec3 L = light_pos.xyz - fP.xyz; \n" - " vec3 V = -fP.xyz; \n" + " highp vec3 L = light_pos.xyz - fP.xyz; \n" + " highp vec3 V = -fP.xyz; \n" - " vec3 N = normalize(fN); \n" + " highp vec3 N = normalize(fN); \n" " L = normalize(L); \n" " V = normalize(V); \n" - " vec3 R = reflect(-L, N); \n" - " vec4 diffuse = max(dot(N,L), 0.0) * light_diff * color; \n" - " vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" + " highp vec3 R = reflect(-L, N); \n" + " highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * color; \n" + " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" "gl_FragColor = light_amb*color + diffuse ; \n" "} \n" diff --git a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h index 0959749fbe6..8b23594cd7c 100644 --- a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h +++ b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h @@ -93,24 +93,24 @@ const char fragment_source_color[] = "varying highp vec4 fP; \n" "varying highp vec3 fN; \n" "varying highp vec4 fColor; \n" - "uniform vec4 light_pos; \n" - "uniform vec4 light_diff; \n" - "uniform vec4 light_spec; \n" - "uniform vec4 light_amb; \n" + "uniform highp vec4 light_pos; \n" + "uniform highp vec4 light_diff; \n" + "uniform highp vec4 light_spec; \n" + "uniform highp vec4 light_amb; \n" "uniform float spec_power ; \n" "void main(void) { \n" - " vec3 L = light_pos.xyz - fP.xyz; \n" - " vec3 V = -fP.xyz; \n" + " highp vec3 L = light_pos.xyz - fP.xyz; \n" + " highp vec3 V = -fP.xyz; \n" - " vec3 N = normalize(fN); \n" + " highp vec3 N = normalize(fN); \n" " L = normalize(L); \n" " V = normalize(V); \n" - " vec3 R = reflect(-L, N); \n" - " vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n" - " vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" + " highp vec3 R = reflect(-L, N); \n" + " highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n" + " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" "gl_FragColor = light_amb*fColor + diffuse ; \n" "} \n" @@ -168,7 +168,7 @@ const char vertex_source_color_comp[] = " mv_matrix_3[1] = mv_matrix[1].xyz; \n" " mv_matrix_3[2] = mv_matrix[2].xyz; \n" " fN = mv_matrix_3* normal; \n" - " fColor = highp vec4(color, 1.0); \n" + " fColor = vec4(color, 1.0); \n" " gl_PointSize = point_size;\n" " gl_Position = mvp_matrix * vertex;\n" "}" @@ -213,7 +213,7 @@ const char vertex_source_p_l_comp[] = "void main(void)\n" "{\n" " gl_PointSize = point_size;\n" - " fColor = highp vec4(color, 1.0); \n" + " fColor = vec4(color, 1.0); \n" " gl_Position = mvp_matrix * vertex;\n" "}" }; diff --git a/GraphicsView/include/CGAL/Qt/qglviewer_impl.h b/GraphicsView/include/CGAL/Qt/qglviewer_impl.h index 311093c8283..8e3addda3d7 100644 --- a/GraphicsView/include/CGAL/Qt/qglviewer_impl.h +++ b/GraphicsView/include/CGAL/Qt/qglviewer_impl.h @@ -452,18 +452,18 @@ void CGAL::QGLViewer::initializeGL() { " highp vec4 light_spec = vec4(0.0, 0.0, 0.0, 1.0); \n" " highp vec4 light_amb = vec4(0.4, 0.4, 0.4, 0.4); \n" " highp float spec_power = 51.8 ; \n" - " vec3 L = light_pos.xyz - fP.xyz; \n" - " vec3 V = -fP.xyz; \n" - " vec3 N; \n" + " highp vec3 L = light_pos.xyz - fP.xyz; \n" + " highp vec3 V = -fP.xyz; \n" + " highp vec3 N; \n" " if(fN == vec3(0.0,0.0,0.0)) \n" " N = vec3(0.0,0.0,0.0); \n" " else \n" " N = normalize(fN); \n" " L = normalize(L); \n" " V = normalize(V); \n" - " vec3 R = reflect(-L, N); \n" - " vec4 diffuse = max(abs(dot(N,L)),0.0) * light_diff*color; \n" - " vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" + " highp vec3 R = reflect(-L, N); \n" + " highp vec4 diffuse = max(abs(dot(N,L)),0.0) * light_diff*color; \n" + " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" "gl_FragColor = color*light_amb + diffuse + specular; \n" "gl_FragColor = vec4(gl_FragColor.xyz, 1.0); \n" diff --git a/Linear_cell_complex/examples/Linear_cell_complex/basic_viewer.h b/Linear_cell_complex/examples/Linear_cell_complex/basic_viewer.h index 3dea72672c8..0ca4f962109 100644 --- a/Linear_cell_complex/examples/Linear_cell_complex/basic_viewer.h +++ b/Linear_cell_complex/examples/Linear_cell_complex/basic_viewer.h @@ -97,24 +97,24 @@ const char fragment_source_mono[] = "varying highp vec4 fP; \n" "varying highp vec3 fN; \n" "uniform highp vec4 color; \n" - "uniform vec4 light_pos; \n" - "uniform vec4 light_diff; \n" - "uniform vec4 light_spec; \n" - "uniform vec4 light_amb; \n" + "uniform highp vec4 light_pos; \n" + "uniform highp vec4 light_diff; \n" + "uniform highp vec4 light_spec; \n" + "uniform highp vec4 light_amb; \n" "uniform float spec_power ; \n" "void main(void) { \n" - " vec3 L = light_pos.xyz - fP.xyz; \n" - " vec3 V = -fP.xyz; \n" + " highp vec3 L = light_pos.xyz - fP.xyz; \n" + " highp vec3 V = -fP.xyz; \n" - " vec3 N = normalize(fN); \n" + " highp vec3 N = normalize(fN); \n" " L = normalize(L); \n" " V = normalize(V); \n" - " vec3 R = reflect(-L, N); \n" - " vec4 diffuse = max(dot(N,L), 0.0) * light_diff * color; \n" - " vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" + " highp vec3 R = reflect(-L, N); \n" + " highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * color; \n" + " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" "gl_FragColor = light_amb*color + diffuse ; \n" "} \n" @@ -127,24 +127,24 @@ const char fragment_source_color[] = "varying highp vec4 fP; \n" "varying highp vec3 fN; \n" "varying highp vec4 fColor; \n" - "uniform vec4 light_pos; \n" - "uniform vec4 light_diff; \n" - "uniform vec4 light_spec; \n" - "uniform vec4 light_amb; \n" + "uniform highp vec4 light_pos; \n" + "uniform highp vec4 light_diff; \n" + "uniform highp vec4 light_spec; \n" + "uniform highp vec4 light_amb; \n" "uniform float spec_power ; \n" "void main(void) { \n" - " vec3 L = light_pos.xyz - fP.xyz; \n" - " vec3 V = -fP.xyz; \n" + " highp vec3 L = light_pos.xyz - fP.xyz; \n" + " highp vec3 V = -fP.xyz; \n" - " vec3 N = normalize(fN); \n" + " highp vec3 N = normalize(fN); \n" " L = normalize(L); \n" " V = normalize(V); \n" - " vec3 R = reflect(-L, N); \n" - " vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n" - " vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" + " highp vec3 R = reflect(-L, N); \n" + " highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n" + " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" "gl_FragColor = light_amb*fColor + diffuse ; \n" "} \n" diff --git a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.cpp b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.cpp index b4c03f43eb9..112f842f499 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.cpp +++ b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/Scene.cpp @@ -143,16 +143,16 @@ void Scene::compile_shaders() "void main(void) { \n" - " vec3 L = light_pos.xyz - fP.xyz; \n" - " vec3 V = -fP.xyz; \n" + " highp vec3 L = light_pos.xyz - fP.xyz; \n" + " highp vec3 V = -fP.xyz; \n" - " vec3 N = normalize(fN); \n" + " highp vec3 N = normalize(fN); \n" " L = normalize(L); \n" " V = normalize(V); \n" - " vec3 R = reflect(-L, N); \n" - " vec4 diffuse = abs(dot(N,L)) * light_diff; \n" - " vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" + " highp vec3 R = reflect(-L, N); \n" + " highp vec4 diffuse = abs(dot(N,L)) * light_diff; \n" + " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" "gl_FragColor = light_amb + diffuse + specular; \n" "} \n" @@ -205,7 +205,7 @@ void Scene::compile_shaders() "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" - " vec4 TN = transfo*vec4(normal,1.0); \n" + " highp vec4 TN = transfo*vec4(normal,1.0); \n" " fN = mat3(mv_matrix)* TN.xyz; \n" " gl_Position = mvp_matrix * transfo * vertex; \n" "}" diff --git a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/heat_intensity_shader.frag b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/heat_intensity_shader.frag index 7c18c72c70b..3494f9928c2 100644 --- a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/heat_intensity_shader.frag +++ b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/heat_intensity_shader.frag @@ -2,8 +2,8 @@ varying highp vec4 color; varying highp float out_dist; void main(void) { - vec3 c = color.xyz; - float h = out_dist; + highp vec3 c = color.xyz; + highp float h = out_dist; h = h * 20.; h = h - floor(h); h = (1./(1.+exp(-100.*(h-.55)))) + (1./(1.+exp(-100.*(-h+.45)))); diff --git a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_c3t3.frag b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_c3t3.frag index ea611daa7cf..251ae415a18 100644 --- a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_c3t3.frag +++ b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_c3t3.frag @@ -35,24 +35,24 @@ void main(void) { if(color.w<0) { - vec4 my_color = vec4(color.xyz, 1.); + highp vec4 my_color = vec4(color.xyz, 1.); highp vec3 L = light_pos.xyz - fP.xyz; highp vec3 V = -fP.xyz; highp vec3 N; - if(fN == highp vec3(0.0,0.0,0.0)) - N = highp vec3(0.0,0.0,0.0); + if(fN == vec3(0.0,0.0,0.0)) + N = vec3(0.0,0.0,0.0); else N = normalize(fN); L = normalize(L); V = normalize(V); highp vec3 R = reflect(-L, N); - vec4 diffuse; + highp vec4 diffuse; if(is_two_side == 1) diffuse = abs(dot(N,L)) * light_diff * my_color; else diffuse = max(dot(N,L), 0.0) * light_diff * my_color; highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; - vec4 ret_color = vec4((my_color*light_amb).xyz + diffuse.xyz + specular.xyz,1); + highp vec4 ret_color = vec4((my_color*light_amb).xyz + diffuse.xyz + specular.xyz,1); if(is_selected) gl_FragColor = vec4(ret_color.r+70.0/255.0, ret_color.g+70.0/255.0, ret_color.b+70.0/255.0, alpha); else diff --git a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_c3t3_spheres.vert b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_c3t3_spheres.vert index 1ce5c173d76..26b307888a0 100644 --- a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_c3t3_spheres.vert +++ b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_c3t3_spheres.vert @@ -15,7 +15,7 @@ void main(void) { gl_PointSize = point_size; color = vec4(colors, center.x * cutplane.x + center.y * cutplane.y + center.z * cutplane.z + cutplane.w); - vec4 my_vertex = vec4(radius*vertex.x + center.x, radius* vertex.y + center.y, radius*vertex.z + center.z, 1.0) ; + highp vec4 my_vertex = vec4(radius*vertex.x + center.x, radius* vertex.y + center.y, radius*vertex.z + center.z, 1.0) ; fP = mv_matrix * my_vertex; mat3 mv_matrix_3; mv_matrix_3[0] = mv_matrix[0].xyz; diff --git a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_instanced.vert b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_instanced.vert index 1aea0be7347..b8a6ecdaa54 100644 --- a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_instanced.vert +++ b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_instanced.vert @@ -15,7 +15,7 @@ void main(void) { gl_PointSize = point_size; color = vec4(colors, 1.0); - vec4 my_vertex = vec4(vertex.x + center.x, vertex.y + center.y, vertex.z + center.z, 1.0); + highp vec4 my_vertex = vec4(vertex.x + center.x, vertex.y + center.y, vertex.z + center.z, 1.0); fP = mv_matrix * my_vertex; mat3 mv_matrix_3; mv_matrix_3[0] = mv_matrix[0].xyz; diff --git a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_no_light_no_selection.frag b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_no_light_no_selection.frag index f17c9563854..711f17d8c8e 100644 --- a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_no_light_no_selection.frag +++ b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_no_light_no_selection.frag @@ -13,5 +13,5 @@ if(is_clipbox_on) dist[4]>0.0 || dist[5]>0.0) discard; - gl_FragColor = highp vec4(color.xyz, alpha); + gl_FragColor = vec4(color.xyz, alpha); } diff --git a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_old_flat.frag b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_old_flat.frag index 559f01a9686..bcb5d361280 100644 --- a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_old_flat.frag +++ b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_old_flat.frag @@ -12,24 +12,24 @@ void main(void) { highp vec3 L = light_pos.xyz - fP.xyz; highp vec3 V = -fP.xyz; highp vec3 N; - vec3 X = dFdx(fP.xyz); - vec3 Y = dFdy(fP.xyz); - vec3 normal=normalize(cross(X,Y)); + highp vec3 X = dFdx(fP.xyz); + highp vec3 Y = dFdy(fP.xyz); + highp vec3 normal=normalize(cross(X,Y)); - if(normal == highp vec3(0.0,0.0,0.0)) - N = highp vec3(0.0,0.0,0.0); + if(normal == vec3(0.0,0.0,0.0)) + N = vec3(0.0,0.0,0.0); else N = normalize(normal); L = normalize(L); V = normalize(V); highp vec3 R = reflect(-L, N); - vec4 diffuse; + highp vec4 diffuse; if(is_two_side == 1) diffuse = abs(dot(N,L)) * light_diff * color; else diffuse = max(dot(N,L), 0.0) * light_diff * color; highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; - vec4 ret_color = vec4((color*light_amb).xyz + diffuse.xyz + specular.xyz,1); + highp vec4 ret_color = vec4((color*light_amb).xyz + diffuse.xyz + specular.xyz,1); if(is_selected) gl_FragColor = vec4(ret_color.r+70.0/255.0, ret_color.g+70.0/255.0, ret_color.b+70.0/255.0, 1.0); else diff --git a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_plane_two_faces.frag b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_plane_two_faces.frag index 8f2fc1837c4..a5986527e8e 100644 --- a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_plane_two_faces.frag +++ b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_plane_two_faces.frag @@ -7,7 +7,7 @@ uniform bool is_selected; void main(void) { highp vec4 t_color = color; -highp vec3 dir = highp vec3(plane_pos.x - dirView.x, plane_pos.y - dirView.y, plane_pos.z - dirView.z); +highp vec3 dir = vec3(plane_pos.x - dirView.x, plane_pos.y - dirView.y, plane_pos.z - dirView.z); if(dot(dir, plane_normal)>0.0) t_color = vec4(1.0-color.r, 1.0-color.g, 1.0-color.b, color.a); if(is_selected) diff --git a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_light.frag b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_light.frag index 1842b061c3f..2c0b38aa039 100644 --- a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_light.frag +++ b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_light.frag @@ -44,12 +44,12 @@ void main(void) { gl_FragColor = vec4(d,d,d,1.0); else { - highp vec4 my_color = highp vec4(color.xyz, 1.0); + highp vec4 my_color = vec4(color.xyz, 1.0); highp vec3 L = light_pos.xyz - fP.xyz; highp vec3 V = -fP.xyz; highp vec3 N; - if(fN == highp vec3(0.0,0.0,0.0)) - N = highp vec3(0.0,0.0,0.0); + if(fN == vec3(0.0,0.0,0.0)) + N = vec3(0.0,0.0,0.0); else N = normalize(fN); L = normalize(L); @@ -61,10 +61,10 @@ void main(void) { else diffuse = max(dot(N,L), 0.0) * light_diff * my_color; highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; - vec4 ret_color = highp vec4((my_color*light_amb).xyz + diffuse.xyz + specular.xyz,1); + vec4 ret_color = vec4((my_color*light_amb).xyz + diffuse.xyz + specular.xyz,1); if(is_selected) gl_FragColor = vec4(ret_color.r+35.0/255.0, ret_color.g+35.0/255.0, ret_color.b+35.0/255.0, alpha); else - gl_FragColor = highp vec4(ret_color.xyz, alpha); + gl_FragColor = vec4(ret_color.xyz, alpha); } } diff --git a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_texture.vert b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_texture.vert index 811ce461ffd..e73931212fa 100644 --- a/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_texture.vert +++ b/Polyhedron/demo/Polyhedron/resources/compatibility_shaders/shader_with_texture.vert @@ -19,21 +19,21 @@ uniform highp float point_size; void main(void) { gl_PointSize = point_size; - vec4 P = mv_matrix * vertex; - mat3 mv_matrix_3; - mv_matrix_3[0] = mv_matrix[0].xyz; - mv_matrix_3[1] = mv_matrix[1].xyz; - mv_matrix_3[2] = mv_matrix[2].xyz; - vec3 N = mv_matrix_3* normals; - vec3 L = light_pos.xyz - P.xyz; - N = normalize(N); - L = normalize(L); - vec3 diffuse; - if(is_two_side == 1) - diffuse = abs(dot(N,L)) * light_diff.xyz; - else - diffuse = max(dot(N,L), 0.0) * light_diff.xyz; - f_texCoord = v_texCoord; - fColors = vec3(1.0, 1.0, 1.0) * (light_amb.xyz + diffuse); - gl_Position = mvp_matrix * f_matrix * vertex; + highp vec4 P = mv_matrix * vertex; + mat3 mv_matrix_3; + mv_matrix_3[0] = mv_matrix[0].xyz; + mv_matrix_3[1] = mv_matrix[1].xyz; + mv_matrix_3[2] = mv_matrix[2].xyz; + highp vec3 N = mv_matrix_3* normals; + highp vec3 L = light_pos.xyz - P.xyz; + N = normalize(N); + L = normalize(L); + highp vec3 diffuse; + if(is_two_side == 1) + diffuse = abs(dot(N,L)) * light_diff.xyz; + else + diffuse = max(dot(N,L), 0.0) * light_diff.xyz; + f_texCoord = v_texCoord; + fColors = vec3(1.0, 1.0, 1.0) * (light_amb.xyz + diffuse); + gl_Position = mvp_matrix * f_matrix * vertex; } diff --git a/Polyhedron/demo/Polyhedron/resources/heat_intensity_shader.frag b/Polyhedron/demo/Polyhedron/resources/heat_intensity_shader.frag index 90f0bcc072b..b1b6da41e7c 100644 --- a/Polyhedron/demo/Polyhedron/resources/heat_intensity_shader.frag +++ b/Polyhedron/demo/Polyhedron/resources/heat_intensity_shader.frag @@ -55,8 +55,8 @@ void main(void) { vec3 L = light_pos.xyz - fP.xyz; vec3 V = -fP.xyz; vec3 N; - if(fN == highp vec3(0.0,0.0,0.0)) - N = highp vec3(0.0,0.0,0.0); + if(fN == vec3(0.0,0.0,0.0)) + N = vec3(0.0,0.0,0.0); else N = normalize(fN); L = normalize(L); diff --git a/Polyhedron/demo/Polyhedron/resources/shader_flat.frag b/Polyhedron/demo/Polyhedron/resources/shader_flat.frag index be9870bca01..f6b2484283d 100644 --- a/Polyhedron/demo/Polyhedron/resources/shader_flat.frag +++ b/Polyhedron/demo/Polyhedron/resources/shader_flat.frag @@ -32,8 +32,8 @@ void main(void) vec3 V = -fs_in.fP.xyz; vec3 N; - if(fs_in.normal == highp vec3(0.0,0.0,0.0)) - N = highp vec3(0.0,0.0,0.0); + if(fs_in.normal == vec3(0.0,0.0,0.0)) + N = vec3(0.0,0.0,0.0); else N = fs_in.normal; L = normalize(L); diff --git a/Triangulation_3/demo/Triangulation_3/Viewer.cpp b/Triangulation_3/demo/Triangulation_3/Viewer.cpp index ca1add3a016..6b2ae97a005 100644 --- a/Triangulation_3/demo/Triangulation_3/Viewer.cpp +++ b/Triangulation_3/demo/Triangulation_3/Viewer.cpp @@ -234,7 +234,7 @@ void Viewer::compile_shaders() "#version 120 \n" "varying highp vec4 fP; \n" "varying highp vec3 fN; \n" - "uniform vec4 color; \n" + "uniform highp vec4 color; \n" "uniform highp vec4 light_pos; \n" "uniform highp vec4 light_diff; \n" "uniform highp vec4 light_spec; \n" @@ -243,16 +243,16 @@ void Viewer::compile_shaders() "void main(void) { \n" - " vec3 L = light_pos.xyz - fP.xyz; \n" - " vec3 V = -fP.xyz; \n" + " highp vec3 L = light_pos.xyz - fP.xyz; \n" + " highp vec3 V = -fP.xyz; \n" - " vec3 N = normalize(fN); \n" + " highp vec3 N = normalize(fN); \n" " L = normalize(L); \n" " V = normalize(V); \n" - " vec3 R = reflect(-L, N); \n" - " vec4 diffuse = abs(dot(N,L)) * light_diff*color; \n" - " vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" + " highp vec3 R = reflect(-L, N); \n" + " highp vec4 diffuse = abs(dot(N,L)) * light_diff*color; \n" + " highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" "gl_FragColor = color*light_amb + diffuse + specular; \n" "} \n" @@ -304,7 +304,7 @@ void Viewer::compile_shaders() "void main(void)\n" "{\n" " fP = mv_matrix * vertex; \n" - " vec4 TN = transfo*vec4(normal,1.0); \n" + " highp vec4 TN = transfo*vec4(normal,1.0); \n" " fN = mat3(mv_matrix)* TN.xyz; \n" " gl_Position = mvp_matrix * transfo* vertex; \n" "}"