- Home /
Split a big level mesh in Unity
Hello Everyone! I got sort of I problem that I have been trying to find solutions for. Let's say that a graphical artist creates a level for me (a big terrain-like mesh in Maya) without splitting up this model into segments. Is it possible for me to split the model inside Unity so that the Occlusion Culling system will effectivly work?
What I thought of was to place some sort of planes that "cut" the object apart, so that a script will know about these planes and slice the object. The bad illustrating picture above tries to show this.
All threads I have searched has suggested to split the objects in Maya (http://answers.unity3d.com/questions/158527/Split-a-mesh.html) and that is of course the best way, but we would like something automatic and simple in Unity.
Answer by Graham-Dunnett · Apr 16, 2013 at 03:18 PM
Whilst you could write an editor extension that splits the level into pieces in Unity, it's a lot of work. You'd use the Mesh
class to create the new pieces. It's far far far simpler to pay your artist to split the model into the pieces that you need.
i'm working on a mesh splitter for animated meshes, and as part of that i am incidentally able to split static meshes.
pay the artist. this stuff is headache-inducing. :)
there's also at least one asset that can slice a mesh... oh, at least two. here's one: http://u3d.as/content/marrrk/piecemaker-mesh-destruction/1RP
Thank you for the creat answer! I will really tell your answer to my artists :)
I started to look into the T4$$anonymous$$ ins$$anonymous$$d but realized that it can't handle terrain lod (or terrain culling). That is, culling a big mesh in an easy way. Not that I am aware of at least.
Feel free to give more advice about how to optimize a terrain for phones :)
Answer by specweapons · Apr 14, 2017 at 05:51 AM
*** I am a programmer, I am going to run into this alot thanks
I find hundreds of questions like this and answers like there is no workaround, or split the mesh, etc. I however do not see many small examples of how to (Best Practices/Best DataTypes) to use to do so. I know GameObjects contain transforms, I know it takes a MeshRenderer and a MeshFilter, and since you have a sizeable mesh now you probably need it to have a transform. However, what I don't find is a simple discussion of some questions that naturally arise. To make matters worse some conversations head off to discussing vague terms like submeshes which I do believe do not even solve the problem. Just a few more questions then. (Please don't tell me Post a separate question else the next nerd that comes along will also have to read 5,000 of these useless replies to a super cool common question:
Can you have more than one MeshFilter/MeshRenderer in and Object/Component/GameObject?
Are GameObject's the only or best/preferred place to store a Transform, MeshFilter, MeshRenderer, to display your separated just less than 65K vertices mesh, or are there multiple varied other places/object types/data types, you can pair these together in?
Say I define a Class in C#, and give it a transform, meshfilter, meshrender, does it have to derive from anything to become a GameObject?
What are the correct public (I would guess public) name to give meshfilter, meshrender, transform references in a scripted (MeshContainerDohickey) class/definition.
Why the crap are these ideas mentioned in every freaking posting with the text, "64K Limit", "64K", "65K" instead of someone saying, "There is no workaround", obviously there is a workaround. It's splitting the mesh somehow, and the common best practices of doing so is what they are going to have to learn how to do. It's not like it's that obvious to a newby, you can't just say well split it. Put it in another Game object. At least discuss a few Data Structure ideas, limits and best practices.
There is a workaround for anything, if your a positive thinker. It's called not quitting!
1: those are componenets, try it and you'd find out no, you cant have more than one. 2: Learn about 4x4 $$anonymous$$atrixies and using Graphics.Draw$$anonymous$$esh 3: Go watch or do a beginner course/tutorial on monobehaviours or unity in general, you dont seem to know basic terms or how objects work. You dont script gameobjects. An empty gameobject only has a transform component on it and stores things like the objects layer, name, tag, and if it's active or not. The attached components derive from monobehaviour, those are the scripts you write. 4: see above.
5: You seem to know there is one, look around a little. You could make a simple component that has a public list of meshes and materials (so it shows in the inspector) then in update loop through the lists and draw them with graphics.draw.
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEdit$$anonymous$$ode]
public class $$anonymous$$ulti$$anonymous$$eshRenderer : $$anonymous$$onoBehaviour
{
public List<$$anonymous$$esh> meshes = new List<$$anonymous$$esh>();
public List<$$anonymous$$aterial> materials = new List<$$anonymous$$aterial>();
// Update is called once per frame
void Update()
{
foreach (var mesh in meshes)
{
if (mesh == null)
continue;
for (int i = 0; i < mesh.sub$$anonymous$$eshCount; i++)
{
if (materials[i] != null)
Graphics.Draw$$anonymous$$esh(mesh, transform.localToWorld$$anonymous$$atrix, materials[i], 0, null, i);
else
Debug.LogError(
"$$anonymous$$esh has more submeshes than there are materials. Some submeshes are not rendering.");
}
}
}
}
Your answer
Follow this Question
Related Questions
Multiple scenes or one scene? 3 Answers
Low FPS when against a wall? 1 Answer
"Big" 3ds model gives performance issues 3 Answers
GFX.WaitForPresent 8 Answers
How to use additionalVertexStreams? 1 Answer