- Home /
Culling out mesh
I would like to cull out my object like Cameras clipping planes does, but only on one object. Like camera clipping planes, but with layers. The object is a large "grass plane" with 50000 vertices, so I cant loop trough all triangles and hide them. The camera far clipping plane set to 10 works fine, but it cant be set to hide only the grass layer :/ Thank you !
Well, first of all, thank you for your time. Then you have to know, I did the same thing that you mentioned, but It wasn't good. It costs a lot op performance, and cant be modified, and handled as needed. I developed this "large object" solution after the first was complete, and It does almost the same, just merge every grass plane instance into the "domain" object. I think Far Cry 3 is uses the same solution, but I faced a big obstacle in the falloff, so I started to develop a new solution, which is more effective, and performance friendly, so overall you are right, this wont be as good as planned.
Here is a new question, for the new, the final solution: http://answers.unity3d.com/questions/1140238/serialize-large-array-of-class.html It generates a large class array of "imaginary" grass, and apply scale, size, rotation, color, type, ect... to it. During runtime, the grass objects (1000-2000) are moved to exchange the near grass spaces. This works excellent, but i don't know how to save the arrays data. Thanx for reading!
Answer by Pangamini · Feb 11, 2016 at 01:29 PM
You could do this effect by clipping the plane in a shader (no performance boost). You could have separate camera to additionally render the grass, with clear flags set to none (But here you will have problems with transparent objects). What you want can be achieved, but what's the point? I mean none of these will bring you any significant performance boost. It's a single mesh, being rendered in a single batch. Sure, by far plane clipping you might achieve a slight reduction of pixels needed to be rendered, however in a standard 1st person view i can imagine this will again not have any impact that'd matter. I mean if your goal is performance, because you didn't mention your motivation. There's no point in software clipping of parts of a single mesh, that would lead to much higher overhead than what you'd save in rendering. Perhaps the whole idea of having "one huge mesh" is not such a good idea.
I don't know how does your grass thing look like, but i suggest you take a look at geometry instancing. Very handy thing. For me, all evidence points to the fact that unity shuriken particle system utilizes instancing when mesh particles are used. Together with custom vertex shader (to slightly modify individual instances of tussocks based eg. on the particle color or world position, time to add wind effect or whatever else you want) you can sure create quite fast, but even infinite plane of grass (by generating particles around the camera instead of emitting them by the shuriken).
Answer by mikelortega · Feb 10, 2016 at 11:09 AM
I think you are looking for Camera.layerCullDistances.
Set your grass in a new Layer, and then, configure that layer's cull distance for your camera.
Answer by manyokibenc · Feb 11, 2016 at 12:10 AM
Definitely not. It hides objects instead of culling the mesh out, like far clipping planes.
Your answer
Follow this Question
Related Questions
How to toggle object visibility with keyboard button? 1 Answer
Layers Show/Hide not hiding children with showing parent 0 Answers
Canvas Hide / Show with 3 clickable Objects 0 Answers
Hiding in Grass or object when player enters it in photon pun game? 1 Answer
Can you change realtime lights falloff? 0 Answers