From 1db408795042da041c4b6c8efaf018e2e31b61b3 Mon Sep 17 00:00:00 2001 From: James Harvey Date: Wed, 18 Dec 2024 16:59:32 +0000 Subject: [PATCH] fix(performance): ACT-1219 shadow and ao tweaks --- src/App/components/Nova.tsx | 3 +++ src/components/Avatar/Avatar.component.tsx | 25 +++++-------------- .../Background/Box/Box.component.tsx | 2 +- .../BaseCanvas/BaseCanvas.component.tsx | 5 ++-- src/components/Exhibit/Exhibit.component.tsx | 2 +- src/components/Lights/Lights.component.tsx | 5 ---- .../EnvironmentModel.component.tsx | 1 - .../Models/Model/Model.component.tsx | 9 +++---- src/components/Shadow/Shadow.component.tsx | 12 --------- src/services/Models.service.tsx | 4 --- 10 files changed, 16 insertions(+), 52 deletions(-) delete mode 100644 src/components/Shadow/Shadow.component.tsx diff --git a/src/App/components/Nova.tsx b/src/App/components/Nova.tsx index e2c2d880..267d45cc 100644 --- a/src/App/components/Nova.tsx +++ b/src/App/components/Nova.tsx @@ -74,6 +74,9 @@ export const AvatarNova: FC = () => { style={{ background: 'rgb(9,20,26)' }} fov={45} cameraInitialDistance={CAMERA.CONTROLS.FULL_BODY.MAX_DISTANCE} + effects={{ + ambientOcclusion: false + }} > diff --git a/src/components/Avatar/Avatar.component.tsx b/src/components/Avatar/Avatar.component.tsx index ac5b8fb5..83342713 100644 --- a/src/components/Avatar/Avatar.component.tsx +++ b/src/components/Avatar/Avatar.component.tsx @@ -16,14 +16,14 @@ import { BaseCanvas } from 'src/components/BaseCanvas'; import { AnimationModel, HalfBodyModel, StaticModel, PoseModel, MultipleAnimationModel } from 'src/components/Models'; import { isValidFormat, triggerCallback } from 'src/services'; import { Dpr } from '@react-three/fiber'; -import { BrightnessContrast, EffectComposer, HueSaturation, SSAO, Vignette } from '@react-three/postprocessing'; +import { EffectComposer, HueSaturation, N8AO, Vignette } from '@react-three/postprocessing'; import { Provider, useSetAtom } from 'jotai'; import Capture, { CaptureType } from 'src/components/Capture/Capture.component'; import { Box, Background } from 'src/components/Background/Box/Box.component'; import { BackgroundColor } from 'src/components/Background'; import Loader from 'src/components/Loader'; import Bloom from 'src/components/Bloom/Bloom.component'; -import { BlendFunction } from 'postprocessing'; + import Lights from 'src/components/Lights/Lights.component'; import { spawnState } from 'src/state/spawnAtom'; @@ -330,28 +330,15 @@ const Avatar: FC = ({ /> {AvatarModel} {children} - {shadows && } + {shadows && } {background?.src && } {capture && } {background?.color && } {enablePostProcessing && ( - + <> {effects?.ambientOcclusion && ( - + )} {effects?.bloom && ( = ({ /> )} {effects?.vignette && } - + diff --git a/src/components/Background/Box/Box.component.tsx b/src/components/Background/Box/Box.component.tsx index 13f757f2..79b4d0a5 100644 --- a/src/components/Background/Box/Box.component.tsx +++ b/src/components/Background/Box/Box.component.tsx @@ -10,7 +10,7 @@ export const Box: FC = ({ src = '', ...baseProps }) => { const texture = useLoader(TextureLoader, src); return ( - + diff --git a/src/components/BaseCanvas/BaseCanvas.component.tsx b/src/components/BaseCanvas/BaseCanvas.component.tsx index 7e9b1677..e4b1428c 100644 --- a/src/components/BaseCanvas/BaseCanvas.component.tsx +++ b/src/components/BaseCanvas/BaseCanvas.component.tsx @@ -22,18 +22,17 @@ export const BaseCanvas: FC = ({ fov = 50, position = new Vector3(0, 0, 5), style, - dpr = [BASE_DPR * 0.5, 2], + dpr = [BASE_DPR * 0.5, BASE_DPR * 0.75], className }) => ( = ({ - + = (lightingProps) => { angle={LIGHT_CONFIG.fillLightAngle} color={fillLightColor} intensity={fillLightIntensity} - castShadow /> {/* Back light that by default creates light warm rim on the left face side. */} = (lightingProps) => { angle={LIGHT_CONFIG.backLightAngle} color={backLightColor} intensity={backLightIntensity} - castShadow /> {/* Key light that creates soft face light. */} = (lightingProps) => { angle={LIGHT_CONFIG.keyLightAngle} color={keyLightColor} intensity={keyLightIntensity} - castShadow /> {/* Lift light that creates soft light on body and shoes. */} = (lightingProps) => { angle={LIGHT_CONFIG.keyLightAngle} color={keyLightColor} intensity={keyLightIntensity * 0.25} - castShadow /> {/* Silhouette light on arms and legs. */} = (lightingProps) => { angle={LIGHT_CONFIG.silhouetteLightAngle} color={keyLightColor} intensity={keyLightIntensity * 0.25} - castShadow /> ); diff --git a/src/components/Models/EnvironmentModel/EnvironmentModel.component.tsx b/src/components/Models/EnvironmentModel/EnvironmentModel.component.tsx index afefe049..d56999c2 100644 --- a/src/components/Models/EnvironmentModel/EnvironmentModel.component.tsx +++ b/src/components/Models/EnvironmentModel/EnvironmentModel.component.tsx @@ -24,7 +24,6 @@ export const EnvironmentModel: FC = ({ environment, scale if (node.type === 'Mesh') { return ( = ({ scene.traverse((object) => { const node = object; - if ((node as Mesh).isMesh) { - node.castShadow = true; - } - if (node.type === 'SkinnedMesh') { - node.receiveShadow = true; + node.frustumCulled = false; } }); @@ -110,3 +106,4 @@ export const Model: FC = ({ ); }; + diff --git a/src/components/Shadow/Shadow.component.tsx b/src/components/Shadow/Shadow.component.tsx deleted file mode 100644 index e61e82e7..00000000 --- a/src/components/Shadow/Shadow.component.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import React, { FC } from 'react'; - -const Shadow: FC = () => ( - - - - - - -); - -export default Shadow; diff --git a/src/services/Models.service.tsx b/src/services/Models.service.tsx index 6ea94fe1..2bc36c09 100644 --- a/src/services/Models.service.tsx +++ b/src/services/Models.service.tsx @@ -394,8 +394,6 @@ function buildFallback(nodes: Nodes, transform: Transform = new Transform()): JS if (node.type === 'SkinnedMesh') { return ( parent.remove(self); }} - castShadow - receiveShadow key={node.name} scale={node.scale} position={node.position}