Browse Source

Shaders: GLSL ES doesn't have default values for uniforms.

If targetting GLSL ES the values are set on initialization explicitly
from application.
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
57f3175b06
  1. 8
      src/Shaders/PhongShader.cpp
  2. 9
      src/Shaders/PhongShader.frag

8
src/Shaders/PhongShader.cpp

@ -60,6 +60,14 @@ PhongShader::PhongShader() {
projectionMatrixUniform = uniformLocation("projectionMatrix");
lightUniform = uniformLocation("light");
lightColorUniform = uniformLocation("lightColor");
/* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */
#ifdef MAGNUM_TARGET_GLES
setAmbientColor({});
setSpecularColor(Vector3(1.0f));
setLightColor(Vector3(1.0f));
setShininess(80.0f);
#endif
}
}}

9
src/Shaders/PhongShader.frag

@ -3,11 +3,18 @@
#define color gl_FragColor
#endif
uniform lowp vec3 ambientColor = vec3(0.0, 0.0, 0.0);
uniform lowp vec3 diffuseColor;
#ifndef GL_ES
uniform lowp vec3 ambientColor = vec3(0.0, 0.0, 0.0);
uniform lowp vec3 specularColor = vec3(1.0, 1.0, 1.0);
uniform lowp vec3 lightColor = vec3(1.0, 1.0, 1.0);
uniform mediump float shininess = 80.0;
#else
uniform lowp vec3 ambientColor;
uniform lowp vec3 specularColor;
uniform lowp vec3 lightColor;
uniform mediump float shininess;
#endif
in mediump vec3 transformedNormal;
in highp vec3 lightDirection;

Loading…
Cancel
Save