Skip to content

Commit 8cf42bd

Browse files
committed
Add resolution scaling
1 parent 4fd1e0c commit 8cf42bd

21 files changed

+419
-56
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.10.0
2+
3+
- Add reduced render scaling option for lighting passes.
4+
- By default, only illumination and darkness effects are rendered with reduced resolution. This should have no visible impact at all as illumination passes don't have detailed features anyway.
5+
- Tweak noise textures for improved fidelity
6+
- Add option to disable blurred window backgrounds in Application V2
7+
18
## 0.9.2
29

310
- Update polish translations (thanks @Lioheart)

asset-sources/noise/noise.ptex

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
"to": "tones_map_3",
3131
"to_port": 0
3232
},
33-
{
34-
"from": "tones_map_3",
35-
"from_port": 0,
36-
"to": "combine",
37-
"to_port": 1
38-
},
3933
{
4034
"from": "tones_map",
4135
"from_port": 0,
@@ -48,12 +42,6 @@
4842
"to": "tones_map_4",
4943
"to_port": 0
5044
},
51-
{
52-
"from": "tones_map_4",
53-
"from_port": 0,
54-
"to": "combine",
55-
"to_port": 0
56-
},
5745
{
5846
"from": "fbm3_5",
5947
"from_port": 0,
@@ -71,6 +59,18 @@
7159
"from_port": 0,
7260
"to": "tones_map_5",
7361
"to_port": 0
62+
},
63+
{
64+
"from": "tones_map_4",
65+
"from_port": 0,
66+
"to": "combine",
67+
"to_port": 0
68+
},
69+
{
70+
"from": "tones_map_3",
71+
"from_port": 0,
72+
"to": "combine",
73+
"to_port": 1
7474
}
7575
],
7676
"label": "Graph",
@@ -105,7 +105,7 @@
105105
"metallic": 0.0,
106106
"normal": 1.0,
107107
"roughness": 1.0,
108-
"size": 12,
108+
"size": 12.0,
109109
"sss": 1.0
110110
},
111111
"seed_int": 0,
@@ -132,7 +132,7 @@
132132
"parameters": {
133133
"folds": 0.0,
134134
"iterations": 3.0,
135-
"noise": 1,
135+
"noise": 1.0,
136136
"offset": 0.0,
137137
"persistence": 0.5,
138138
"scale_x": 3.0,
@@ -303,7 +303,7 @@
303303
"parameters": {
304304
"folds": 0.0,
305305
"iterations": 4.0,
306-
"noise": 1,
306+
"noise": 1.0,
307307
"offset": 0.0,
308308
"persistence": 0.5,
309309
"scale_x": 3.0,
@@ -333,7 +333,7 @@
333333
"parameters": {
334334
"folds": 0.0,
335335
"iterations": 4.0,
336-
"noise": 1,
336+
"noise": 1.0,
337337
"offset": 0.0,
338338
"persistence": 0.5,
339339
"scale_x": 20.0,

assets/noise/fbm2_3.avif

677 KB
Binary file not shown.

img/visual-comparison/default.avif

1.26 MB
Binary file not shown.

img/visual-comparison/default.png

6.5 MB
Loading
1.34 MB
Binary file not shown.

lang/en.json

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"settings": {
44
"optimize-interface-layer-clipping": {
55
"name": "Optimize Token UI Render Batching",
6-
"hint": "Optimizes render batching of Token UI elements. No visual degredation expected. Needed in order for the other settings to have a noticable impact."
6+
"hint": "Optimizes render batching of Token UI elements. No visual degredation expected. Required in order for the token bars and effects caching settings to have a noticable impact."
77
},
88
"token-bars-caching": {
99
"name": "Cache Token Resource Bars",
@@ -13,6 +13,14 @@
1313
"name": "Cache Token Effects",
1414
"hint": "Caches the token effects bar. Very minor visual degradataion on high zoom levels expected."
1515
},
16+
"precomputed-noise-textures": {
17+
"name": "Optimize animated lights",
18+
"hint": "Optimizes the shader of certain animated lights (Bewitching Wave, Fairy Light, Ghostly Light, Smoke Patch, Swirling Fog, Vortex) by utilizing precomputed FBM noise textures. The visual impact is minimal, but the performance impact is significant, especially on lower-end GPUs."
19+
},
20+
"reduce-lighting-resolution": {
21+
"name": "Scale Lighting Effects Resolution",
22+
"hint": "Reduces the internal resolution of lighting effects to improve performance. This can dramatically improve performance, especially when using many lights or large light sources. The visual impact should be minimal, except for some very high zoom levels and some lighting effects like hexa dome that have very clear outlines. You can configure the render scale for the individual lighting layers in the settings menu."
23+
},
1624
"spritesheet-substitution": {
1725
"name": "Texture Replacement with Spritesheets",
1826
"hint": "Substitutes core SVG icons and other graphic elements with optimized spriteshseets. This can improve performance and resource usage when displaying many UI icons for journals, lights, doors, etc."
@@ -37,9 +45,40 @@
3745
"name": "Dynamic Token Spritesheet Support",
3846
"hint": "Allows tokens with dynamic rings to be replaced with spritesheet textures. This is only needed if you use dynamic token rings and the spritesheet substitution feature to replace token textures."
3947
},
40-
"precomputed-noise-textures": {
41-
"name": "Optimize animated lights",
42-
"hint": "Optimizes the shader of certain animated lights (Bewitching Wave, Fairy Light, Ghostly Light, Smoke Patch, Swirling Fog, Vortex) by utilizing precomputed FBM noise textures."
48+
"disable-app-v2-background-blur": {
49+
"name": "Disable background blur effects",
50+
"hint": "Disables the background blur effects in the app v2 and all other UI elements. This can dramatically improve performance, especially on lower-end GPUs and certain operating systems like MacOS."
51+
},
52+
53+
"custom-render-scale": {
54+
"name": "Lighting Effects Render Scale",
55+
"label": "Configure Render Scale",
56+
"hint": "Configure the rennder scale for lighting effects on the canvas. This can improve performance significantly, especially on lower-end GPUs. Visual impact ranges from unnoticable to very noticable, depending on the effects layer. Activate \"Reduce resolution of lighting effects\" for this configuration to work.",
57+
"menu": {
58+
"title": "Custom Render Scale",
59+
"label": "Custom Render Scale",
60+
"description": "Configure individual render scales for different lighting effects. The render scale is a multiplier for the internal resolution of the lighting effects. A value of 100 means 100% render scale, so no change. A value of 50 means the resolution is halved and so on.",
61+
"confirm": "Confirm",
62+
"cancel": "Reset",
63+
"FIELDS": {
64+
"background": {
65+
"label": "Background",
66+
"hint": "Background effects render scale. High visual impact, minimal performance impact. Optimized default is 100%"
67+
},
68+
"illumination": {
69+
"label": "Illumination",
70+
"hint": "Illumination effects render scale. Very low visual impact, medium performance impact. Optimized default is 40%"
71+
},
72+
"coloration": {
73+
"label": "Coloration",
74+
"hint": "Coloration effects render scale. Medium to very high visual impact, depending on coloration technique. High performance impact. Optimized default is 100%."
75+
},
76+
"darkness": {
77+
"label": "Darkness",
78+
"hint": "Darkness effects render scale. Minimal visual impact, minmal performance impact. Optimized default is 50%"
79+
}
80+
}
81+
}
4382
}
4483
}
4584
}

module.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "fvtt-perf-optim",
33
"title": "Prime Performance",
4-
"version": "0.9.2",
4+
"version": "0.10.0",
55
"description": "Provides a collection of unofficial performance optimizations and hacks for foundry vtt.",
66
"esmodules": ["dist/fvtt-perf-optim.js"],
77
"languages": [
@@ -30,6 +30,7 @@
3030
"flags": {}
3131
}
3232
],
33+
"styles": ["styles/disable-blur.css"],
3334
"compatibility": {
3435
"minimum": "12.324",
3536
"verified": "13.341",

src/apps/CustomRenderScaleMenu.ts

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
import { NAMESPACE } from 'src/constants.ts';
2+
import { configureEffectsResolution } from 'src/hacks/reduceLightingResolution.ts';
3+
import { RENDER_SCALE_DEFAULTS, SETTINGS } from 'src/settings/constants.ts';
4+
import { getSetting } from 'src/settings/settings.ts';
5+
import { FOUNDRY_API } from 'src/utils/foundryShim.ts';
6+
7+
const fields = foundry.data.fields;
8+
9+
export class CustomRenderScaleConfig extends foundry.applications.api.HandlebarsApplicationMixin(
10+
foundry.applications.api.ApplicationV2,
11+
) {
12+
static override DEFAULT_OPTIONS = {
13+
id: 'render-scale-config',
14+
tag: 'form',
15+
window: {
16+
contentClasses: ['standard-form'],
17+
title: `${NAMESPACE}.settings.${SETTINGS.CustomRenderScale}.menu.title`,
18+
icon: 'fa-solid fa-percent',
19+
},
20+
position: {
21+
width: 600,
22+
},
23+
form: {
24+
closeOnSubmit: true,
25+
handler: CustomRenderScaleConfig.#onSubmit,
26+
},
27+
actions: {
28+
reset: CustomRenderScaleConfig.#onReset,
29+
},
30+
};
31+
32+
static override PARTS = {
33+
body: {
34+
template: `modules/${NAMESPACE}/templates/render-resolution-menu.hbs`,
35+
scrollable: [''],
36+
},
37+
footer: {
38+
template: 'templates/generic/form-footer.hbs',
39+
},
40+
};
41+
42+
static #schema = new fields.SchemaField({
43+
background: new fields.NumberField({
44+
required: true,
45+
min: 25,
46+
max: 100,
47+
step: 5,
48+
initial: RENDER_SCALE_DEFAULTS.background,
49+
}),
50+
illumination: new fields.NumberField({
51+
required: true,
52+
min: 25,
53+
max: 100,
54+
step: 5,
55+
initial: RENDER_SCALE_DEFAULTS.illumination,
56+
}),
57+
coloration: new fields.NumberField({
58+
required: true,
59+
min: 25,
60+
max: 100,
61+
step: 5,
62+
initial: RENDER_SCALE_DEFAULTS.coloration,
63+
}),
64+
darkness: new fields.NumberField({
65+
required: true,
66+
min: 25,
67+
max: 100,
68+
step: 5,
69+
initial: RENDER_SCALE_DEFAULTS.darkness,
70+
}),
71+
});
72+
73+
/**
74+
* The data schema for the core.uiConfig setting.
75+
* @type {SchemaField}
76+
*/
77+
static get schema() {
78+
return CustomRenderScaleConfig.#schema;
79+
}
80+
81+
static #localized = false;
82+
83+
/** @inheritDoc */
84+
override async _preFirstRender(_context: any, _options: any) {
85+
const LocalizationHelper: Localization = FOUNDRY_API.generation >= 13 ? foundry.helpers.Localization : Localization;
86+
await super._preFirstRender(_context, _options);
87+
88+
if (!CustomRenderScaleConfig.#localized) {
89+
LocalizationHelper.localizeDataModel(
90+
{ schema: CustomRenderScaleConfig.#schema },
91+
{ prefixes: ['fvtt-perf-optim.settings.custom-render-scale.menu'] },
92+
);
93+
CustomRenderScaleConfig.#localized = true;
94+
}
95+
}
96+
97+
#setting: typeof RENDER_SCALE_DEFAULTS | undefined;
98+
99+
override async _prepareContext(options: any) {
100+
if (options.isFirstRender) {
101+
this.#setting = getSetting<typeof RENDER_SCALE_DEFAULTS>(SETTINGS.CustomRenderScale) ?? RENDER_SCALE_DEFAULTS;
102+
}
103+
104+
return {
105+
renderScale: this.#setting,
106+
fields: CustomRenderScaleConfig.#schema.fields,
107+
buttons: [
108+
{
109+
type: 'button',
110+
label: `${NAMESPACE}.settings.${SETTINGS.CustomRenderScale}.menu.cancel`,
111+
icon: 'fa-solid fa-arrow-rotate-left',
112+
action: 'reset',
113+
},
114+
{
115+
type: 'submit',
116+
label: `${NAMESPACE}.settings.${SETTINGS.CustomRenderScale}.menu.confirm`,
117+
icon: 'fa-solid fa-check',
118+
action: 'confirm',
119+
},
120+
],
121+
};
122+
}
123+
124+
static async #onSubmit() {
125+
game.settings.set(NAMESPACE, SETTINGS.CustomRenderScale, this.#setting);
126+
const enabled = getSetting<boolean>(SETTINGS.ReduceLightingResolution);
127+
configureEffectsResolution(enabled ? this.#setting : null);
128+
}
129+
130+
static async #onReset() {
131+
this.#setting = RENDER_SCALE_DEFAULTS;
132+
}
133+
134+
override _onClose(options: any) {
135+
super._onClose(options);
136+
if (!options.submitted) {
137+
const enabled = getSetting<boolean>(SETTINGS.ReduceLightingResolution);
138+
const renderScale = getSetting<typeof RENDER_SCALE_DEFAULTS>(SETTINGS.CustomRenderScale);
139+
configureEffectsResolution(enabled ? renderScale : null);
140+
}
141+
}
142+
143+
/* -------------------------------------------- */
144+
145+
/** @override */
146+
override _onChangeForm(_formConfig: any, _event: any) {
147+
const FormDataExtendedConstructor =
148+
FOUNDRY_API.generation >= 13 ? foundry.applications.ux.FormDataExtended : FormDataExtended;
149+
150+
const formData = new FormDataExtendedConstructor(this.form);
151+
152+
this.#setting = foundry.utils.expandObject(formData.object) as typeof RENDER_SCALE_DEFAULTS;
153+
configureEffectsResolution(this.#setting);
154+
}
155+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { SETTINGS } from 'src/settings/constants.ts';
2+
import { getSetting } from 'src/settings/settings.ts';
3+
4+
function enableDisableAppBackgroundBlur() {
5+
const enabled = getSetting<boolean>(SETTINGS.DisableAppV2BackgroundBlur);
6+
7+
if (!enabled) {
8+
return;
9+
}
10+
11+
toggleDisableAppBackgroundBlur(enabled);
12+
}
13+
14+
function toggleDisableAppBackgroundBlur(enabled: boolean) {
15+
if (enabled) {
16+
document.body.classList.add('disable-app-background-blur');
17+
} else {
18+
document.body.classList.remove('disable-app-background-blur');
19+
}
20+
}
21+
22+
export { enableDisableAppBackgroundBlur, toggleDisableAppBackgroundBlur };

0 commit comments

Comments
 (0)