diff --git a/src/optionsStorage.ts b/src/optionsStorage.ts index 0256c81b7..1c90bb305 100644 --- a/src/optionsStorage.ts +++ b/src/optionsStorage.ts @@ -52,6 +52,7 @@ const defaultOptions = { // antiAliasing: false, + webgpuRendererParams: {}, clipWorldBelowY: undefined as undefined | number, // will be removed disableSignsMapsSupport: false, singleplayerAutoSave: false, diff --git a/src/watchOptions.ts b/src/watchOptions.ts index 82a594ec6..1ace647b0 100644 --- a/src/watchOptions.ts +++ b/src/watchOptions.ts @@ -3,6 +3,7 @@ import { subscribeKey } from 'valtio/utils' import { WorldRendererThree } from 'prismarine-viewer/viewer/lib/worldrendererThree' import { isMobile } from 'prismarine-viewer/viewer/lib/simpleUtils' +import { WorldRendererWebgpu } from 'prismarine-viewer/viewer/lib/worldrendererWebgpu' import { options, watchValue } from './optionsStorage' import { reloadChunks } from './utils' import { miscUiState } from './globalState' @@ -96,6 +97,15 @@ export const watchOptionsAfterViewerInit = () => { watchValue(options, o => { viewer.powerPreference = o.gpuPreference }) + + if (viewer.world instanceof WorldRendererWebgpu) { + Object.assign(viewer.world.rendererParams, options.webgpuRendererParams) + const oldUpdateRendererParams = viewer.world.updateRendererParams.bind(viewer.world) + viewer.world.updateRendererParams = (...args) => { + oldUpdateRendererParams(...args) + Object.assign(options.webgpuRendererParams, viewer.world.rendererParams) + } + } } let viewWatched = false