mirror of https://github.com/CGAL/cgal
Merge pull request #3772 from maxGimeno/BasicViewer-Update_shaders-GF
Basic viewer: use compatibility shaders in basic_viewer
This commit is contained in:
commit
fd328f6c91
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -142,6 +142,93 @@ 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"
|
||||
" 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"
|
||||
" 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 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"
|
||||
|
||||
" highp vec3 L = light_pos.xyz - fP.xyz; \n"
|
||||
" highp vec3 V = -fP.xyz; \n"
|
||||
|
||||
" highp vec3 N = normalize(fN); \n"
|
||||
" L = normalize(L); \n"
|
||||
" V = normalize(V); \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"
|
||||
"\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)
|
||||
{
|
||||
|
|
@ -378,12 +465,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"<<std::endl; }
|
||||
|
||||
source_ = isOpenGL_4_3()
|
||||
? fragment_source_p_l
|
||||
: fragment_source_p_l_comp;
|
||||
|
||||
QOpenGLShader *fragment_shader_p_l= new QOpenGLShader(QOpenGLShader::Fragment);
|
||||
if(!fragment_shader_p_l->compileSourceCode(fragment_source_p_l))
|
||||
if(!fragment_shader_p_l->compileSourceCode(source_))
|
||||
{ std::cerr<<"Compiling fragmentsource FAILED"<<std::endl; }
|
||||
|
||||
if(!rendering_program_p_l.addShader(vertex_shader_p_l))
|
||||
|
|
@ -394,12 +490,21 @@ protected:
|
|||
{ std::cerr<<"linking Program FAILED"<<std::endl; }
|
||||
|
||||
// Faces shader
|
||||
|
||||
source_ = isOpenGL_4_3()
|
||||
? vertex_source_color
|
||||
: vertex_source_color_comp;
|
||||
|
||||
QOpenGLShader *vertex_shader_face = new QOpenGLShader(QOpenGLShader::Vertex);
|
||||
if(!vertex_shader_face->compileSourceCode(vertex_source_color))
|
||||
if(!vertex_shader_face->compileSourceCode(source_))
|
||||
{ std::cerr<<"Compiling vertex source FAILED"<<std::endl; }
|
||||
|
||||
source_ = isOpenGL_4_3()
|
||||
? fragment_source_color
|
||||
: 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"<<std::endl; }
|
||||
|
||||
if(!rendering_program_face.addShader(vertex_shader_face))
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
"}"
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#version 120
|
||||
|
||||
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))));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#version 120
|
||||
|
||||
attribute highp vec4 vertex;
|
||||
attribute highp vec3 normals;
|
||||
attribute highp vec3 colors;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#version 120
|
||||
|
||||
varying highp vec4 color;
|
||||
varying highp vec4 fP;
|
||||
varying highp vec3 fN;
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#version 120
|
||||
|
||||
varying highp vec4 color;
|
||||
void main(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#version 120
|
||||
|
||||
varying highp vec4 color;
|
||||
varying highp float dist[6];
|
||||
uniform bool is_clipbox_on;
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#version 120
|
||||
|
||||
varying highp vec4 color;
|
||||
varying highp vec4 fP;
|
||||
uniform highp vec4 light_pos;
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#version 120
|
||||
|
||||
varying highp vec4 color;
|
||||
uniform highp vec3 dirView;
|
||||
uniform highp vec3 plane_normal;
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#version 120
|
||||
|
||||
varying highp vec4 color;
|
||||
varying highp vec4 fP;
|
||||
varying highp vec3 fN;
|
||||
|
|
@ -44,18 +44,18 @@ void main(void) {
|
|||
gl_FragColor = vec4(d,d,d,1.0);
|
||||
else
|
||||
{
|
||||
vec4 my_color = 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);
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#version 120
|
||||
|
||||
varying highp vec3 fColors;
|
||||
varying highp vec2 f_texCoord;
|
||||
uniform sampler2D s_texture;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#version 120
|
||||
|
||||
varying highp vec3 fColors;
|
||||
varying highp vec2 f_texCoord;
|
||||
uniform highp sampler2D s_texture;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#version 120
|
||||
|
||||
varying highp vec4 color;
|
||||
varying highp float dist[6];
|
||||
uniform bool is_selected;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
"}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue