I have researched and I’ve seen you can do some shader+collision tricks to make holes in terrain. So for a flat terrain, using a simple plane with the special shader would work to make a hole. So it seems you would need a preset mesh to overlap onto your mesh that you’re trying to make a hole in.
However, lets say you have a custom terrain mesh and you want to dynamically create round holes onto the ground. What would be the best way to approach this?
Should I find a way to only select and duplicate the specific polygons somehow 'cut it out into a circle or whatever shape I wanted and take that mesh and apply the masking shader? Even though that wouldn’t quite make sense since it’s probably not possible to do that, or we wouldn’t even need the special shader, if we can cut out shapes in the mesh?
Is it possible to overlap to mesh objects? and somehow cut out the intersecting?
Any guidance in this matter would be most helpful.
Thank you in advance!
Edit:
To clarify my question, I definitely mean during runtime/gameplay. In this game theres a type of digging action, and you’d be able to choose whatever location on the terrain. So pre-making meshes to make holes would not be an option.
“Is it possible to overlap to mesh objects? and somehow cut out the intersecting?”
You would have to do this BY HAND, working with the mesh. This is by no means simple, and not something you can do as a beginner.
Now, is there an existing tool that does this? I’m pretty sure, no, I’ve not seen any tool (say on the asset store) that will take a flat mesh, a “ground”, and knock a hole in it.
based on your further comments …
Note that using a PROJECTOR is a very common and very simple solution to what you are describing.
(A “decal” is somewhat similar conceptually, but it does not work if the ground is, as you say, not perfectly flat. A “projector” will work perfectly for you here – depending on the look you want.)
To try a projector basically, just click once to add an example projector (“blob light” or whatever) from the standard example assets
Tarlius’ response is in the right direction. That will take care of dynamic terrain texture changes.
To actually make holes, though, you have to have a texture that it switches to, that’s transparent, and a script system that makes objects fall through those dynamically-made-transparent areas.
I’ve made a plugin for this second half, that can be found on the Asset Store: Terrain Hole System
Description: “This Unity extension lets you make holes in your terrain that characters and other objects can go through.”
More information can be found on the forum thread.
To get it working with the dynamic texture setting, just have the dynamic-texture-setting set the terrain texture of the area to the “Transparent” texture talked about in my plugin’s manual.
Let me know if you need more details into how to get this to work.
I would suggest looking for “destructible terrain”.
Check this out. I didn’t read the code, but the concept is explained in the video description. Basically he uses a texture to adjust the hieghtmap. The disadvantage of this is there will be no way to make “caves”, which might be a problem.
voxelform looks like it would get around this (and looks awesome in general), although I can’t find it on the asset store now.
If you aren’t looking to do this in real time, then Fattie has the answer
(Disclaimer: I am not affiliated in any way with either of these solutions)