Reduce environment lights for older gles, invert camera x axis

This commit is contained in:
Evert Prants 2019-12-31 21:36:25 +02:00
parent afeb4a957d
commit fa72bdc92a
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
5 changed files with 10 additions and 10 deletions

View File

@ -1,13 +1,13 @@
precision highp float;
varying vec2 uv;
varying vec3 toLightVector[8];
varying vec3 toLightVector[5];
varying vec3 surfaceNormal;
varying vec3 toCameraVector;
uniform sampler2D texture0;
uniform vec3 lightColor[8];
uniform vec3 attenuation[8];
uniform vec3 lightColor[5];
uniform vec3 attenuation[5];
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<8;i++){
for(int i=0;i<5;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[8];
uniform vec3 lightPosition[5];
varying vec2 uv;
varying vec3 toLightVector[8];
varying vec3 toLightVector[5];
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<8;i++){
for(int i=0;i<5;i++){
toLightVector[i] = lightPosition[i] - worldPosition.xyz;
}
toCameraVector = (inverse(uViewMatrix) * vec4(0.0,0.0,0.0,1.0)).xyz - worldPosition.xyz;

View File

@ -57,7 +57,7 @@ class Camera extends Node {
}
processMouseMove (offset, constrain = true) {
let fst = vec2.fromValues(offset.x * this.sensitivity, offset.y * this.sensitivity)
let fst = vec2.fromValues(offset.x * -this.sensitivity, offset.y * this.sensitivity)
this.rotation[0] += glMatrix.toRadian(fst[0])
this.rotation[1] += glMatrix.toRadian(fst[1])

View File

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

View File

@ -29,7 +29,7 @@ class Screen {
}
loadExtensions () {
this._gl.drawBuffers = this._gl.getExtension('WEBGL_draw_buffers')
// this._gl.drawBuffers = this._gl.getExtension('WEBGL_draw_buffers')
this._gl.getExtension('WEBGL_depth_texture')
this._gl.getExtension('OES_texture_float')
}