Search Unity

Terrain Hole System

Discussion in 'Assets and Asset Store' started by Venryx, May 13, 2013.

  1. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    The last three make sense, because deferred doesn't work with both shadows and transparency. (I don't know the low-level reason, but that's what I discovered through experimentation--there must be some way around it, as I think there are some shaders that have both--but if there is I don't yet know how to implement it)

    With the first two, is the issue that there are shadow artifacts? If so, then yes, that is unfortunately a side-effect of having the terrain geometry underneath, with shadows added using the built-in approach. This is mentioned in the Asset Store plugin description: "With shadows enabled, some transparent areas may have darkening artifacts. This can make the surface look a bit odd."

    Is there a way you can work without shadows, or are they pretty important?

    Sorry that you've run into this issue. Maybe in the future, I'll finally have a fix for it. (and believe me, I've tried--I've spent at least ~6 hours on it so far--but shaders are a hard thing to fix issues in, because a lot of it is behind-the-scenes/not in visible code)
     
    Last edited: Mar 11, 2014
  2. Et12

    Et12

    Joined:
    Mar 16, 2014
    Posts:
    4
    havn't been able to find an answer to the black hole problem. Am new to this site and new to unity. if you could give me a way to fix it it would be greatly appreciated. Thank you
     
  3. Et12

    Et12

    Joined:
    Mar 16, 2014
    Posts:
    4
    have you foudn an answer to the black hole problem? im new to the site and all and dont see an answer in this thread.
     
  4. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    The most common cause is of there being another shader in your project which also overrides the default terrain shader. The problem results from this "other terrain shader" blocking the THS terrain shader from applying the transparency/drawing the terrain with transparency. The fix is just to remove these "other terrain shaders" from your project, or edit the other terrain shader by opening it up in notepad and changing its (in-file) name from "Nature/Terrain/Diffuse" to something else, like "Nature/Terrain/Diffuse_Old".

    That should get transparency working, if the Transparency.png file is in one of the first four slots.

    If it turns out that you do need/are using the other terrain shader, then the fix would have to be to merge the shaders. This actually isn't that complicated, usually; though it is still enough that there's usually an "extra step" or two that the person needs to perform, in addition to the generic instructions. Anyway, if this is your situation, you can find these "generic instructions" at the following location: "Terrain Hole System\Documentation\ShaderMerging.txt".
     
  5. Et12

    Et12

    Joined:
    Mar 16, 2014
    Posts:
    4
    where would you find other shaders? if i remove all textures from the terrain and then add the transparent texture, the whole terrain goes black. im not well versed in this program yet so im realtivley naive and such.
     
  6. Et12

    Et12

    Joined:
    Mar 16, 2014
    Posts:
    4
    so i have figured out the black hole problem. The creator is right. But to put it in layman's terms. The material of your terrain has to be one with the merged shaders. follow the readme that the creator provided and create an asset from the drop down menu "assets" and create a material. drag the bumpmapped shader on to it and this will apply the shader to it. Then drag that material to the material section in the settings menu of the terrain. Thank you to venryx for providing the information about shaders being in conflict and for providing all the information that we really needed to figure it out.
     
  7. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    That's great that you got it working. I was just about to make some help instructions for finding the problem-causing shaders, but it looks like you figured it out. That is one advantage of the material-based approach--you can have other terrain shaders in your project, and not have them override the one you want to use for a particular terrain.
     
  8. reapi

    reapi

    Joined:
    Apr 5, 2014
    Posts:
    2
    I have purchased this and if I can get around one issue I think it will work great. I have a mesh collider cave and a terrain. I made a hole in the terrain to match the cave entrance. When I start my character on the terrain and walk on through the hole into the cave, it works. When I start in the cave and walk out onto the terrain it works. But neither will work continually back and forth as I walk to and from the terrain to the cave. I fall through the terrain the 2nd "exchange" every time.
    Any ideas?
    Thanks!
     
  9. reapi

    reapi

    Joined:
    Apr 5, 2014
    Posts:
    2
    Solved my own problem. I had "snap up on terrain checked" but I guess this is meant for multiple terrain objects, which I am not using. Maybe the script can only active this field (or otherwise ignore it) if you don't have multiple terrain colliders assigned?
     
  10. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    The "snap up on terrain contact" option was actually made to solve the problem of the user getting 'stuck' in the terrain when they try to exit a below-terrain cave, from an angle. What would happen, (at least for me in some tests), is that I'd be coming up onto the main terrain, and the terrain collider would enable itself just before the character's feet made it out of the hole. This caused the feet to still be stuck 'under' the terrain, with collisions then enabled--causing the player to be unable to move. The option above was added to help solve this problem.

    You're right that in most cases, it won't be necessary--at least, not in its basic form like that. A better long-term approach for scenes that do have that issue would be to just solve the root of it--fix the 'overhang' part of the main terrain over the hole section. But I added the option for people to use, until they get around to carefully making the hole boundaries; it's better to have a snap-up issue when you first use a plugin, then to find your character stuck in the terrain due to height-missetting (i.e. the max-snap-up-distance options) or imprecision of the fall-through area around the cave entrance.

    Glad to hear the issue wasn't caused by the core of the plugin. (which isn't actually very complex--but still, better for the cause to be in one of the optional settings) As for what the root problem is, I'm actually not sure--I thought I designed the snap-up code to only every move the player up, but I suppose I must have missed some special case somewhere.

    With a quick glance back at the code, the best explanation I can think of is that the "max snap up distance" option is set too low. (possible to zero?) If you do in fact end up needing to use the "snap up on terrain contact" option again, try checking this other option to make sure it's set to the height of your character. (or I guess, more precisely, the character's collider)
     
  11. GenOli

    GenOli

    Joined:
    Apr 21, 2013
    Posts:
    139
    Is there any way to get this to work with NavMesh or A* Pathfinding?
     
  12. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    I honestly don't know. I haven't looked much into how path-finding systems work. (haven't gotten to that phase in the games I'm making yet)

    I would guess that good path-finding systems would allow some way to notify the system of dynamic openings, though. The path-finding system used in TerraVol, for example, adjusts to how the user shapes the terrain in real-time. As for the details, I'm really not sure how you would go about this/how it works. I'll eventually have to look into this myself, though, once I have an AI system implemented.
     
  13. GenOli

    GenOli

    Joined:
    Apr 21, 2013
    Posts:
    139
    Also I've that when going between a model (ie: a house) and the terrain that if I start in the house, go on terrain, back inside, then on terrain again, I fall through the floor.

    The Object Fall Through/Terrain Settings scripts have default settings.


    Edit: Turned off "Snap Up On Terrain Contact" - now works fine.
     
    Last edited: Apr 11, 2014
  14. joesan

    joesan

    Joined:
    Jan 27, 2014
    Posts:
    9
    I have bought the terrain hole but I can only gt the First Person Controller fall thru. I tried several models such as the standard thirdPerson Constractor model but it doesn't fall thru. I have followed the conditions and attached the fall through script plus a rigidbody to the model to no avail. What exactly are the parameters/conditions to have an object fall thru?
     
  15. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    The set-up is fairly straight-forward, and the manual gives a basic instruction list for getting it working. Most likely it's just a single step that you're missing, that's causing the problem.

    A few questions:
    1) Is the character being affected by gravity? (is the player falling to the ground?)
    2) Is the hole in the terrain fully transparent?
    3) Is the "fall through opacity" of the fall-through script set to something reasonable? (for starters, you can try 0.5)

    Beyond these immediate checks, for me to know what went wrong would require a more detailed approach. If the above checks all seem fine, and don't lead to anything when you look around, try packaging up a very small demo scene, with the problem present. Then send it to me through a Private Message, and I'll take a look.

    Usually these sorts of problems are from a very simple thing, like forgetting to check some option box, or attaching the script to the wrong object. It's usually fastest to just sent a simple project, that demonstrates the problem.
     
  16. joesan

    joesan

    Joined:
    Jan 27, 2014
    Posts:
    9
    How do I send my test project to your Private Message?
     
  17. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    I guess on checking, there is no way to actually attach files to private messages. You could either upload the project, in a zip file, to a free file-sharing website (and then send me the link), or you could send me a regular email and just attach the zip file. My email is venryx [at] gmail [dot] com.
     
  18. joesan

    joesan

    Joined:
    Jan 27, 2014
    Posts:
    9
    I have been partially successful with falling through your hole in terrain system. It works OK with any primitives (cube, cylinder) but not all AI models. It works for MAX soldier, but not for Skeleton model (imported from Asset store) nor does it work with the 3rdPersonController (constructor). If I place a rigidbody of mass 1 it doesn't work even with MAX but if I apply 500 mass it does fall thru but the others tend to rather float.
    At this point I would appreciate if you could give me some parameters to include in the ai-to-be-fallen-thru in the inspector.
    Thank you
     
  19. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    I suppose you could try resetting the parameters to their default value. You can do this by pressing the small arrow at the very top-right of the Inspector panel (next to the text "Inspector", if I remember correctly), and pressing "Reset". This will bring the property values all back to how they were when I uploaded the plugin.

    That said, it probably won't fix the problem. The problem is most likely some small detail that is not set up correctly on the model's you've been testing. I don't really know what sort of 'small detail' that would be, but the system's pretty simple, so there must be something about the models themselves that's preventing the fall-through.

    To help with this, it's really only practical to use some sort of small example scene, demonstrating the issue. It doesn't actually take very long. Just start a new Unity project, import the THS plugin, import the model you want to use, open the THS demo scene, drag the model onto the scene (adding the movement scripts, and the THS fall-through script), remove the existing cylinder model, and then press play.

    If the problem is still there, just package the files into a .zip file, and send it to my email above. I'll take a look at it, see what's wrong (hopefully), get it working as it should, and then give you an explanation of what steps I took.
     
  20. joesan

    joesan

    Joined:
    Jan 27, 2014
    Posts:
    9
    It's OK, I may use some models and some others not so why the perfectionism? I'll do with the ones that work after all I am not entering a contest or such. Thank very much for your answers and they helped me anyway.
     
  21. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    Black hole problem here too...

    Can't figure out the issue, read through previous posts. Even changed the nature/diffuse to diffuse_old.

    Please help.

    Edit: Okay, "No shadows" worked, one thing I didn't try.
     
    Last edited: Jun 1, 2014
  22. snowcult

    snowcult

    Joined:
    Feb 6, 2014
    Posts:
    295
    New problem, doesn't work if you're on a setting where textures aren't at full resolution... which is troublesome... any way to work around it?
     
  23. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    I saw the update in the store and that it require now unity 4.6.
    Can you please tell us what you changed?
     
  24. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    From the update notes:
    I think there were a few other changes, but the time between updates was so long, I don't remember what they were.
     
  25. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Sorry, I missed this.

    I'm not sure what you mean. I doubt it's as simple as a texture simply not being at full resolution, since that's abstracted away from the scripts/shaders, as far as I know. (the scripts make use of downsized images the same way they do full-sized images, I believe)

    Could the problem perhaps be with having textures of different sizes? That seems odd, too. I don't see how that would cause a problem.

    Anyway, let me know if you still need help, after all these months. (I'll probably need a problem-demonstration demo, or at least a more detailed description of the problem/the discovery process.)
     
  26. toxtronyx

    toxtronyx

    Joined:
    Aug 21, 2014
    Posts:
    114
    Can you give a short advice how to create the new transparency map? I like the idea behind it since it doesn't mess up the texture slots but I get only strange results when trying to paint it in an external application.
     
  27. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    1) Have the image size be the same in width and height as the terrain's "Control Texture Resolution" property.
    2) No alpha/opacity in the image, means no transparency (i.e. full alpha/opacity on the terrain). So, have zero opacity in the transparency image for normal terrain, and have full opacity in the transparency image for a hole.

    Also, if you choose to take the live-paint approach, note that the THS shader now can recognize a "transparency texture slot" for any of the slots--so you can paint using an extra texture just added to the 10th slot or something now. (no need to be in one of the first four anymore)
     
  28. toxtronyx

    toxtronyx

    Joined:
    Aug 21, 2014
    Posts:
    114
    Thanks! I need to give it try. Had some struggles in Unity5 Beta where in some cases the terrain was transparent in the editor but not in play mode.
     
  29. toxtronyx

    toxtronyx

    Joined:
    Aug 21, 2014
    Posts:
    114
    Me again. When I load a scene in U5 directly it works like a charm. But when I load a scene via another scene e.g. from the main menu scene hit play and load the one with the terrain in it, the hole is solid black instead of transparent. Are you able to check that and in case could you please do it?

    TIA
     
  30. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Can you put together a demo scene/project demonstrating the issue? It makes it much easier for me to fix things when I can reproduce the problem. (I've never noticed that issue myself, including in projects where scenes are loaded dynamically)

    Thanks.
    -V
     
  31. toxtronyx

    toxtronyx

    Joined:
    Aug 21, 2014
    Posts:
    114
    Shot you a message
     
  32. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Okay, found the problem, and how to fix it.

    Problem: when the game is in play mode, terrain-transparency script checks if there is already a transparency-map set. If not, it calculates one from the splat-map/texture data, and applies it. If so, it does nothing. (meaning the transparency-map is never applied/the property is never set for the material/shader)

    Changed that to now "apply the transparency-map", if it finds an existing transparency-map in play mode.

    I've submitted the update for asset-store review already, but to apply the change immediately, open the TerrainTransparency.cs file, and change the final if-else block in the Update method to this:
    Code (CSharp):
    1. if (!Application.isPlaying)
    2.     ApplyTransparencyMap();
    3. else
    4.     if (!transparencyMap && autoUpdateTransparencyMap)
    5.     {
    6.         UpdateTransparencyMap();
    7.         ApplyTransparencyMap();
    8.     }
    9.     else
    10.         ApplyTransparencyMap();
     
    Last edited: Jan 12, 2015
  33. toxtronyx

    toxtronyx

    Joined:
    Aug 21, 2014
    Posts:
    114
    Works like a charm! Thanks a lot for the update.
     
  34. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Wow... I just realized I have three calls to ApplyTransparencyMap, and I only actually need one of them.

    I guess my excuse is that I originally wrote the code to only "apply" when something had changed... until I found out that it takes virtually no time to just call that method every frame.
     
  35. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello Venryx,
    Great work with THS!

    Is there a possibility for shadows to go through the holes and be visible on opaque terrain fragments at once? I have a issue with lightmapping where lightmapped shadows are treating invisible parts of terrain as a obstacle and shadow is not cast on objects below it.

    Cheers!
    Piotr
     
  36. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    I think the shadows are handled internally by Unity. From the shader include files, it appears some of it is configurable, but I don't really have the time right now to look into whether that is fixable. I expect it isn't, but who knows, there is quite a bit of shadow-mapping-related code in those files.

    One option is to try to sink the invisible hole terrain area down beneath the opaque area. If the terrain heightmap resolution is high enough, you should be able to at least reduce that effect to just a vertical plane instead of a diagonal one. Sorry I don't have a clear-cut solution for it though, I realize it's pretty distracting for some use-cases.
     
  37. Stephanides

    Stephanides

    Joined:
    Oct 5, 2014
    Posts:
    12
    Hello, i have the same problem like was here before, when i create new project and run demo it looks good but when i open demo scene in my project i dont see transparent but black , i dont understand solutions before, any advice ?
    Thank you
     
  38. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Can you make a copy of your project, simplify it down to just the terrain issue, then send it to me so I can have a look? (you can also just send your whole project if you want, but some people aren't able to do that due to private source code, etc.)

    I'll take a look and try to see what's wrong/how to fix it. (and sorry for the late response; I had it on my todo list, but haven't looked at it for a couple weeks now)
     
  39. acaton

    acaton

    Joined:
    May 27, 2013
    Posts:
    28
    i had terrain holes working great before unity 5, but they're broken now (coming out all pink or black, depending on what i try). Has the plug in been tested on Unity 5? if so, would you mind forwarding me a link to the current setup instructions, if they're available? i made small test project with just terrain, added 2 textures (1st transparent.png, 2nd grass), added the transparent terrain script to the project, created a custom material which i added to the terrain settings, and now the terrain is all pink, despite painting grass on it. I could send you my project, if that would help. just need basic transparency to work, if possible. thanks and have a great day!
     
  40. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Yes please, send me the project (you can of course strip it down/simplify it to just the terrain, if you want). The default demo scene has seemed to work fine in Unity 5 from what I've tried.
     
  41. ctalmeida

    ctalmeida

    Joined:
    Sep 3, 2014
    Posts:
    13
    Hi Venryx

    Bought today your product and works great inside Unity, the player goes through the hole and there is a hole, but if I build the project and run the .exe there is no more hole, my terrain is back there, but the player still goes trough the terrain on the place the hole should be transparent, than works but you cannot see a transparent hole.

    Any suggestions?

    Thanks

    Carlos
     
  42. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Odd. My first thought was that the shader wasn't included in the build somehow (i.e. it wasn't referenced by anything), but that can't be so, since the latest versions of the plugin require that you link your terrain to the material.

    I don't know what would be causing that.

    As with a lot of the problems reported recently, I'll have to rely again on a issue-demo scene submission. Can you make a copy of your project that just has the terrain, character, and the transparency issue, and email it to me (venryx [at] gmail [dot] com)? Please include what version of Unity you're using as well, and if you like, the built exe that has the problem.

    Thanks. -V
     
  43. ctalmeida

    ctalmeida

    Joined:
    Sep 3, 2014
    Posts:
    13
    Hi Venryx

    Here 3 pictures of the your Demo using basic terrain. First on edit more, second running inside unity and third the .exe.
    Unity 4.6.3f1. I will do the same with yours Bump-Mapped Terrain in few minutes. upload_2015-3-14_9-44-42.png upload_2015-3-14_9-45-2.png upload_2015-3-14_9-45-21.png
     
  44. ctalmeida

    ctalmeida

    Joined:
    Sep 3, 2014
    Posts:
    13
    Here using Bump-Mapped Terrain, I must be doing something wrong

    upload_2015-3-14_9-55-5.png

    upload_2015-3-14_9-55-20.png


    upload_2015-3-14_9-55-36.png
     
  45. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    I admire the effort, though I'd love if you'd find some way to extrude it a bit - that cave hole is literally paper-thin (in a demo).
     
  46. mars-red

    mars-red

    Joined:
    Mar 14, 2015
    Posts:
    2
    I'm new to Unity, and just purchased this to use in Unity 5. I get 2 shader errors when creating a new project and bringing in this package. These are the errors I get:
     
  47. acaton

    acaton

    Joined:
    May 27, 2013
    Posts:
    28
    Thank you for getting back to me so quickly. i've been busy at work so haven't had a chance to reply. i can send you my demo. could i zip it up and send it to you? if so, please let me know where i could email it. i also sent you a message from your website, so please feel free to reply there. thank you again for all your help over the past few years! i've really enjoyed using your amazing project! - tony
     
  48. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Yet another anomaly... I had no idea there'd be so many edge cases when I first released the extension.

    Anyway, I've tested the demo myself in Unity 4.6, and it seemed to work fine. So I'm guessing it's either a project setting you have different (e.g. the rendering/quality settings), or something specific to your computer or build settings (e.g. drivers or chosen platform).

    To help narrow down the possibilities, can you try sending me a stripped-down version of your project that I can open myself? Then I can see if I can reproduce the problem. (the first step in efficient debugging)
     
  49. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Yeah, that would look quite a bit better for uses like that in the demo. Unfortunately, it's a non-trivial thing to add thickness to the wall. You'd have to introduce entirely new polygons, which is pretty advanced, and in any case isn't worth the effort for something that would be better fixed by custom models anyway. (the idea is to use the tool just for making the hole, and then make it look like an actual tunnel or hole using additional objects/models)
     
  50. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    PM sent.