Skip to content

Comments

[DRAFT, DO-NOT-MERGE] Instancing for skeletal meshes#281

Draft
kirides wants to merge 18 commits intomasterfrom
feat/next_try_skel_instancing
Draft

[DRAFT, DO-NOT-MERGE] Instancing for skeletal meshes#281
kirides wants to merge 18 commits intomasterfrom
feat/next_try_skel_instancing

Conversation

@kirides
Copy link
Owner

@kirides kirides commented Feb 9, 2026

This PR tries to implement instanced rendering for skeletal mesh vobs by batching them by mesh and texture.

also upload all bone transforms for each batch only a single time.

In current tests this PR can achieve up to 10-20% better performance, by issuing a lot less draw calls.

Gothic 2 Marketplace area goes from 100 to roundabout 127 FPS.
This is mostly achieved by drastically reducing the amount of setup and drawcalls needed to draw MOBs.
Though also NPCs are batched, which improves performance especially in cases where a lot of monsters of the same kind are shown.

  • with the improved frustum culling from Improve (Shadow) Frustumculling #285 the improvements are less noticable, but still account to about 5-10% more fps and less CPU/GPU usage for the same fps
  • mesh Buffers and vectors are stored only once per occuring mesh where possible.
    • if 10 NPCs share the same body but wear different armor, we only store the body mesh data once and re-use shared data.

@kirides kirides force-pushed the feat/next_try_skel_instancing branch 7 times, most recently from 0944e05 to 92f6748 Compare February 16, 2026 14:16
@kirides kirides force-pushed the feat/next_try_skel_instancing branch from 716e76e to cbf336e Compare February 17, 2026 18:15
…bs and made it extensible, "automatic" reset of seen-vobs after BSP traversal
…way, which MAY help with lower end GPUs on high end CPUs
…e some values for less constant buffer uploads
batching: fix rendering because of broken view matrix, shortcut for single instance

clean up some residue

fix node batches fluctuating, simplify unordered_map usage

use meshlib to identify duplicate meshes, aswell as zCProgMeshProto->progId which should be unique-enough

clean up hashing, also use progid for skeletal meshes like wolfs and npcs

make skeletal batch key texture aware.

use hash_combine

ensure we call UpdateMeshLibTexAniState before accessing GetAniTexture(), use std::string_view for hashing

add memory locations for G1 and G2, ensure updated mm->GetTexAniState()->UpdateTexList(); for batched attachments

disable skeletal mesh batching for g1 sequel builds

ensure all cascadeCRs are populated ahead of time

work on top of motion vectors

fix ide warning due to static friend

rebase on per-object-velocity, fix indoor vobs being drawn when outdoors, don't rely as much on global WorldTransform

fix merge conflicts, batch more meshes when rendering shadows, as we mostly dont need textures

do some performance profiling, reduce need to cull against frustum, beginnings of trying to implement a renderqueue

add todo

things
…vob-kind, share index and vertex buffers for skeletal meshes globally
@kirides kirides force-pushed the feat/next_try_skel_instancing branch from 97133a5 to 5670dc0 Compare February 20, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant