Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
IR-1439-Scene-Render-Quality-Dropping-Unexpectedly-with-Automatic-Ren…
Browse files Browse the repository at this point in the history
…der-Settings (#10246)

* Start of reworking render quality change parameters

* wip

* Smoothing fix

* Single source of truth for quality tier, csm update frustrum quality flag

* Override performance tier with user settings, render scale as performance setting

* Store any value that can be serialized

* Accumulator instead of timeout

* Reactive cameraOcclusion in model component

* Measure logic behind automatic flag

* Better tracking of GPU status

* enabled flag

* remove unused variables

* remove unused variable

---------

Co-authored-by: HexaField <[email protected]>
  • Loading branch information
MichaelEstes and HexaField authored Jun 3, 2024
1 parent e81bdcd commit c87de3e
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 162 deletions.
2 changes: 1 addition & 1 deletion packages/client-core/i18n/en/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"lbl-left-control-scheme": "Left Control Scheme",
"lbl-right-control-scheme": "Right Control Scheme",
"lbl-preferred-hand": "Preferred Hand",
"lbl-resolution": "Resolution",
"lbl-quality": "Quality Preset",
"lbl-shadow": "Shadows",
"lbl-pp": "Post Processing",
"lbl-pbr": "Full PBR",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,9 @@ const SettingMenu = ({ isPopover }: Props): JSX.Element => {
<>
<InputSlider
icon={<Icon type="BlurLinear" sx={{ ml: '-3px' }} />}
label={t('user:usermenu.setting.lbl-resolution')}
label={t('user:usermenu.setting.lbl-quality')}
max={5}
min={1}
min={0}
step={1}
value={rendererState.qualityLevel.value}
sx={{ mt: 4 }}
Expand Down
17 changes: 5 additions & 12 deletions packages/engine/src/scene/components/ModelComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ import { CameraComponent } from '@etherealengine/spatial/src/camera/components/C
import { RendererComponent } from '@etherealengine/spatial/src/renderer/WebGLRendererSystem'
import { GroupComponent, addObjectToGroup } from '@etherealengine/spatial/src/renderer/components/GroupComponent'
import { MeshComponent } from '@etherealengine/spatial/src/renderer/components/MeshComponent'
import {
ObjectLayerComponents,
ObjectLayerMaskComponent
} from '@etherealengine/spatial/src/renderer/components/ObjectLayerComponent'
import { ObjectLayerMaskComponent } from '@etherealengine/spatial/src/renderer/components/ObjectLayerComponent'
import { ObjectLayers } from '@etherealengine/spatial/src/renderer/constants/ObjectLayers'
import {
EntityTreeComponent,
Expand Down Expand Up @@ -118,14 +115,10 @@ function ModelReactor() {
const [gltf, error] = useGLTF(modelComponent.src.value, entity)

useEffect(() => {
const occlusion =
!!modelComponent?.cameraOcclusion?.value || hasComponent(entity, ObjectLayerComponents[ObjectLayers.Camera])
if (!occlusion) return
ObjectLayerMaskComponent.enableLayer(entity, ObjectLayers.Camera)
return () => {
ObjectLayerMaskComponent.disableLayer(entity, ObjectLayers.Camera)
}
}, [modelComponent?.cameraOcclusion?.value])
const occlusion = modelComponent.cameraOcclusion.value
if (!occlusion) ObjectLayerMaskComponent.disableLayer(entity, ObjectLayers.Camera)
else ObjectLayerMaskComponent.enableLayer(entity, ObjectLayers.Camera)
}, [modelComponent.cameraOcclusion])

useEffect(() => {
if (!error) return
Expand Down
6 changes: 4 additions & 2 deletions packages/hyperflux/functions/StateFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ export function syncStateWithLocalStorage<S, E extends Identifiable>(
onSet: (state, desc) => {
for (const key of keys) {
const storageKey = `${stateNamespaceKey}.${rootState.identifier}.${key}`
if (!rootState[key] || !rootState[key].get(NO_PROXY)) localStorage.removeItem(storageKey)
else localStorage.setItem(storageKey, JSON.stringify(rootState[key].get(NO_PROXY)))
const value = rootState[key]?.get(NO_PROXY)
// We should still store flags that have been set to false or null
if (value === undefined) localStorage.removeItem(storageKey)
else localStorage.setItem(storageKey, JSON.stringify(value))
}
}
} as any
Expand Down
14 changes: 7 additions & 7 deletions packages/spatial/src/renderer/PerformanceState.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ describe('PerformanceState', () => {
mockRenderer,
() => {
const performanceState = getState(PerformanceState)
const budgets = performanceState.budgets
assert(budgets.max3DTextureSize === 1000)
assert(budgets.maxBufferSize === 54000000000)
assert(budgets.maxIndices === 8000)
assert(budgets.maxTextureSize === 2000)
assert(budgets.maxVerticies === 10000)
assert(performanceState.max3DTextureSize === 1000)
assert(performanceState.maxBufferSize === 54000000000)
assert(performanceState.maxIndices === 8000)
assert(performanceState.maxTextureSize === 2000)
assert(performanceState.maxVerticies === 10000)
done()
},
{ renderer: 'nvidia corporation, nvidia geforce rtx 3070/pcie/sse2, ' }
Expand Down Expand Up @@ -176,8 +175,9 @@ describe('PerformanceState', () => {
const { rerender, unmount } = render(<Reactor />)
const clock = sinon.useFakeTimers()
act(async () => {
// Decrementing performance state twice consecutively should only have one reactive change with the value off by 1 instead of 2
PerformanceManager.decrementGPUPerformance()
PerformanceManager.decrementGPUPerformance()
PerformanceManager.incrementGPUPerformance()
clock.tick(3000)
rerender(<Reactor />)
clock.restore()
Expand Down
Loading

0 comments on commit c87de3e

Please sign in to comment.