toji / webgpu-bundle-culling

A WebGPU demonstration of using frustum culling with render bundles through indirect instanced draw calls.
MIT License
32 stars 4 forks source link

CULLING_SHADER may be run in renderModels.naive ? #2

Open Davidyanlong opened 4 months ago

Davidyanlong commented 4 months ago

CULLING_SHADER may be run in renderModels.naive? How is the performance?

Do you have any better suggestions for Frustum Culling?

toji commented 3 months ago

I'm not sure what you mean by "CULLING_SHADER may be run in renderModels.naive?" Are you saying that it's running when it shouldn't be? I reviewed the code and it's only being invoked when one of the culling modes is active (see https://github.com/toji/webgpu-bundle-culling/blob/main/index.html#L736). It does CREATE the pipeline no matter what mode you start with, but that's just to prevent stutter when switching modes.

Or are you asking if the culling shader can be run with the naive mode? In that case the answer is "yes" but it won't actually provide any benefit.

In terms of performance I find that GPU culling in this way is pretty fast, though obviously it'll vary depending on the scene. The biggest performance tip I've found so far is to try and do as much of the culling as possible in a single compute dispatch, which implies that the data necessary for culling is all kept in a single buffer. That can be a bit tricky to manage, but the benefit of avoiding the overhead of multiple dispatches is probably worth it!