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
|
|
@ -32,7 +32,7 @@ void main(void) {
|
||||||
gl_FragColor = vec4(d,d,d,1.0);
|
gl_FragColor = vec4(d,d,d,1.0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(color.w<0)
|
if(color.w<0.)
|
||||||
{
|
{
|
||||||
|
|
||||||
highp vec4 my_color = vec4(color.xyz, 1.);
|
highp vec4 my_color = vec4(color.xyz, 1.);
|
||||||
|
|
|
||||||
|
|
@ -23,17 +23,17 @@ void main(void)
|
||||||
mv_matrix_3[2] = mv_matrix[2].xyz;
|
mv_matrix_3[2] = mv_matrix[2].xyz;
|
||||||
fN = mv_matrix_3* normals;
|
fN = mv_matrix_3* normals;
|
||||||
|
|
||||||
highp mat4 transOB = mat4(1, 0, 0, 0, // first column
|
highp mat4 transOB = mat4(1., 0., 0., 0., // first column
|
||||||
0, 1, 0, 0, // second column
|
0., 1., 0., 0., // second column
|
||||||
0, 0, 1, 0, // third column
|
0., 0., 1., 0., // third column
|
||||||
center.x, center.y, center.z, 1); // fourth column
|
center.x, center.y, center.z, 1); // fourth column
|
||||||
highp mat4 transBO = mat4(1, 0, 0, 0, // first column
|
highp mat4 transBO = mat4(1., 0., 0., 0., // first column
|
||||||
0, 1, 0, 0, // second column
|
0., 1., 0., 0., // second column
|
||||||
0, 0, 1, 0, // third column
|
0., 0., 1., 0., // third column
|
||||||
-center.x, -center.y, -center.z, 1); // fourth column
|
-center.x, -center.y, -center.z, 1); // fourth column
|
||||||
highp mat4 scaling = mat4(shrink_factor, 0, 0, 0,
|
highp mat4 scaling = mat4(shrink_factor, 0., 0., 0.,
|
||||||
0, shrink_factor, 0, 0,
|
0., shrink_factor, 0., 0.,
|
||||||
0, 0, shrink_factor, 0,
|
0., 0., shrink_factor, 0.,
|
||||||
0, 0, 0, 1);
|
0., 0., 0., 1.);
|
||||||
gl_Position = mvp_matrix *transOB * scaling * transBO * vertex;
|
gl_Position = mvp_matrix *transOB * scaling * transBO * vertex;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
varying highp vec4 color;
|
varying highp vec4 color;
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
if(color.w<0)
|
if(color.w<0.)
|
||||||
gl_FragColor = vec4(0,0,0,1.0);
|
gl_FragColor = vec4(0.,0.,0.,1.0);
|
||||||
else
|
else
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ uniform bool back_front_shading;
|
||||||
uniform sampler2D sampler;
|
uniform sampler2D sampler;
|
||||||
uniform highp float alpha;
|
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) {
|
void main(void) {
|
||||||
|
|
@ -53,7 +53,7 @@ void main(void) {
|
||||||
highp vec4 my_color = highp vec4(color.xyz, 1.0);
|
highp vec4 my_color = highp vec4(color.xyz, 1.0);
|
||||||
if(fN == vec3(0.0,0.0,0.0))
|
if(fN == vec3(0.0,0.0,0.0))
|
||||||
{
|
{
|
||||||
out_color = my_color;
|
gl_FragColor = my_color;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
N = normalize(fN);
|
N = normalize(fN);
|
||||||
|
|
@ -61,11 +61,11 @@ void main(void) {
|
||||||
V = normalize(V);
|
V = normalize(V);
|
||||||
highp vec3 R = reflect(-L, N);
|
highp vec3 R = reflect(-L, N);
|
||||||
highp vec4 diffuse;
|
highp vec4 diffuse;
|
||||||
float dot_prod = dot(N,L);
|
highp float dot_prod = dot(N,L);
|
||||||
|
|
||||||
if(back_front_shading)
|
if(back_front_shading)
|
||||||
{
|
{
|
||||||
if (dot_prod > 0)
|
if (dot_prod > 0.0)
|
||||||
my_color = front_color;
|
my_color = front_color;
|
||||||
else
|
else
|
||||||
my_color = back_color;
|
my_color = back_color;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue