Search Unity

Hollowed Mountain

Discussion in 'Editor & General Support' started by NathanFX, Dec 15, 2007.

  1. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    734
    I did found a way.....and for my uses it works.
    I did a simple edit to "Depth Mask.shader"

    Tags{"Queue" = "Geometry-101"}

    replace with

    Tags{"Queue" = "Geometry+10"}


    and to fix the standard terrain shaders. (AddPass.shader and FirstPass.shader)

    Tags{"Queue" = "Geometry-99"}

    replace with
    Tags{"Queue" = "Geometry+11"}
     

    Attached Files:

  2. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58
    Does that mean you have to change the original Unity shaders (AddPass, FirtPass)? I don't know how to apply this.

    If so is there another way to make this work with terrains again?
     
  3. psychentist

    psychentist

    Joined:
    Apr 12, 2009
    Posts:
    75
    what you might try is making the entrance to the cave be an above ground tunnel that is long and windy. you can create a box collider that fills an entire section of the cave, so the player must eventually pass through it. you might want to either lock the player in somehow, or have another box collider to re-enable the terrain when leaving. the box collider would have this script:

    Code (csharp):
    1.  
    2. var terrainAsset : GameObject;
    3. function OnTriggerEnter (other : Collider) {
    4.    if (other.tag == "Player"){
    5.  
    6. terrainAsset.active = false;
    7.  
    8. }
    9. }
    you will have to assign the terrain to the variable through the inspector, which is not the preferred way to do such things, but it won't kill you to do it once in a project. the only downside of this is that any rigidbody objects resting on the terrain will fall into oblivion. make sure you have a fallout collider to destroy such objects so they will be removed from memory. a player who goes deep enough into the cave to trigger the deactivation, but then returns to the terrain would probably notice the missing objects, which is why i suggested the lock in. another workaround could be to use your 3d modeling program and create an invisible terrain reinforcement that sits .000000001 units below the terrain, and has your hole cut into it where the cave passes through, so even when you disable the terrain, your objects stay in place.
     

    Attached Files:

    Last edited: Jun 22, 2011
  4. Cyrus_Zei

    Cyrus_Zei

    Joined:
    Apr 24, 2011
    Posts:
    41
    or, you could do like this.

    just for show

     
  5. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
  6. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    Seems like the problem with the shader is, it doesn't work well for steep cliffs.
    I need to dig around...I had a shader that lets you make an invisible cube. Setting the cube into the terrain results in a square hole there. Which...heh if your ground is relatively flat, that brings up a whole other set of challenges :D
    Anyway, your underground "cave" would be drawn by a different camera, not affected by the cube.
     
  7. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Finally took the time to extend the shader given above, and turn it into an Asset Store Plugin! I put quite a bit of time into it, though, (a couple full days), so I decided to put it up for 5$. The major improvement is that it now comes with script that will let objects actually pass through the graphical holes made.

    There's a plugin for this 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.
     
    Last edited: May 13, 2013
  8. chargedneuron

    chargedneuron

    Joined:
    Jan 12, 2013
    Posts:
    21
    He said it and I tried it. I managed to have a working cave in less than an hour of playing with code. Considering that the last cave I made I spent hours on hours of carving the terrain to match. Portals are the easiest way to punch holes in the terrain.

    Now... I have a lot of terrain to repaint back to normal...

    Thanks Angry Ant for the suggestion!
     
  9. Alven4

    Alven4

    Joined:
    Dec 15, 2013
    Posts:
    1
    Steps how to make holes in terrain:
    1. Download shaders uploaded by me here.
    2. Make material and add Depth Mask shader on it.
    3. Store remaining 2 shaders somewhere in the assets.
    4. Put material on 3D object like cube.
    5. Put that object in your terrain so it is in it from both sides.
    6. Compile and test. If it doesn't work then you probably modified render queue by something else.
     

    Attached Files:

    ProGameDevUser likes this.