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

How to increase R3F project performance? #5

Open
doyen001 opened this issue Jan 14, 2025 · 0 comments
Open

How to increase R3F project performance? #5

doyen001 opened this issue Jan 14, 2025 · 0 comments

Comments

@doyen001
Copy link
Owner

1. Reduce Draw Calls
Problem: Too many objects/materials in the scene can hammer the GPU.
Solution:

Merge Geometries: Combine static meshes (e.g., using three.js BufferGeometryUtils.mergeBufferGeometries). This reduces the number of draw calls.
Instancing: Use InstancedMesh if you have repeating objects (like trees or rocks).

2. Optimize Materials and Textures
Problem: Shaders, large textures, and transparency can be heavy on the GPU.
Solutions:

Use THREE.MeshBasicMaterial: For non-dynamic objects without lighting needs, skip the shader-heavy MeshStandardMaterial.
Compress Textures: Use .ktx2 or .basis textures with THREE.KTX2Loader for GPU-friendly compression. Alternatively, tools like squoosh can help.
Use Lower Texture Resolutions: Ask yourself, does that 4K texture really need to be 4K? (Spoiler: It probably doesn’t.)

3. Culling & Frustum Management
Problem: Rendering objects the user can’t see is a waste of resources.
Solutions:

Frustum Culling: R3F automatically culls objects outside the camera's view, but ensure objects’ frustumCulled is true.
LOD (Level of Detail): Use lower-poly versions of far-away objects.

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

No branches or pull requests

1 participant