Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Suggestion / Idea  Feature request: API to get the mesh from FluidMesher
#1
My use case is that I'm working on my own custom fluid shader. The workflow is tedious: Press Play -> Wait for the simulation until the fluid gets to a certain shape I'd like to inspect the shader for -> Tweak the shader.

I figured that if I dump the mesh from BurstFluidMesherSystem as an Unity asset, it would make iterating on the shader much faster. So I added this API:

Code:
public List<Mesh> DumpMeshes_Editor()
{
        var meshes = new List<Mesh>();
        for (int i = 0; i < batchCount; i++)
        {
            var batch = batchList[i];
            meshes.Add(batch.mesh);
        }

        return meshes;
}
/// then save the mesh with AssetDatabase.CreateAsset...

It works. I kinda hope it's officially supported tho, cause 1. I don't know if it's the correct way to do it 2. It's not that easy for Compute backend as the mesh only lives in GPU (I suppose).
Reply
#2
(09-04-2024, 02:48 AM)kodra Wrote: My use case is that I'm working on my own custom fluid shader. The workflow is tedious: Press Play -> Wait for the simulation until the fluid gets to a certain shape I'd like to inspect the shader for -> Tweak the shader.

I figured that if I dump the mesh from BurstFluidMesherSystem as an Unity asset, it would make iterating on the shader much faster. So I added this API:

Code:
public List<Mesh> DumpMeshes_Editor()
{
        var meshes = new List<Mesh>();
        for (int i = 0; i < batchCount; i++)
        {
           var batch = batchList[i];
           meshes.Add(batch.mesh);
        }

        return meshes;
}
/// then save the mesh with AssetDatabase.CreateAsset...

It works. I kinda hope it's officially supported tho, cause 1. I don't know if it's the correct way to do it 2. It's not that easy for Compute backend as the mesh only lives in GPU (I suppose).

Hi,

This is a planned feature. All other ObiActors (Ropes, Cloth, Softbodies) currently support exposing the mesh, by right clicking on the Renderer component (ObiRopeExtrudedRenderer, ObiClothRenderer, etc) and selecting "Bake Mesh". Works both for Burst and Compute (in the case of the Compute backend, we read the mesh back from the GPU before exporting it). We'll add it to fluid emitters shortly.

Your code will export all fluid emitters in a solver, many of them fused into a single mesh as batches contain all fluid meshes sharing the same fluid rendering pass. That, and that it will only work when using Burst.

kind regards,
Reply