So the light was at position (0, 10, 0). I moved it to (10000, 10000, 10000) and the thing looks good on PC.
But on Android, all the colors are burned. It looks like the distance of the light is exploding the intensity of it on Android:
So I managed to reduce that problem by replacing:
vec4 Idiff = LDiffuse * max(dot(N,L), 0.0);
per:
vec4 Idiff = LDiffuse * clamp(dot(N,L), 0.0, 1.0);
in:
Code: Select all
#ifdef GL_ES
precision mediump float;
#endif
uniform mat4 modelViewMatrix;
uniform mat4 modelViewProjectionMatrix;
uniform mat3 normalMatrix;
attribute vec4 position, color; // vertex position & color
attribute vec3 normal; // vertex normal
varying vec3 N;
varying vec3 v;
varying vec4 v_Color;
void main(void)
{
v = vec3(modelViewMatrix * position);
N = normalize(normalMatrix * normal);
v_Color = color;
gl_Position = modelViewProjectionMatrix * position;
}
Code: Select all
#ifdef GL_ES
precision mediump float;
#endif
varying vec3 N;
varying vec3 v;
varying vec4 v_Color;
uniform vec4 globalColor; // = Material.Color
uniform mat4 lightPosition;
uniform mat4 lightColorAmbient;
uniform mat4 fogColor;
void main (void)
{
// Light position
vec3 LPosition = vec3(lightPosition[0][0], lightPosition[0][1], lightPosition[0][2]);
vec3 L = normalize(LPosition.xyz - v);
// calculate Diffuse Term
vec4 LAmbient = vec4(lightColorAmbient[0][0], lightColorAmbient[0][1], lightColorAmbient[0][2], 1.0);
vec4 LDiffuse = globalColor * LAmbient;
// clamp to avoid burned colors on Android?
// vec4 Idiff = LDiffuse * max(dot(N,L), 0.0);
vec4 Idiff = LDiffuse * clamp(dot(N,L), 0.0, 1.0);
gl_FragColor = mix(v_Color, Idiff, 0.3);
}
It's better, but the result still isn't the same on PC and Android. It's way more contrasted on Android for the ships, and the planets keeps burning, and I really don't know why...
PC: Android: