Reduce environment lights for older gles even further

This commit is contained in:
Evert Prants 2019-12-31 22:09:10 +02:00
parent fa72bdc92a
commit 6eaf11cc02
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 8 additions and 8 deletions

View File

@ -1,13 +1,13 @@
precision highp float;
varying vec2 uv;
varying vec3 toLightVector[5];
varying vec3 toLightVector[4];
varying vec3 surfaceNormal;
varying vec3 toCameraVector;
uniform sampler2D texture0;
uniform vec3 lightColor[5];
uniform vec3 attenuation[5];
uniform vec3 lightColor[4];
uniform vec3 attenuation[4];
void main() {
float reflectivity = 0.0;
@ -19,7 +19,7 @@ void main() {
vec3 totalDiffuse = vec3(0.0);
vec3 totalSpecular = vec3(0.0);
for(int i=0;i<5;i++){
for(int i=0;i<4;i++){
float distance = length(toLightVector[i]);
float attFactor = attenuation[i].x + (attenuation[i].y * distance) + (attenuation[i].z * distance * distance);
vec3 unitLightVector = normalize(toLightVector[i]);

View File

@ -7,10 +7,10 @@ attribute vec2 aTexCoords;
uniform mat4 uModelMatrix;
uniform mat4 uViewMatrix;
uniform mat4 uProjectionMatrix;
uniform vec3 lightPosition[5];
uniform vec3 lightPosition[4];
varying vec2 uv;
varying vec3 toLightVector[5];
varying vec3 toLightVector[4];
varying vec3 surfaceNormal;
varying vec3 toCameraVector;
@ -60,7 +60,7 @@ void main() {
gl_Position = uProjectionMatrix * uViewMatrix * worldPosition;
uv = aTexCoords;
surfaceNormal = (uModelMatrix * vec4(aNormal,0.0)).xyz;
for(int i=0;i<5;i++){
for(int i=0;i<4;i++){
toLightVector[i] = lightPosition[i] - worldPosition.xyz;
}
toCameraVector = (inverse(uViewMatrix) * vec4(0.0,0.0,0.0,1.0)).xyz - worldPosition.xyz;

View File

@ -1,5 +1,5 @@
const ENV_MAX_LIGHTS = 5
const ENV_MAX_LIGHTS = 4
class Light {
constructor (pos, color, attenuation = [1.0, 0.0, 0.0]) {