Fix lights

This commit is contained in:
schmelczerandras 2020-09-21 15:45:03 +02:00
parent 7250d164a8
commit 3725f56c78
6 changed files with 10 additions and 6 deletions

View file

@ -5,7 +5,7 @@ import { Insights } from '../insights';
import { RenderPass } from './render-pass';
export class LightsRenderPass extends RenderPass {
public lightPhaseOutLength = 400;
public lightCutoffDistance = 400;
private drawables: Array<LightDrawable> = [];
public addDrawable(drawable: LightDrawable) {
@ -33,9 +33,9 @@ export class LightsRenderPass extends RenderPass {
const distance =
vec2.length([Math.max(d.x, 0), Math.max(d.y, 0)]) +
Math.min(Math.max(d.x, d.y), 0.0);
l.setLightnessRatio(clamp01(1 - distance / this.lightPhaseOutLength));
l.setLightnessRatio(clamp01(1 - distance / this.lightCutoffDistance));
return distance < this.lightPhaseOutLength;
return distance < this.lightCutoffDistance;
});
drawablesNearTile.forEach((p) =>

View file

@ -5,5 +5,6 @@ export interface RuntimeSettings {
tileMultiplier: number;
isWorldInverted: boolean;
shadowLength: number;
lightCutoffDistance: number;
ambientLight: vec3;
}

View file

@ -50,6 +50,9 @@ export class WebGl2Renderer implements Renderer {
ambientLight: (v) => {
this.uniformsProvider.ambientLight = v;
},
lightCutoffDistance: (v) => {
this.lightsPass.lightCutoffDistance = v;
},
};
private static defaultStartupSettings: StartupSettings = {