diff --git a/documentation-readme.md b/documentation-readme.md index 1d5e8d6..f5bdd7e 100644 --- a/documentation-readme.md +++ b/documentation-readme.md @@ -19,8 +19,8 @@ The motivation behind this library and more in-depth information about the rende ## 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. -Further documentation on its usage is available in its [documentation](globals.html#run-animation). +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#runanimation). ## Extending drawables diff --git a/package.json b/package.json index a6a5124..44adbd8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sdf-2d", - "version": "0.5.3", + "version": "0.6.0", "description": "Graphics framework for efficiently rendering 2D signed distance fields.", "keywords": [ "webgl", diff --git a/src/graphics/graphics-library/helper/get-hardware-info.ts b/src/graphics/graphics-library/helper/get-hardware-info.ts index 5c840ca..5dba3e7 100644 --- a/src/graphics/graphics-library/helper/get-hardware-info.ts +++ b/src/graphics/graphics-library/helper/get-hardware-info.ts @@ -1,6 +1,9 @@ import { UniversalRenderingContext } from '../universal-rendering-context'; import { tryEnableExtension } from './enable-extension'; +/** + * @internal + */ export const getHardwareInfo = ( gl: UniversalRenderingContext ): { vendor: string; renderer: string } | null => { diff --git a/src/graphics/rendering/fps-quality-autoscaler.ts b/src/graphics/rendering/fps-quality-autoscaler.ts index 7497b04..41ca6c3 100644 --- a/src/graphics/rendering/fps-quality-autoscaler.ts +++ b/src/graphics/rendering/fps-quality-autoscaler.ts @@ -1,3 +1,4 @@ +import { clamp } from '../../helper/clamp'; import { Renderer } from './renderer/renderer'; /** @@ -15,7 +16,7 @@ import { Renderer } from './renderer/renderer'; */ export class FpsQualityAutoscaler { private readonly maxAdjusmentRateInMilliseconds = 10000; - private readonly adjusmentRateIncrease = 1.3; + private readonly adjusmentRateIncrease = 2; private adjusmentRateInMilliseconds = 500; private fps = 0; @@ -62,17 +63,17 @@ export class FpsQualityAutoscaler { private lightsScale = 1; private adjustQuality() { - console.log(this.distanceScale, this.lightsScale); if (this.fps >= this.fpsTarget + this.fpsHysteresis) { - this.renderer.setRuntimeSettings({ - distanceRenderScale: this.distanceScale += 0.1, - lightsRenderScale: this.lightsScale += 0.1, - }); + this.distanceScale = clamp(this.distanceScale + 0.1, 0.2, 1); + this.lightsScale = clamp(this.lightsScale + 0.1, 0.2, 1); } else if (this.fps <= this.fpsTarget + this.fpsHysteresis) { - this.renderer.setRuntimeSettings({ - distanceRenderScale: this.distanceScale *= 0.7, - lightsRenderScale: this.lightsScale *= 0.7, - }); + this.distanceScale = clamp(this.distanceScale / 2, 0.2, 1); + this.lightsScale = clamp(this.lightsScale / 2, 0.2, 1); } + + this.renderer.setRuntimeSettings({ + distanceRenderScale: this.distanceScale, + lightsRenderScale: this.lightsScale, + }); } }