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

[New3D] Patch THREE.js to improve custom shader performance #4021

Merged
merged 6 commits into from
Aug 4, 2022

Conversation

jhurliman
Copy link
Contributor

User-Facing Changes

  • Improved 3D (Beta) TEXT_VIEW_FACING rendering performance

Description

For custom shaders, THREE.js uses the internal WebGLShaderCache class which contains a Map<string, WebGLShaderStage> where the keys are vertex and fragment shader source code. This change patches THREE.js (via yarn patch) to use Material#vertexShaderKey and/or Material#fragmentShaderKey properties as map keys when available. The cache lookup methods have also been rewritten to avoid unnecessary lookups.

These new properties are used to speed up shader execution for TEXT_VIEW_FACING markers (RenderableTextViewFacing). Performance tracing shows a ~30% reduction in frame times in the synthetic label benchmark on my machine after this change.

@jhurliman jhurliman requested a review from jtbandes August 3, 2022 00:23
@defunctzombie
Copy link
Contributor

Performance tracing shows a ~30% reduction in frame times in the synthetic label benchmark on my machine after this change.

Were you able to use the benchmark player to see the same improvements?

packages/three-text/src/LabelPool.ts Outdated Show resolved Hide resolved
@jtbandes
Copy link
Member

jtbandes commented Aug 4, 2022

Have we searched for existing github issues on three.js about this performance concern? I think we should file one if there isn't one already, so that they are aware of the problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants