Turn off lighting for VR
This commit is contained in:
parent
3af3635eea
commit
2b0b699fa0
|
@ -719,7 +719,7 @@ class ThreeDRenderer extends Renderer {
|
||||||
normal[0] / normal[3],
|
normal[0] / normal[3],
|
||||||
normal[1] / normal[3],
|
normal[1] / normal[3],
|
||||||
normal[2] / normal[3]);
|
normal[2] / normal[3]);
|
||||||
|
gl.uniform1f(monumentProgram.uniforms.uLightThings, this.inVR ? 0 : 1);
|
||||||
// Draw the face!
|
// Draw the face!
|
||||||
gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, face * 6 * UINT16_SIZE);
|
gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, face * 6 * UINT16_SIZE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,22 +25,28 @@ uniform float uShininess;
|
||||||
/// The normal of these vertices.
|
/// The normal of these vertices.
|
||||||
uniform vec3 uNormal;
|
uniform vec3 uNormal;
|
||||||
|
|
||||||
|
uniform bool uLightThings;
|
||||||
|
|
||||||
varying vec3 vPosition;
|
varying vec3 vPosition;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec3 normal = normalize(uNormal);
|
vec3 normal = normalize(uNormal);
|
||||||
vec3 lightDirection = normalize(uLightPosition - vPosition);
|
vec3 lightDirection = normalize(uLightPosition - vPosition);
|
||||||
|
|
||||||
float lambertian = max(dot(lightDirection, normal), 0.0);
|
vec3 color = uAmbientColor;
|
||||||
float specular = 0.0;
|
|
||||||
|
|
||||||
if (lambertian > 0.0) {
|
if (uLightThings) {
|
||||||
vec3 viewDirection = normalize(-vPosition);
|
float lambertian = max(dot(lightDirection, normal), 0.0);
|
||||||
vec3 halfDirection = normalize(lightDirection + viewDirection);
|
float specular = 0.0;
|
||||||
float specularAngle = max(dot(halfDirection, normal), 0.0);
|
|
||||||
specular = pow(specularAngle, uShininess);
|
if (lambertian > 0.0) {
|
||||||
|
vec3 viewDirection = normalize(-vPosition);
|
||||||
|
vec3 halfDirection = normalize(lightDirection + viewDirection);
|
||||||
|
float specularAngle = max(dot(halfDirection, normal), 0.0);
|
||||||
|
specular = pow(specularAngle, uShininess);
|
||||||
|
}
|
||||||
|
|
||||||
|
color = color + uAmbientColor + lambertian * uDiffuseColor + specular * uSpecularColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 color = uAmbientColor + lambertian * uDiffuseColor + specular * uSpecularColor;
|
|
||||||
gl_FragColor = vec4(color, 1.0);
|
gl_FragColor = vec4(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue