agargaro / instanced-mesh

Enhanced InstancedMesh with frustum culling, fast raycasting (using BVH), sorting, visibility management, LOD and more.
MIT License
132 stars 9 forks source link

Incompatible with WebGPURenderer? #40

Open ligaofeng0901 opened 5 days ago

ligaofeng0901 commented 5 days ago

It seems that if the renderer is WebGPURenderer, it doesn't work.

agargaro commented 5 days ago

It is currently only compatible with WebGLRenderer.

I still have to study how WebGPURenderer works, but I think many things will be done differently. For example, frustum culling without BVH will be performed on GPU instead of CPU.

I would be happy if someone experienced would like to contribute.

ligaofeng0901 commented 5 days ago

It is currently only compatible with WebGLRenderer.

I still have to study how WebGPURenderer works, but I think many things will be done differently. For example, frustum culling without BVH will be performed on GPU instead of CPU.

I would be happy if someone experienced would like to contribute.

Thanks! If we only consider make it compatible with WebGPURenderer , it will not cost too much time. But If we want optimize it with some features of WebGPU, I think some modules need refactor.

agargaro commented 4 days ago

Having a working basic version would be great. :D

I think the main things to change are:

1) do not modify the shader using Material.onBeforeCompile. We have to use an alternative method to be able to read instanceId from a texture.

2) don't use GLInstancedBufferAttribute and figure out how to modify an attribute inside onBeforeRender. I had to use GLInstancedBufferAttribute because otherwise the attribute update would run the next frame, causing incorrect frustum culling.

3) Figure out how to get setUniformAt to work.