ldl19691031 / AddMeshPassPlugin

MIT License
24 stars 2 forks source link

Nanite static mesh not showing up in RT_Output #1

Open NicoBrug opened 3 months ago

NicoBrug commented 3 months ago

Hello,

Thank you very much for this very interesting repos. I made some tests, I realized that if the mesh was in nanite, was not showing up in RT_Output. Do you have any idea where this could be coming from? Thanks !

ldl19691031 commented 3 months ago

Hello! @NicoBrug

I realized that if the mesh was in nanite, was not showing up in RT_Output. Do you have any idea where this could be coming from?

Short answer: This is because the Nanite mesh should ONLY be rendered by the Nanite render pass, instead of a simple mesh render pass. The easiest way is just avoid using use Nanite mesh if you want to use the proposed method.

As I know, there is no way to easily execute an individual Nanite mesh render pass. If you really want to do this:

NicoBrug commented 3 months ago

Hi, thanks for the answer.

Similarly, if I want to display skeletals, for example, this doesn't work either. (logic was not implemented but i think it's feasible)

According to Epic's doc: "FPrimitiveSceneProxy has two paths for generating FMeshBatches - one cached and one dynamic. FPrimitiveSceneProxy implementations control the path used for each image via the GetViewRelevance() function. "

I imagine the implementation does in the plugin used only the first way, it is correct ?

cf PostRenderBasePassDeferred_RenderThread

int32 LODIndex = 0;
TArray<FMeshBatch> MeshElements;
primitive->GetMeshDescription(LODIndex, MeshElements);

Do you think it would be possible to dynamically retrieve MeshBatches from skeletal meshes?

(I've made a few modifications to the plugin to be able to retrieve all proxy primitives in the scene instead of using a custom static mesh component).

ldl19691031 commented 3 months ago

Hello @NicoBrug

I checked the source code and tried to find a simple way to render a skeletal mesh ONLY inside a plugin, but to be honest I didn't find an easy way to do this. Maybe there is one but I just don't know that. As I mentioned, I proposed this plugin which should only be used as a prototype tool. In my personal projects, I used this to render only static meshes.

But to answer your question:

According to Epic's doc: "FPrimitiveSceneProxy has two paths for generating FMeshBatches - one cached and one dynamic. FPrimitiveSceneProxy implementations control the path used for each image via the GetViewRelevance() function. " I imagine the implementation in the plugin used only the first way, it is correct ?

Actually, the two paths are both more complex than this plugin's way. And if you try this:

Do you think it would be possible to dynamically retrieve MeshBatches from skeletal meshes?

If you check FSkeletalMeshSceneProxy::DrawStaticElements you will see how the skeletal meshes build its mesh batch. The limitation is how could we do the same thing but with the limitation of only inside a plugin. In my work, I can directly touch the engine's source code and add a pass, which automatically supports both static and skeletal meshes. So that's why in my blog I said if you want to use this in a production, you should consider directly adding a custom pass to the engine.

I hope my answer will help you, and if you find a better way, please also teach me!