Search Unity

Ferr2D Terrain Tool

Discussion in 'Assets and Asset Store' started by koujaku, Oct 9, 2013.

  1. josessito

    josessito

    Joined:
    Feb 14, 2014
    Posts:
    57
    Great!! That smooth feature looks fantastic!! I can't wait to try it.
    I have a question though. I have been working on a little project and up to this point i have use the terrain materials that came with the asset, but it is time to use my own textures. My question is (maybe Kelde could answer since he has show some beautiful stuff), how would someone approach creating the edges. I have a good idea how to approach the fill textures but not the ones from the edges. And I ask from a technical, not an artistic point of view. I could create a tillable texture for the middle block, but how can I approach the caps so that they are seamless?

    Thanks!!
     
  2. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    Still pending review! I'm guessing they're still a little busy post-GDC? They haven't replied to my emails yet either =/
     
  3. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    I really need to make more videos on the topic, haven't found the time lately. I'll see if I can work one in after my current project is over! But in the meantime, this post early on in the thread talks a little bit about how I lay stuff out to help with getting things tile-able. It's a bit of a tricky thing to get right, regardless, but hopefully this idea helps some =D

    http://forum.unity3d.com/threads/204436-Ferr2D-Terrain-Tool?p=1382567&viewfull=1#post1382567
     
  4. josessito

    josessito

    Joined:
    Feb 14, 2014
    Posts:
    57
    Hi koujaku, thanks for the reply! I'm slowly figuring it out. I have another question though (I hate to be that guy, but I'm not an experience developer) the question is, how can I avoid the situation in the image? I'm trying to figure out how the terrain works but I'm having some trouble.

    Edit: i think the image didn't upload her it is again.

    Edit2: well this is embarrassing. The image just won't show. My problem is with caps, Sometimes caps get behind the "side" (left or right) part of the textures instead of being on top of it. How can I avoid this so that the cap is always on front? $problem.png
     

    Attached Files:

    Last edited: Mar 30, 2014
  5. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    This one should be an easy one to fix =D In the Terrain Material editor window, you just want to change the "Z Offset" attribute on the left and right edges, to make sure they're behind the top and bottom edges. Right now, they probably have the same z-value, so they just get drawn in order.
     
  6. josessito

    josessito

    Joined:
    Feb 14, 2014
    Posts:
    57
    Of course! I'm such a moron! Thanks koujaku. By the way have you seen this?

    Apparently this tool never made it to the store, but the idea of combining Ferr2D with a planar "road like" terrain might be worth checking up. I haven't delve into the code of Ferr2D but maybe is not so hard to implement the same functionality (ie. changing textures at certain angles, etc) in this mode (or maybe it would be hell).

    Again thanks for the quick replay and keep up the great work!
     
  7. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    I have not seen that before! But it does look pretty cool =D I've pondered about doing something similar to that, but I haven't decided what the "Right Way" to implement it would be. I might get there! Right now, I'm actually spending a little thought on 2D lighting stuff, but we'll see what I get to first n_n Thanks for sharing!
     
  8. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    i have a problem and made this test scene to show my problem;

    http://www.atmuc.com/UnityTest/FerrTest/WebPlayer.html

    this scene has glitch on my 2 android tablets. they are asus memo pad 8 (quad core 1.8 Ghz cpu), artes 712(dual core 1.6ghz cpu, 1GB RAM, Quad Core Mali 400). there are few glitches on my nokia lumia 925. there is no problem on windows standalone build.

    in this scene there just ferr terrain and itween to move character and camera as pingpong.

    what should i check?
     
  9. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    Can you describe and provide screenshots of the glitches? I can't seem to tell just from that scene what's wrong.

    Feel free to email me at Nick.Klingensmith@simbryocorp.com
     
  10. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    i sent my test project to you by email.
     
  11. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    koujaku, i tested my project with just unity sprites. it stills occur. unity android build has problem. i have just one backgound sprite and camera. i move camera with itween. it's movement is not smooth on my androd tablets. i will post this problem to another thread. so you can skip my email.
     
  12. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    Update finally just went live!! Give it a try, and please let me know if you have any trouble with it! As always, if upgrading from an existing project, be sure to back it up~ There shouldn't be anything that'll screw stuff up, but it never hurts to be on the careful side =D

    And be sure to check out the smoothing! It should be pretty enjoyable to play around with n_n
     
  13. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    And if 1.0.7 going live isn't exciting enough, here's another thing I've been working on for the next version! Some more flexible UI, and scaling edges per-point!

    $ScalePoints.gif

    I may be changing the 'delete' command from Ctrl to Alt, that way I can put snapping on the Ctrl button. Also, Alt to reset the edge overrides and scale back to their default values =D
     
    SBull likes this.
  14. idTaken

    idTaken

    Joined:
    Sep 14, 2013
    Posts:
    22
    Nice tease...

    Alright 1.0.7 is finally up, but wait... what is this? Scaling is in the next castle?

    Keep'em coming.
     
  15. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    Haha, yeah, approval process took forever this time around! Scaling is also not 100% right now, caps don't play well yet, and I haven't tied in colliders! I was just excited about it, figured I'd tease a little ;D

    I actually think I may have found a nice solution for seamless corners too, so I may fit that in the next update as well. Of course, that's still a little ways before I get to that. I've still got 16 more games to publish first~
     
  16. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hey there! I updateded Ferr2D just now, and with smoothing I got this little problem here:



    As you see in the right at a certain point there the tool creates this "gaps".
    Here's another screen:




    (on another note, I also wrote you an email back about the Colour-Problem)
     
  17. k3pp

    k3pp

    Joined:
    May 2, 2013
    Posts:
    23
    Just updated my project with this update, but seems like the caps offset isn´t working anymore?
    Here´s a screenshot.
    $ferrupdate.JPG
    I´ve updated the project and this is a terrain that was already working fine for the previous version of ferr2d.
    If I make any modification to the terrain it is updated and becomes broken as seen on the screenshot.
    I tried to edit the terrain material, but seems like the "caps offset" isn´t working....

    Anyway, nice to see a update! The scale feature seems to be awesome!
     
  18. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    Ok! It looks like I just accidentally dropped the cap offset code when re-working the mesh creation for smoothing. Looks like I don't use cap offsets in my test scene o_-

    Just add this code to line #529 of Ferr2D_PathTerrain.cs
    Code (csharp):
    1.  
    2. Vector2 capLeftSlideDir  = (aSegment[1                 ] - aSegment[0                 ]);
    3. Vector2 capRightSlideDir = (aSegment[aSegment.Count - 2] - aSegment[aSegment.Count - 1]);
    4. capLeftSlideDir .Normalize();
    5. capRightSlideDir.Normalize();
    6. aSegment[0                 ] -= capLeftSlideDir  * desc.capOffset;
    7. aSegment[aSegment.Count - 1] -= capRightSlideDir * desc.capOffset;
    8.  
    It should come right before this line of code:
    Code (csharp):
    1.  
    2. point2   = aSegment[0];
    3.  
    I'll be looking into those little gaps too! Thanks for pointing it out! I have a feeling those will be a tiny bit trickier, but we'll see what I come up with.
     
    fidelsoto likes this.
  19. zbegra

    zbegra

    Joined:
    Dec 14, 2010
    Posts:
    10
    Thanks again! the fix worked :D
     
  20. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    I fooled around with some settings and these "gaps" only seem to appear when "Smooth Path" is checked, and ONLY when I move the Points to a certain "angle".

    So, when I check "Smooth Path" and don't change the points, it looks fine:




    When I now move the middle point down to a certain position gaps occur on the left side:




    When I move the middle point up to a certain position gaps occur on the right side:



    Maybe this will help to limit the problem/bug?


    And did already received my mail about the Color-Problem :) ?
     
  21. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    Alright, figured the gap problem! I was calculating my smoothed normals slightly wrong. Try this out! It's not my favorite, but it seems to work perfectly.

    In Ferr2D_Path.cs, replace the HermiteGetNormal method (on line #296) with this code:
    Code (csharp):
    1.  
    2. public  static Vector2   HermiteGetNormal (List<Vector2> aSegment, int i, float aPercentage, bool aClosed, float aTension = 0, float aBias = 0)
    3. {
    4.     if (aPercentage == 0  i == 0) return GetNormal(aSegment, i, aClosed);
    5.  
    6.     int   p1Index   = i;
    7.     float p1Percent = aPercentage;
    8.     int   p2Index   = i;
    9.     float p2Percent = aPercentage + 0.01f;
    10.  
    11.     if (p2Percent > 1.0f) {
    12.         if (i + 1 < aSegment.Count) {
    13.             p2Index = i + 1;
    14.             p2Percent = (aPercentage + 0.01f) - 1.0f;
    15.         } else {
    16.             p2Percent = 1.0f;
    17.             p1Percent = 0.99f;
    18.         }
    19.     }
    20.  
    21.     Vector2 p1 = HermiteGetPt(aSegment, p1Index, p1Percent, aClosed, aTension, aBias);
    22.     Vector2 p2 = HermiteGetPt(aSegment, p2Index, p2Percent, aClosed, aTension, aBias);
    23.     Vector2 dir = p2 - p1;
    24.     dir.Normalize();
    25.     return new Vector2(dir.y, -dir.x);
    26. }
    27.  
    If you guys spot anything else, please let me know! If nothing else comes up by the end of the day, I'll probably send these fixes off as a small update.

    And yeah, I saw your email about the color stuff, just replied to it =D
     
  22. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Yep, that did the trick! :D
     
  23. Ennothan

    Ennothan

    Joined:
    Oct 17, 2013
    Posts:
    51
    There's a problem with the new colliders, it is creating a curve on the edge when it shouldn't.
    I don't know if this is necessary for some of the new features, maybe a checkbox to use straight edge colliders.

    $edge.jpg
     
  24. k3pp

    k3pp

    Joined:
    May 2, 2013
    Posts:
    23
    Ok... maybe it´s a problem... but it´s the solution for a very big problem on my project! hehehehe
    PLEASE keep this! even if it´s a flag as Anguis suggested! hehehe
     
  25. Ennothan

    Ennothan

    Joined:
    Oct 17, 2013
    Posts:
    51
    Yeah, I think that keeping both ways is the best for everyone.
     
  26. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    Ok! Yeah, that was a bug fix, but I can definitely see why the old version might be better in this instance! I'll work on a solution for this, should be able to come up with a good thing that does both =D I need to do some work on my other project right now though, so I'll try and fit that in later tonight! Hopefully it won't be ridiculously hard.
     
  27. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    THAAANK YOU for getting the basic grid functionality addded. My game is mostly rigid shaped terrain, so before getting the collider lines perfectly straight like I wanted was time consuming, this is wonderful!
     
  28. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    Glad it's workin' out for you! It's not quite in the state I want it to be in, but I did find it to be usable~ should be a lot more enjoyable in the next version though, since I figured out how to make that scene toolbar =D
     
  29. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    I'm very interested in figuring this out. Where did you find this shader code from? How does your "light" object interact with the shader on the terrain? I would like to help you figure this out because it also interests me. I have not coded shaders before though so I need some direction on how to get started...
     
  30. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    I just realized that you can use the built in shader found under "Sprites/Diffuse" to have your texture react to normal lighting in Unity, this is awesome! (I'm very new to Unity so I assume other people already knew about this). Check out the attached screenshot, it looks really great but you will notice that the terrain edge and fill are having bleed through issues when using this shader. Is this what your shader you are trying to write is trying to fix josessito?

    @Koujaku, Would you know how this problem could be fixed? Once that issue is resolved, we could do some amazing things in regards to lighting our terrain using built in Unity lighting...

    $lightingTestIssue.png
     
  31. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    If I have some time tonight, I'll put together some shaders that do this properly too. I won't guarantee super efficient, but I'm pretty sure I can whip together something decent!
     
  32. Bitawu

    Bitawu

    Joined:
    May 11, 2013
    Posts:
    14
    That would be awesome! I've been waiting for an effect like this with the terrain tool. Also, thanks for another great update! Can't wait for those shaders! *drools*
     
  33. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    You the man Koujaku. Hope you have the time tonight! =)
     
  34. Ennothan

    Ennothan

    Joined:
    Oct 17, 2013
    Posts:
    51
    I'm really interested too in shaders with proper lightning, on my tests it lights a whole triangle of the mesh, which is completely wrong.
     
  35. Ennothan

    Ennothan

    Joined:
    Oct 17, 2013
    Posts:
    51
    Another bug, sometimes if you don't generate colliders on some side, uncheck "Generates Colliders along: left and bottom" for example, it is not using the collider thickness and instead is generating collider along the mesh.
     
  36. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    I did have some pain with drawing GUI lines for the "Generate colliders along" options. If the offending line you're seeing is yellow instead of green, don't trust it. Run the game, and check the collider in the scene, see if that's correct. I didn't have any problems with the actual generated colliders in my test cases, but I would be very interested to know if it is indeed ignoring the offset!
     
  37. Ennothan

    Ennothan

    Joined:
    Oct 17, 2013
    Posts:
    51
    The problem is exactly this yellow line, guessing this only show on impossible shapes

    First this terrain with yellow line and unchecked left
    $beforePlay.png

    after play it creates colliders along everything
    $afterPlay.png

    but with this shape the yellow line doesn't show
    $beforePlayB.png

    and after hit play it generates correctly
    $afterPlayB.png

    It's only me not using the tool right =D
     
  38. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    I draw a simple "closing line" from the last point to the first point, but with the options to disable edges, it ended up being a little too simple in a few cases! Pretty exclusively with disabled collider edges. It's literally just a UI thing, I draw it in a separate color to indicate that it's potentially not accurate to the final collider =D

    I would have fixed it already, but it doesn't break anything at all, and I've been super short on time. Next update, for sure =D
     
  39. Ennothan

    Ennothan

    Joined:
    Oct 17, 2013
    Posts:
    51
    Thanks =D

    Not a game breaking problem but it's good to know it will be fixed.
     
  40. fidelsoto

    fidelsoto

    Joined:
    Aug 7, 2012
    Posts:
    87
    Hi, I'm having an issue after the last update. Can you help me locate where the problem is?
    This happens when I press play, even on an empty scene.

    $err.png

    Edit: Actually there seems to be something weird about the latest build. Projects with the Ferr2D plugin imported take a long time to play after pressing the play button.
     
    Last edited: Apr 4, 2014
  41. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    Restarting the Unity editor should fix it, if it doesn't, please let me know, because it should! If it doesn't, try setting the mesh on your terrain prefabs to None which would force the terrain to re-build the mesh from scratch and save it properly. Did you have mesh saving code of your own in there or something?

    Prefabs used to have an issue where they didn't save the mesh in the scene, forcing you to rebuild them when the game starts or other awful things, so I save prefab meshes in the Ferr2DTerrainMeshes folder so you don't have to worry about that anymore! However, if you manually delete them (which shouldn't be a normal thing), Unity doesn't seem to pick up on that properly unless you restart the editor.

    Please let me know what/if something works for you here!
     
  42. fidelsoto

    fidelsoto

    Joined:
    Aug 7, 2012
    Posts:
    87
    The real issue I'm having is that scenes take too long to play. I removed the folders because I wanted to see if the long startup time was caused by Ferr2D. The error messages were coming from old prefabs I had, I deleted everything and everything was fine. I reimported Ferr2D from scratch and the problem is back (no error messages). Scenes take a long time to play after hitting the play button.
     
    Last edited: Apr 4, 2014
  43. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    Normally, re-compiling terrain at the start takes very little time at all (less than 100ms), but if you've deleted that folder and haven't reloaded the editor, the error message it gives you somehow takes a long time to generate, not sure what's up with that =/ Did you restart it?
     
  44. fidelsoto

    fidelsoto

    Joined:
    Aug 7, 2012
    Posts:
    87
    I created a new empty project, made an empty scene, imported Ferr2D and everything is normal. I'm going to clean up my project tomorrow (must sleep for now) and see if the issue persists.
     
  45. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    Ok, well, these don't work yet, but they're a tiny bit better than what I saw in the screenshots earlier. I'm not a fan of surface shaders, but I'm also not a huge fan of doing lighting code in the fragment shaders either! I've got a feeling that if I wrote this as a fragment shader, the overlap stuff would be way easier to solve, but it's almost 4AM, so I'm gonna call it quits for the night.

    Perhaps you guys can pull something out of 'em in the meantime. If not, there's a weekend looming on the horizon where I can get some good stuff done =D

    Opaque lit shader, works fine:
    https://dl.dropboxusercontent.com/u/2985443/Code/Unity/LitColored.shader
    Transparent lit shader, overlap at corners:
    https://dl.dropboxusercontent.com/u/2985443/Code/Unity/LitColoredTransparent.shader
     
  46. Sparticus

    Sparticus

    Joined:
    Mar 15, 2014
    Posts:
    149
    I just purchased Ferr2D Yesterday. I seems cool, but after creating terrain for all of maybe 5 minutes, the terrain magically disappears completely. I try undoing my last few actions, nothing. I search everywhere for it in the scene, it doesn't exist. I click on it in the Hierarchy and press F to focus it, it focuses on empty space.

    What am I missing? :(

    EDIT : I now noticed that when I click on "Path Vertices", they all say "NaN". Any idea what caused all the values to get removed?
     
    Last edited: Apr 4, 2014
  47. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
    Lets see, a few questions then. Does the path show, or is there really nothing at all? Do you have any errors in your code preventing the project from compiling properly? Is your inspector in Debug mode, rather than Normal mode? Does the mesh component have a mesh in it? Is it possible that you're on the wrong side of the terrain?

    Any other details you think might help?
     
  48. Sparticus

    Sparticus

    Joined:
    Mar 15, 2014
    Posts:
    149
    The path doesn't show at all. Sicne something changed all the vertices to NaN the code doesn't draw anything. The game compiles and runs. I am not sure mode my inspector is in (new to unity). The mesh component does have a mesh. Viewing the terrain from either side makes no difference.

    No one else has ever had this issue? I assumed it was common as it's happens all the time for me. :(
     
  49. koujaku

    koujaku

    Joined:
    Aug 28, 2013
    Posts:
    321
  50. Ennothan

    Ennothan

    Joined:
    Oct 17, 2013
    Posts:
    51
    The Shaders works really fine, I guess it's more optimized than the shaders I was using. And for the whole mesh triangle lightning what I did is mark all the lights with "Render Mode: Important" and now everything is working.