{"id":14959767,"url":"https://github.com/unity-technologies/meshapiexamples","last_synced_at":"2025-04-04T20:11:38.904Z","repository":{"id":41295464,"uuid":"226815474","full_name":"Unity-Technologies/MeshApiExamples","owner":"Unity-Technologies","description":"Example project for Unity 2020.1 Mesh API improvements","archived":false,"fork":false,"pushed_at":"2023-03-08T08:14:50.000Z","size":707,"stargazers_count":729,"open_issues_count":4,"forks_count":47,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-03-28T19:08:09.851Z","etag":null,"topics":["procedural-meshes","unity3d"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Unity-Technologies.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-12-09T07:54:49.000Z","updated_at":"2025-03-27T09:35:28.000Z","dependencies_parsed_at":"2024-03-02T05:44:34.653Z","dependency_job_id":null,"html_url":"https://github.com/Unity-Technologies/MeshApiExamples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unity-Technologies%2FMeshApiExamples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unity-Technologies%2FMeshApiExamples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unity-Technologies%2FMeshApiExamples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unity-Technologies%2FMeshApiExamples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Unity-Technologies","download_url":"https://codeload.github.com/Unity-Technologies/MeshApiExamples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242679,"owners_count":20907134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["procedural-meshes","unity3d"],"created_at":"2024-09-24T13:20:44.638Z","updated_at":"2025-04-04T20:11:38.869Z","avatar_url":"https://github.com/Unity-Technologies.png","language":"C#","readme":"# Unity 2020.1 Mesh API improvements examples\n\nUnity 2020.1 adds `MeshData` APIs for C# Jobs/Burst compatible way of reading \u0026 writing Mesh data; see [overview document](https://docs.google.com/document/d/1QC7NV7JQcvibeelORJvsaTReTyszllOlxdfEsaVL2oA/edit).\n\nThis repository contains several small examples of that. Required Unity version is **2020.1** or later.\n\nWhen on Unity 2021.2 or later version, the examples also show how to use GPU Compute Shaders to\naccess and modify Mesh vertex buffers.\n\n## Procedural Water/Wave Mesh\n\nA simple example where a dense \"water\" surface mesh is updated every frame, based on positions on \"wave source\" objects.\n\n![Water](/Images/Water.png?raw=true \"Water\")\n\n`Assets/ProceduralWaterMesh` is the sample scene and code. Each vertex of the resulting mesh is completely independent of others, and\nonly depends on positions of the \"wave source\" objects.\nUsing C# Job System and Burst to compute all vertex positions in parallel brings\nsome nice speedups. The sample also implements a similar computation using a GPU compute\nshader to modify the Mesh vertex buffer, for comparison.\n\nFrame times on 400x400 water mesh, with 10 wave source objects, on 2019 MacBookPro (Core i9 2.4GHz, Radeon Pro 5500M); note that these are full frame times including rendering:\n\n- Single threaded C#: 155ms\n- Single threaded Burst: 38ms\n- Multi threaded Burst: 9ms\n- GPU compute shader: 4ms\n\nSame scene on Windows, AMD ThreadRipper 1950X 3.4GHz w/ 16 threads, GeForce GTX 1080Ti, DX11:\n\n- Single threaded C#: 208ms\n- Single threaded Burst: 45ms\n- Multi threaded Burst: 11ms\n- GPU compute shader: 2ms\n\n\n## Noise Ball\n\nA mesh with procedural simplex noise driven mesh. The mesh positions and normals are updated\nevery frame, using either CPU code or a GPU compute shader. Based on\n[NoiseBall2](https://github.com/keijiro/NoiseBall2) by Keijiro Takahashi.\n\n![NoiseBall](/Images/NoiseBall.png?raw=true \"NoiseBall\")\n\n`Assets/NoiseBall` is the sample scene and code. Implementation is very similar to the\nwater sample above.\n\nFrame times on a 300 thousand triangle mesh, on 2019 MacBookPro; note that these are full frame times including rendering:\n\n- Single threaded C#: 2723ms\n- Single threaded Burst: 187ms\n- Multi threaded Burst: 22ms\n- GPU compute shader: 14ms\n\nSame scene on Windows, AMD ThreadRipper 1950X 3.4GHz w/ 16 threads, GeForce GTX 1080Ti, DX11:\n\n- Single threaded C#: 3368ms\n- Single threaded Burst: 184ms\n- Multi threaded Burst: 22ms\n- GPU compute shader: 6ms\n\n\n## Combine Many Input Meshes Into One\n\nA more complex example, where for some hypothetical tooling there's a need to process geometry of many input Meshes, and produce\nan output Mesh. Here, all input meshes are transformed into world space, and a giant output mesh is created that is the union of\nall input meshes. This is very similar to how Static Batching in Unity works.\n\n![Combine1](/Images/Combine1.png?raw=true \"Combine 1\")\n![Combine2](/Images/Combine2.png?raw=true \"Combine 2\")\n\n`Assets/CreateMeshFromAllSceneMeshes` is the sample scene and code. The script registers two menu items under `Mesh API Test`\ntop-level menu; both do the same thing just one uses \"traditional\" Mesh API and does everything on the main thread, whereas\nthe other uses 2020.1 new APIs to do it in C# Jobs with Burst.\n\nNumbers for 11466 input objects, total 4.6M vertices, on 2018 MacBookPro (Core i9 2.9GHz):\n\n- Regular API: 760ms (and 23k GC allocations totaling 640MB)\n- Jobs+Burst: 60ms (0.3MB GC allocations)\n\nSame scene on Windows, AMD ThreadRipper 1950X 3.4GHz w/ 16 threads:\n\n- Regular API: 920ms\n- Jobs+Burst: 70ms\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funity-technologies%2Fmeshapiexamples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funity-technologies%2Fmeshapiexamples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funity-technologies%2Fmeshapiexamples/lists"}