Hi, I’m just starting game designing and I have almost no clue as to what I’m doing. That said, I’m sorry if this is a stupid question, but I have no clue about this and need help.
I was wondering if there was a way to use Unity’s “create terrain” option to make a mountain, and then hollow out caves and caverns in some way. Help would be highly appreciated!
Have you read this?
Thanks, but I couldn’t find what I was looking for. So maybe I can’t hollow out terrain, but are there any other methods you could recommend for doing what I want to do?
Nope, no diging. You can only do this along the y-axis, so an open crater would be possible but for caves, tunnels and similar geometry you’ll have to use the modeller or script your way via the mesh interface.
I think this is a good question.
What if i want to make a Level in wich i can walk on the land and also in some dungeons?
In Torque you can cut out a hole in the ground and positioning the dungeon so that the entry is where the hole is and then you have to build something around the hole and the entry so that it loos nice.
How can we do that in Unity?
You can’t just push the terrain into a hill forming a cave, because the terrain is a heightmap system only and doesn’t support overhangs. But there is a hack you can do. It involves making a flat part of the terrain (probably near vertical) then surrounding it with props like rocks to hide a seam you are about to generate. Then with this shader , clever layer masks and guesswork modeling you can cut a visual hole in the terrain with whatever else you want behind it (hand made cave, door into underground building etc). Then you just need to build a collider model that is the same shape as the hole and the terrain around it, which you swap for the terrain collider using Physics.IgnoreCollision on a trigger near the threshold. The only problem is if your camera is in between the terrain and the depthmask mesh, which you can detect and fix with a raycast.
Its pretty complicated but possible. I think in the future UT plans on adding a feature that lets you cut proper holes in terrains.
Normally you either model the whole scene the way you want it or you combine the terrain with imported/generated models, so place your mountain with the caves in the terrain. Would be nice if you just could sculpt your way through somekind of a polygon block but it’s not possible yet. If i remember correctly Crysis for instance was combining voxel objects with their polygon terrain…
Wow… tis is way too complicated for me, but it looks like I’ll have to try!
I went ahead and did an example, because I wasn’t even sure myself that it was possible. Feel free to pick it up.
Realistically I think you would probably want to generate such portals procedurally instead of setting them up manually, to accommodate with oddly shaped terrain.
Good job including your example Yoggy.
However my advice with these things is, don’t use it until you need it badly or you’re just curious about playing around with it as most of the time it’ll turn out that you’ll loose time contrary to using a officially supported and tested solution were you don’t have to change things afterwards.
Large game companies use portals. And so can you
To Yoggy: love your DepthMask example!
Before I saw this post I tried to just paint a transparent zone (using a 0% alpha texture), but it doesn’t seem to work.
Does that mean that the terrain shader ignores alpha? If so, then what is the SplatAlpha? I thought it did just that, but it’s probably just the name confusing me.
I know Taumel alluded to this already but I thought I’d go into a bit more detail…
One way of dealing with caves and such things in a heightmap is to model the terrain you want in Unity and then export that heightmap to your modeling program. Use the heightmap as a displacement map on a mesh that is (although it doesn’t need to be) the same dimensions as the terrain in Unity, and then grab that section of the mesh that you want to build into. Do your modeling work, applying the same textures and resolutions you have in your scene, and simply import that as an asset. Then you have to sculpt away that area in your Unity terrain and blend in your cave section.
Of course you will have a seam to deal with, but you can use grass and assets to blend it as best you can. Hope that helps.
Thanks Chad, but I’m not worried about the modeling part.
Our level is mine-themed, so we just have one big mountain (terrain engine), entry points (little wood huts that will acts as seams + disable the terrain collider --mesh + triggers), then big tunnels (mesh) inside the mountain.
That’s the part I’m curious about: how do you sculpt?
Yoggy uses a DepthMask. What I was trying to accomplish was to just paint the hole, just like you would paint stone or sand or whatever: create a splat texture, but using a 100% transparent texture… doesn’t work though, so I’m wondering if I did it wrong or if the terrain shader is incapable of painting transparent splats.
You didn’t do anything wrong; the terrain shader doesn’t do transparency.
–Eric
Ahh right, I meant nothing as elaborate as that I’m afraid. By ‘sculpt’ away I meant you would lower that part of the terrain to allow for the mountain ‘cap’ that contained your cave.
I guess you want to use the Terrain tech for painting grass etc …because otherwise you could just use a mesh instead. You’d get better shadows that way too if I understand it correctly.
Eric: Thanks for the confirmation!
Chad: check out Yoggy’s posts (here and here), his solution isn’t that complicated… less than the sculpting you suggest I think… but still not as cool as painting holes ;)… I guess we’ll just have to wait for an update from UT to get this kind of coolness!
yeah thx, I looked at those. I think it’s really great that you can hack this in. I honestly can’t wait to try it out. My only issue would be that, as Yoggy states, it helps if the area is near vertical (I don’t know if it has to be this way), and steepness in Terrains is bad due to stretched textures. It sounds like you’ve got that covered though.
Err, I don’t know, I don’t really see why it would need to be vertical or steep. According to the wiki the DepthMask shader was made to cover water inside boat hulls so it can certainly work horizontally.
What you do need is a rather flat zone where you’re going to carve, so true you probably can’t carve just anywhere… but if you have an object to put in front of the hole (like our mine huts), you can cover pretty much anything and not worry about seams.
Probably works better with artificial structures than with natural caves…