Plane section cut that removes/hides GameObjects (similar to Camera nearClipPlane)
Hi, as this is my first question of the forums I will try my best to describe my question. Please excuse my English, it is not my native language!
In a scene I'm trying to create a "section cut" of the GameObjects, relative to a plane in real time (no precut objects). I made the following mock-up in Sketchup to illustrate my point :
After some researches and tests I manage to get a similar effect simply by changing the nearClipPlane attribute of the Camera, however my point here is to cut along a plane.
For reference, the person on this thread had a similar request, however he didn't found complete a solution.
If my question is too complex to solve, I have an alternative one : what would be the most efficient way to simulate a similar effect ?
So far my first idea would be to create a cube from the camera to a specific distance, and hide every object that would be inside the cube. Once again here's a crude illustration of what I'm proposing :
This could work for a demo, but it doesn't seem to be practical for highly populated scenes. What would be a more efficient way to do a similar thing ?
Answer by TobiLaForge · Sep 25, 2017 at 10:57 AM
Hello JETom,
have you looked in the Asset store for an already exising solution? Searching for 'section' or 'cross section' brings up some assets of which some might already do what you want. One of them is also free. It actually replaces the shader of your Objects and clips all the triangles and vertices at the selected plane. All vertices are considered in the shader though. Depending on what you count as 'highly populated scenes' that approach could be too slow, because it uses a 2. pass to fill the gaps for a nicer look. So rendering amount increases though you cut things away. Maybe you could combine it with some script for some kind of bounding box, to ignore objects which aren't visible at all because of your cut.
Your answer
![](https://koobas.hobune.stream/wayback/20220612124148im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do I change the colour of an object inside the camera's FOV when pressing a button? 0 Answers
Unity 5 Swiching cameras causes missing scene 0 Answers
Z-Fighting Problem (Increasing Near Clipping Planes Problem) 1 Answer
How do I set the near clipping plane of the camera in C#? 1 Answer
Changing camera projection matrix does not change Canvas 0 Answers