Update colors

This commit is contained in:
schmelczerandras 2020-07-25 17:16:48 +02:00
parent 4ef6922da8
commit 9aef368324
8 changed files with 36 additions and 45 deletions

View file

@ -24,7 +24,7 @@ export class WebGl2Renderer implements Drawer {
private multiplicativeQualityDecrease = 1.5;
private timeSinceLastAdjusment = 0;
private adjusmentRate = 500;
private maxRenderScale = 2;
private maxRenderScale = 1.5;
private minRenderScale = 0.2;
private exponentialDecayedDeltaTime = 0.0;

View file

@ -1,16 +1,16 @@
import { GameObject } from '../game-object';
import { vec2 } from 'gl-matrix';
import { BeforeDrawCommand } from '../../commands/types/before-draw';
import { CursorMoveCommand } from '../../commands/types/cursor-move-command';
import { MoveToCommand } from '../../commands/types/move-to';
import { ZoomCommand } from '../../commands/types/zoom';
import { BeforeDrawCommand } from '../../commands/types/before-draw';
import { PrimaryActionCommand } from '../../commands/types/primary-action';
import { vec2 } from 'gl-matrix';
import { CursorMoveCommand } from '../../commands/types/cursor-move-command';
import { GameObject } from '../game-object';
import { CircleLight } from './circle-light';
export class Camera extends GameObject {
private inViewArea = 1920 * 1080;
private cursorPosition = vec2.create();
constructor() {
constructor(private light: CircleLight) {
super();
this.addCommandExecutor(BeforeDrawCommand, this.draw.bind(this));
@ -30,6 +30,15 @@ export class Camera extends GameObject {
private moveTo(c: MoveToCommand) {
this._position = c.position;
this.light.sendCommand(
new MoveToCommand(
vec2.add(
vec2.create(),
c.position,
vec2.scale(vec2.create(), this.boundingBoxSize, 0.5)
)
)
);
}
private zoom(c: ZoomCommand) {

View file

@ -1,5 +1,6 @@
import { vec2, vec3 } from 'gl-matrix';
import { DrawCommand } from '../../commands/types/draw';
import { MoveToCommand } from '../../commands/types/move-to';
import { GameObject } from '../game-object';
export class CircleLight extends GameObject {
@ -11,6 +12,7 @@ export class CircleLight extends GameObject {
super();
this.addCommandExecutor(DrawCommand, this.draw.bind(this));
this.addCommandExecutor(MoveToCommand, this.moveTo.bind(this));
}
private draw(c: DrawCommand) {
@ -22,4 +24,8 @@ export class CircleLight extends GameObject {
});
}
}
private moveTo(c: MoveToCommand) {
this.center = c.position;
}
}

View file

@ -1,30 +0,0 @@
import { vec2, vec3 } from 'gl-matrix';
import { CursorMoveCommand } from '../../commands/types/cursor-move-command';
import { DrawCommand } from '../../commands/types/draw';
import { GameObject } from '../game-object';
export class CursorLight extends GameObject {
private mousePosition = vec2.create();
constructor(private radius: number, private value: vec3) {
super();
this.addCommandExecutor(DrawCommand, this.draw.bind(this));
this.addCommandExecutor(CursorMoveCommand, this.setPosition.bind(this));
}
private draw(c: DrawCommand) {
const center = c.drawer.screenUvToWorldCoordinate(this.mousePosition);
if (c.drawer.isOnScreen(center)) {
c.drawer.appendToUniformList('lights', {
center,
radius: this.radius,
value: this.value,
});
}
}
private setPosition(c: CursorMoveCommand) {
this.mousePosition = c.position;
}
}

View file

@ -1,12 +1,18 @@
import { vec3 } from 'gl-matrix';
import { vec2, vec3 } from 'gl-matrix';
import { ObjectContainer } from '../object-container';
import { Camera } from '../types/camera';
import { Character } from '../types/character';
import { CursorLight } from '../types/cursor-light';
import { CircleLight } from '../types/circle-light';
export const createCharacter = (objects: ObjectContainer) => {
const camera = new Camera();
const light = new CircleLight(
vec2.create(),
40,
vec3.fromValues(0.67, 0.0, 0.33)
);
const camera = new Camera(light);
objects.addObject(light);
objects.addObject(camera);
objects.addObject(new Character(camera));
objects.addObject(new CursorLight(40, vec3.fromValues(0.67, 0.67, 0.33)));
};

View file

@ -24,7 +24,7 @@ export const createDungeon = (objects: ObjectContainer) => {
Math.random() * 20 + 30,
vec3.scale(
vec3.create(),
vec3.normalize(vec3.create(), vec3.random(vec3.create())),
vec3.normalize(vec3.create(), vec3.fromValues(0.5, 0.1, 0.8)),
Math.random() * 0.5 + 0.5
)
)

View file

@ -40,10 +40,10 @@ out vec4 fragmentColor;
void main() {
float distance = getDistance(worldCoordinates);
const vec3 caveColor = vec3(0.0);
const vec3 caveColor = vec3(0.36, 0.38, 0.76);
const vec3 airColor = vec3(1.0);
fragmentColor = vec4(
mix(caveColor, airColor, distance),
mix(caveColor, airColor, clamp(distance, 0.0, 1.0)),
distance / 32.0
);
}

View file

@ -4,7 +4,7 @@ precision mediump float;
#define INFINITY 10000.0
#define LIGHT_COUNT 5
#define AMBIENT_LIGHT vec3(0.05)
#define AMBIENT_LIGHT vec3(0.15)
#define LIGHT_DROP 800.0
#define SHADOW_BIAS 0.01