mirror of https://github.com/CGAL/cgal
Merge pull request #5056 from maxGimeno/Demo-Fix_compatibility_shaders-maxGImeno
Polyhedron_demo : Fix for compatibility shader
This commit is contained in:
commit
6a2e3a4df4
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
varying highp vec4 color;
|
||||
varying highp vec4 fP;
|
||||
varying highp vec3 fN;
|
||||
uniform highp vec4 light_pos;
|
||||
uniform highp vec4 light_diff;
|
||||
uniform highp vec4 light_spec;
|
||||
uniform highp vec4 light_amb;
|
||||
varying highp vec4 fP;
|
||||
varying highp vec3 fN;
|
||||
uniform highp vec4 light_pos;
|
||||
uniform highp vec4 light_diff;
|
||||
uniform highp vec4 light_spec;
|
||||
uniform highp vec4 light_amb;
|
||||
uniform highp float spec_power ;
|
||||
uniform int is_two_side;
|
||||
uniform int is_two_side;
|
||||
uniform bool is_selected;
|
||||
uniform highp float near;
|
||||
uniform highp float far;
|
||||
|
|
@ -32,29 +32,29 @@ void main(void) {
|
|||
gl_FragColor = vec4(d,d,d,1.0);
|
||||
else
|
||||
{
|
||||
if(color.w<0)
|
||||
if(color.w<0.)
|
||||
{
|
||||
|
||||
highp vec4 my_color = vec4(color.xyz, 1.);
|
||||
highp vec3 L = light_pos.xyz - fP.xyz;
|
||||
highp vec3 V = -fP.xyz;
|
||||
highp vec3 N;
|
||||
highp vec3 L = light_pos.xyz - fP.xyz;
|
||||
highp vec3 V = -fP.xyz;
|
||||
highp vec3 N;
|
||||
if(fN == vec3(0.0,0.0,0.0))
|
||||
{
|
||||
gl_FragColor = my_color;
|
||||
return;
|
||||
}
|
||||
else
|
||||
N = normalize(fN);
|
||||
L = normalize(L);
|
||||
V = normalize(V);
|
||||
highp vec3 R = reflect(-L, N);
|
||||
else
|
||||
N = normalize(fN);
|
||||
L = normalize(L);
|
||||
V = normalize(V);
|
||||
highp vec3 R = reflect(-L, N);
|
||||
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;
|
||||
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;
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//#version 100
|
||||
//#version 100
|
||||
attribute highp vec4 vertex;
|
||||
attribute highp vec3 normals;
|
||||
attribute highp vec3 colors;
|
||||
|
|
@ -7,33 +7,33 @@ uniform highp mat4 mvp_matrix;
|
|||
uniform highp mat4 mv_matrix;
|
||||
uniform highp vec4 cutplane;
|
||||
uniform highp float shrink_factor;
|
||||
varying highp vec4 fP;
|
||||
varying highp vec3 fN;
|
||||
varying highp vec4 color;
|
||||
varying highp vec4 fP;
|
||||
varying highp vec3 fN;
|
||||
varying highp vec4 color;
|
||||
uniform highp float point_size;
|
||||
void main(void)
|
||||
{
|
||||
gl_PointSize = point_size;
|
||||
color = vec4(colors, vertex.x * cutplane.x + vertex.y * cutplane.y + vertex.z * cutplane.z + cutplane.w);
|
||||
fP = mv_matrix * vertex;
|
||||
fP = 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;
|
||||
fN = mv_matrix_3* normals;
|
||||
|
||||
highp mat4 transOB = mat4(1, 0, 0, 0, // first column
|
||||
0, 1, 0, 0, // second column
|
||||
0, 0, 1, 0, // third column
|
||||
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;
|
||||
fN = mv_matrix_3* normals;
|
||||
|
||||
highp mat4 transOB = mat4(1., 0., 0., 0., // first column
|
||||
0., 1., 0., 0., // second column
|
||||
0., 0., 1., 0., // third column
|
||||
center.x, center.y, center.z, 1); // fourth column
|
||||
highp mat4 transBO = mat4(1, 0, 0, 0, // first column
|
||||
0, 1, 0, 0, // second column
|
||||
0, 0, 1, 0, // third column
|
||||
highp mat4 transBO = mat4(1., 0., 0., 0., // first column
|
||||
0., 1., 0., 0., // second column
|
||||
0., 0., 1., 0., // third column
|
||||
-center.x, -center.y, -center.z, 1); // fourth column
|
||||
highp mat4 scaling = mat4(shrink_factor, 0, 0, 0,
|
||||
0, shrink_factor, 0, 0,
|
||||
0, 0, shrink_factor, 0,
|
||||
0, 0, 0, 1);
|
||||
highp mat4 scaling = mat4(shrink_factor, 0., 0., 0.,
|
||||
0., shrink_factor, 0., 0.,
|
||||
0., 0., shrink_factor, 0.,
|
||||
0., 0., 0., 1.);
|
||||
gl_Position = mvp_matrix *transOB * scaling * transBO * vertex;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
varying highp vec4 color;
|
||||
void main(void)
|
||||
{
|
||||
if(color.w<0)
|
||||
gl_FragColor = vec4(0,0,0,1.0);
|
||||
void main(void)
|
||||
{
|
||||
if(color.w<0.)
|
||||
gl_FragColor = vec4(0.,0.,0.,1.0);
|
||||
else
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ uniform bool back_front_shading;
|
|||
uniform sampler2D sampler;
|
||||
uniform highp float alpha;
|
||||
|
||||
highp float depth(float z)
|
||||
highp float depth(highp float z)
|
||||
{
|
||||
return (2 * near) / (far + near - z * (far - near));
|
||||
return (2.0 * near) / (far + near - z * (far - near));
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
|
|
@ -53,7 +53,7 @@ void main(void) {
|
|||
highp vec4 my_color = highp vec4(color.xyz, 1.0);
|
||||
if(fN == vec3(0.0,0.0,0.0))
|
||||
{
|
||||
out_color = my_color;
|
||||
gl_FragColor = my_color;
|
||||
return;
|
||||
}
|
||||
N = normalize(fN);
|
||||
|
|
@ -61,16 +61,16 @@ void main(void) {
|
|||
V = normalize(V);
|
||||
highp vec3 R = reflect(-L, N);
|
||||
highp vec4 diffuse;
|
||||
float dot_prod = dot(N,L);
|
||||
|
||||
highp float dot_prod = dot(N,L);
|
||||
|
||||
if(back_front_shading)
|
||||
{
|
||||
if (dot_prod > 0)
|
||||
if (dot_prod > 0.0)
|
||||
my_color = front_color;
|
||||
else
|
||||
my_color = back_color;
|
||||
}
|
||||
|
||||
|
||||
if(is_two_side == 1)
|
||||
diffuse = abs(dot(N,L)) * light_diff * color;
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue