Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(performance): ACT-1219 performance optimisations #109

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Jarvv
Copy link
Contributor

@Jarvv Jarvv commented Dec 19, 2024

Ticket: https://ready-player-me.atlassian.net/jira/software/c/projects/ACT/boards/46?selectedIssue=ACT-1219

Recommendations for integration optimisation:

  • Keep canvas size at a limited width, especially important at 4k screens. If we don't need to show the full canvas, then the canvas size can be adjusted to fit around the avatar. Taking into account attachments such as wings, or zooming in/out
  • Base DPR could be < 1, lower values greatly reduce gpu load however this should be balanced with visual fidelity. Perhaps these values should be higher in 'editors' rather than just 'viewers' for instance.

Example with PlayerZero:
before:
Screenshot 2024-12-19 161418

after:
Screenshot 2024-12-19 163246
Screenshot 2024-12-19 163706

by setting the canvas size appropriately (this will be too much but as an example), we can easily reduce GPU usage by 4%.

fade={0.02}
rings={8}
/>
<N8AO quality="performance" aoRadius={5} distanceFalloff={0.25} intensity={3} screenSpaceRadius halfRes />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing with a more performant ao

@@ -363,7 +357,7 @@ const Avatar: FC<AvatarProps> = ({
/>
)}
{effects?.vignette && <Vignette eskil={false} offset={0.5} darkness={0.5} />}
<BrightnessContrast brightness={0.025} contrast={0.25} />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently bugged alongside the ao causing white flickering, will see if there is a fix available rather than outright removing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reintroduced with a small increase instead.

@@ -22,16 +23,17 @@ export const BaseCanvas: FC<BaseCanvasProps> = ({
fov = 50,
position = new Vector3(0, 0, 5),
style,
dpr = [BASE_DPR * 0.5, 2],
className
dpr = [BASE_DPR * 0.5, BASE_DPR * 0.75],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing with reduced dpr values, probably wont be final

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might set the top range to 1, then we can handover implementation details on the best value(s)

@@ -67,10 +67,8 @@ export const Model: FC<ModelProps> = ({

if ((node as Mesh).isMesh) {
node.castShadow = true;
}

if (node.type === 'SkinnedMesh') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As attachments are Mesh, lets not differentiate between mesh and skinnedmesh.

@@ -18,6 +18,7 @@ export const AvatarDevelop: React.FC = () => (
effects={{
ambientOcclusion: true
}}
canvasConfig={{ alpha: false }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alpha can be turned off for scenes which don't need.

@@ -102,7 +100,6 @@ const Lights: FC<LightingProps> = (lightingProps) => {
angle={LIGHT_CONFIG.silhouetteLightAngle}
color={keyLightColor}
intensity={keyLightIntensity * 0.25}
castShadow
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed castShadow from lights which shadows don't have an effect.

@@ -348,28 +355,17 @@ const Avatar: FC<AvatarProps> = ({
/>
{AvatarModel}
{children}
{shadows && <ContactShadows position={[0, 0, 0]} opacity={2} scale={10} blur={1.0} far={1.0} />}
{shadows && (
<ContactShadows opacity={effects?.ambientOcclusion ? 1 : 2} scale={4} blur={2} far={1.0} resolution={256} />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ao and shadows don't behave well together, change the oopacity values depending on if its enabled or not.

@Jarvv Jarvv marked this pull request as ready for review December 19, 2024 16:54
@Jarvv Jarvv requested a review from a team as a code owner December 19, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant