Minor fixes

This commit is contained in:
schmelczerandras 2020-10-19 12:16:20 +02:00
parent eaeeebfca2
commit 06dfd593cd
4 changed files with 17 additions and 13 deletions

View file

@ -19,8 +19,8 @@ The motivation behind this library and more in-depth information about the rende
## Usage (2nd option) ## Usage (2nd option)
If you're planning on creating animated content, use the [runAnimation function](globals.html#run-animation) function to spare yourself from writing boilerplate code. If you're planning on creating animated content, use the [runAnimation function](globals.html#runanimation) to spare yourself from writing boilerplate code.
Further documentation on its usage is available in its [documentation](globals.html#run-animation). Further documentation on its usage is available in its [documentation](globals.html#runanimation).
## Extending drawables ## Extending drawables

View file

@ -1,6 +1,6 @@
{ {
"name": "sdf-2d", "name": "sdf-2d",
"version": "0.5.3", "version": "0.6.0",
"description": "Graphics framework for efficiently rendering 2D signed distance fields.", "description": "Graphics framework for efficiently rendering 2D signed distance fields.",
"keywords": [ "keywords": [
"webgl", "webgl",

View file

@ -1,6 +1,9 @@
import { UniversalRenderingContext } from '../universal-rendering-context'; import { UniversalRenderingContext } from '../universal-rendering-context';
import { tryEnableExtension } from './enable-extension'; import { tryEnableExtension } from './enable-extension';
/**
* @internal
*/
export const getHardwareInfo = ( export const getHardwareInfo = (
gl: UniversalRenderingContext gl: UniversalRenderingContext
): { vendor: string; renderer: string } | null => { ): { vendor: string; renderer: string } | null => {

View file

@ -1,3 +1,4 @@
import { clamp } from '../../helper/clamp';
import { Renderer } from './renderer/renderer'; import { Renderer } from './renderer/renderer';
/** /**
@ -15,7 +16,7 @@ import { Renderer } from './renderer/renderer';
*/ */
export class FpsQualityAutoscaler { export class FpsQualityAutoscaler {
private readonly maxAdjusmentRateInMilliseconds = 10000; private readonly maxAdjusmentRateInMilliseconds = 10000;
private readonly adjusmentRateIncrease = 1.3; private readonly adjusmentRateIncrease = 2;
private adjusmentRateInMilliseconds = 500; private adjusmentRateInMilliseconds = 500;
private fps = 0; private fps = 0;
@ -62,17 +63,17 @@ export class FpsQualityAutoscaler {
private lightsScale = 1; private lightsScale = 1;
private adjustQuality() { private adjustQuality() {
console.log(this.distanceScale, this.lightsScale);
if (this.fps >= this.fpsTarget + this.fpsHysteresis) { if (this.fps >= this.fpsTarget + this.fpsHysteresis) {
this.renderer.setRuntimeSettings({ this.distanceScale = clamp(this.distanceScale + 0.1, 0.2, 1);
distanceRenderScale: this.distanceScale += 0.1, this.lightsScale = clamp(this.lightsScale + 0.1, 0.2, 1);
lightsRenderScale: this.lightsScale += 0.1,
});
} else if (this.fps <= this.fpsTarget + this.fpsHysteresis) { } else if (this.fps <= this.fpsTarget + this.fpsHysteresis) {
this.distanceScale = clamp(this.distanceScale / 2, 0.2, 1);
this.lightsScale = clamp(this.lightsScale / 2, 0.2, 1);
}
this.renderer.setRuntimeSettings({ this.renderer.setRuntimeSettings({
distanceRenderScale: this.distanceScale *= 0.7, distanceRenderScale: this.distanceScale,
lightsRenderScale: this.lightsScale *= 0.7, lightsRenderScale: this.lightsScale,
}); });
} }
} }
}