Commit 685f3e79 authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[FIX] Shader work now under Mac OS X too

parent 7d24a4b2
...@@ -9,30 +9,30 @@ const vec4 DEFAULT_BLACK = vec4(0.0, 0.0, 0.0, 0.0); ...@@ -9,30 +9,30 @@ const vec4 DEFAULT_BLACK = vec4(0.0, 0.0, 0.0, 0.0);
void directionalLight( in int i, in vec3 normal, in float shininess, void directionalLight( in int i, in vec3 normal, in float shininess,
inout vec4 ambient, inout vec4 diffuse, inout vec4 specular) inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
{ {
float nDotVP; float nDotVP;
float nDotHV; float nDotHV;
float pf; float pf;
vec3 L = normalize (gl_LightSource[i].position.xyz - vertex.xyz); vec3 L = normalize (gl_LightSource[i].position.xyz - vertex.xyz);
vec3 H = normalize (L + halfvec.xyz); vec3 H = normalize (L + halfvec.xyz);
nDotVP = max(0.0, dot(normal, normalize((gl_LightSource[i].position.xyz)))); nDotVP = max(0.0, dot(normal, normalize((gl_LightSource[i].position.xyz))));
nDotHV = max(0.0, dot(normal, H)); nDotHV = max(0.0, dot(normal, H));
if (nDotVP == 0.0) if (nDotVP == 0.0)
pf = 0.0; pf = 0.0;
else else
pf = pow(nDotHV, gl_FrontMaterial.shininess); pf = pow(nDotHV, gl_FrontMaterial.shininess);
ambient += gl_LightSource[i].ambient; ambient += gl_LightSource[i].ambient;
diffuse += gl_LightSource[i].diffuse * nDotVP; diffuse += gl_LightSource[i].diffuse * nDotVP;
specular += gl_LightSource[i].specular * pf; specular += gl_LightSource[i].specular * pf;
} }
void calculateLighting(in vec3 N, in float shininess, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular) void calculateLighting(in vec3 N, in float shininess, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
{ {
directionalLight(0, N, shininess, ambient, diffuse, specular); directionalLight(0, N, shininess, ambient, diffuse, specular);
} }
...@@ -18,7 +18,7 @@ void main() ...@@ -18,7 +18,7 @@ void main()
col = clamp(col, 0.0, 1.0); col = clamp(col, 0.0, 1.0);
col.a = opacity * 0.01; col.a = float( opacity ) * 0.01; // MacOS X has old shader spec, no implicit conversion to float takes place
gl_FragColor = col; gl_FragColor = col;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment