Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[FREE] YAPP - Yet Another Prefab Painter (Open Source, GitHub)

Discussion in 'Assets and Asset Store' started by Rowlan, Nov 24, 2019.

Thread Status:
Not open for further replies.
  1. KYL3R

    KYL3R

    Joined:
    Nov 16, 2012
    Posts:
    127
    Bug? Is Poisson Disk Distribution Mode broken? Prefabs appear offset in y-direction. Prefab is at 0,0,0, the container as well. "Center" is working correctly, so what can I do?


    Missing in the video: When I then move the container lower to "fix" it and continue painting, it's offset again on the same amount.
     
  2. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    That's odd. I just tried to reproduce, but couldn't. Which tree prefab are you using there? And what are the settings for it in the prefab section of YAPP?

     
    Last edited: Jan 6, 2021
    mahdi_jeddi likes this.
  3. KYL3R

    KYL3R

    Joined:
    Nov 16, 2012
    Posts:
    127
    Hey @Rowlan, Here are the settings in an album:
    https://imgur.com/a/PB3v8B5

    I'm using an empty GameObject, attaching the PrefabPainter and use that exact empty as the container as well. But I tried a different gameObject as container as well. Everything is at 0,0,0 I guess.
    Using "New" as a container (which creates a child) doesn't work either.

    + same behaviour when I use a different prefab.

    edit: I think I got it. The terrain is at y:-47 and the objects are placed 47 units too high. (I subtracted 47 to check)

    But it doesn't happen on "Center" Mode. Workaround for me: Place Terrain mesh on 0,0,0 and raise it for example. But it seems like a bug. Also: When I place my terrain on 50, the prefabs are placed 50 too LOW. So do you have a sign error here? :p
     
    Last edited: Jan 6, 2021
    Rowlan likes this.
  4. KYL3R

    KYL3R

    Joined:
    Nov 16, 2012
    Posts:
    127
    To fix YAPP, you need to edit BrushModuleEditor.cs:417
    from
    Code (CSharp):
    1.  
    2.     // get terrain y position
    3.     float y = Terrain.activeTerrain.SampleHeight(terrainPosition);
    4.  
    to

    Code (CSharp):
    1.  
    2.     // get terrain y position
    3.     float y = Terrain.activeTerrain.SampleHeight(terrainPosition) + Terrain.activeTerrain.GetPosition().y;
    4.  
    Because after that, the position is simply set to:

    Code (CSharp):
    1.  
    2.     // create position vector
    3.      Vector3 prefabPosition = new Vector3( x, y, z);
    4.  
    And then, y is only the sampled height. The Terrain Transforms y-position is lost because of that. The incoming Vector "position" from the Raycast of course was correct, but sampling around the raycast-hit is done in the foreach loop.

    I just created a Pull-Request on your Github :)
    https://github.com/Roland09/PrefabPainter/pull/4
     
    Last edited: Jan 6, 2021
    Rowlan likes this.
  5. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    Thank you! :) Merged it. Gonna shift my demo terrain again. I had it before at y != 0 for exactly that reason, i. e. detect those kinds of errors. But at some point I must have reset the transform.
     
    KYL3R likes this.
  6. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    I changed the behaviour of the terrain alignment vs random rotation. Now they can be combined. But please keep in mind that the values should make sense depending on your gameobject.

    Example: I got the Camel Spider asset and wanted to fill a Lordenfel dungeon with it. It made sense to align the spiders on the walls. And also to rotate them in Y direction. But X and Z wouldn't make any sense here either, they'd just look as if they stuck inside the walls. So the settings you use pretty much depend on the context.

    Here's an example:



    Or final pics, filling the dungeon took just a few seconds:

    crowd 2.jpg
    crowd 3.jpg
     
    Last edited: Jan 16, 2021
    dsilverthorn and Lars-Steenhoff like this.
  7. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    I just had to paint in some snakes as well, literally took only a minute to do so :D

    scene 01.jpg
     
  8. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,442
    Indiana Jones vibes!
     
    Rowlan likes this.
  9. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    This morning I started working on the Fence Builder I had on the roadmap.

    Turned out to be relatively easy with the fence prefabs of Meadow Enviornment:



    I'm gonna introduce more attributes to the prefab settings so that it can be generic (eg override the forward direction, etc) before I put it on GitHub.
     
  10. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    831
    Just in time for my latest project. :D
    I need to add street lights in a city. :)
     
    Rowlan likes this.
  11. Swyfft

    Swyfft

    Joined:
    Mar 14, 2019
    Posts:
    54
    day-um man .. need to get something to take care of them spiders!!
    .. don't think I'll EVER be able to walk thru Lordenfel again without looking over my shoulder............
    <shiver>
     
    Rowlan likes this.
  12. Microck

    Microck

    Joined:
    Oct 6, 2015
    Posts:
    5
    Hello just let you know that the latest version give an error
    "Assets\PrefabPainter-master\Assets\Yapp\Editor\Physics\AutoPhysicsSimulation.cs(7,18): error CS0101: The namespace 'Yapp' already contains a definition for 'AutoPhysicsSimulation'" :D
     
  13. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    The physics stuff got extended and I had to refactor the code structure to keep it organized. There's probably a duplicate class now, I guess you just updated an existing version? Please delete the old one first before updating. I just installed into a new project and don't get that error. If you still get it, please post the complete console. Thank you :)

    Does anyone know if things like that happen if you install directly from GitHub? I guess I should try that.
     
    Lars-Steenhoff and Microck like this.
  14. Microck

    Microck

    Joined:
    Oct 6, 2015
    Posts:
    5
    Yeah it's fixed by deleting the entire folder.
    The new version is way better than the old one I was using. Thank you. ;)
     
    Rowlan likes this.
  15. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,442
    I have another idea, for grass placement on a mesh ( not terrain )
    If you could spawn grass prefabs in a grid on a mesh, in order to quickly have a mesh full of grass. ( with some random variation )
    Not sure how easy this would be?

    A bit like the paint bucket tool in photoshop
     
    Last edited: Apr 8, 2021
  16. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    The poisson distribution basically does that, so it would be easy.
     
    Lars-Steenhoff likes this.
  17. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,442
    If they could be placed only per material on the mesh that would make it great, I have for example a racetrack and around the track is a grass material where I would like the meshes the be created on the surface
     
    Rowlan likes this.
  18. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    I added this, was just a matter of minutes. In case anyone else wants to extend the distribution, here's an example of what I did.

    The y-position was calculated using the terrain before:

    Code (CSharp):
    1.  // x/z come from the poisson sample
    2. float x = position.x + sample.x - brushRadius;
    3. float z = position.z + sample.y - brushRadius;
    4.  
    5. // y depends on the terrain height
    6. Vector3 terrainPosition = new Vector3(x, position.y, z);
    7.  
    8. // get terrain y position and add Terrain Transform Y-Position
    9. float y = Terrain.activeTerrain.SampleHeight(terrainPosition) + Terrain.activeTerrain.GetPosition().y;
    10.  
    11. // create position vector
    12. Vector3 prefabPosition = new Vector3(x, y, z);
    Now it's calculated using a raycast against any collider (i should add a layer option at some point):

    Code (CSharp):
    1. // x/z come from the poisson sample
    2. float x = position.x + sample.x - brushRadius;
    3. float z = position.z + sample.y - brushRadius;
    4.  
    5. float y = position.y + editorTarget.brushSettings.poissonDiscRaycastOffset;
    6. Vector3 currentPosition = new Vector3(x, y, z);
    7.  
    8. if (Physics.Raycast(currentPosition, Vector3.down, out RaycastHit raycastHitDown, Mathf.Infinity))
    9. {
    10.   y = raycastHitDown.point.y;
    11. }
    12. else if (Physics.Raycast(currentPosition, Vector3.up, out RaycastHit raycastHitUp, Mathf.Infinity))
    13. {
    14.   y = raycastHitUp.point.y;
    15. }
    16. else
    17. {
    18.   continue;
    19. }
    20.  
    21. // create position vector
    22. Vector3 prefabPosition = new Vector3( x, y, z);
    For this to work I needed to add an offset for the ray to start, you can change it in the inspector.

    So basically not something sophisticated or something one should charge money for ...

    Without further words, here's how it looks like:



    I'll see about the material request. Would be also easy to check against the splatmap. However, Unity is about to add something awesome, but no public information is available yet, nontheless implementing it today might turn out as having been a huge waste of time tomorrow because of this:

    https://portal.productboard.com/dzcznunfgebtky7ipmhrc22z/c/495-spline-editor

    I hope @gabrielw_unity can share some more information soon, I'm really excited for this :)
     
  19. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,442
    Hey thats already looking awesome!, thanks for adding this.

    About the material stamp, I don't use splatmaps and use only meshes for my ground surface not terrain, I hope gabriel will account for that :)
     
    Rowlan likes this.
  20. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    A more realistic use case :D

     
    chingwa and Swyfft like this.
  21. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,442
    Thats a quick way to take out the trash :)

    Really usefull to quickly create a lot of objects!
     
    Rowlan likes this.
  22. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    Last edited: Apr 24, 2021
  23. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    957
    Hey! :)

    What's this thing I'm maybe doing that affects YAPP? :D Happy to shed some light if I can!
    (super cool work, btw)
     
    Baldinoboy and Rowlan like this.
  24. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    957
    Erm, if it's just Splines in general - the current plan is just to provide a foundational spline system. So, ideally YAPP would actually benefit from the new system, not be replaced at all! :)
     
  25. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    957
    So, we would provide this part ... the rest is up to you :)
    (as currently planned, yada yada)
    upload_2021-5-4_15-16-58.png
     
  26. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    Thank you very much for sharing! I'm even more excited now :D I also gotta try that new toolbar system, that looks very helpful.
     
  27. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    535
    @Rowlan That's why i messaged you on Discord. DONT STOP ;)

    @gabrielw_unity i can't wait for this baseline to be in everyones hands keep it up too :D
     
  28. pitibonom

    pitibonom

    Joined:
    Aug 17, 2010
    Posts:
    188
    wow 8-O
    This one seems insane !

    I myself wrote a tiny YAPP as i didn't knew this one existed.
    No doubt i'll give it a try :)
    Thanks a lot for this piece of awesomeness ;)

    Happy unitying !
     
  29. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    Feel free to fork, modify and enhance. But I suggest naming yours differently in order to avoid confusion for the users.
     
    Last edited: Jul 30, 2021
  30. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    598
    Trying this today, and it seems great! I'm running into a few small problems.

    - Is it possible to update the spline position when an object moves? I can't move an object created with YAPP splines.

    - Is it possible to fill a spline area with objects?
     
  31. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    - Can you describe the use case with an example? However, YAPP is intended to be an Editor tool for prefab placement, not a Runtime tool.

    - You mean filling a Spline based Polyogn with objects? In theory yes, but currently not possible, the Brush should be sufficient enough to fill an area quickly. Personally I prefer Vegetation Studio Pro for that task since it also handles the performance.
     
  32. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    598
    I mark out a section of my map with splines for road edges or similar, but then we discover the section would be better off 100 metres east. The YAPP splines do not move, causing the spline to snap back to the original world space location.
     
  33. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    Thanks, yeah, I wanted to add that and other things (saving, loading etc), but waited for the new Unity Splines package to surface. Currently you can move the entire Container (ie parent gameobject) in which your painted gameobjects reside to move them all at once.
     
  34. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    598
    Ah, it makes sense to wait for Unity Splines to avoid adding bloat to this, especially if it lets you streamline the code and add more features. Thanks for letting me know!
     
    Rowlan likes this.
  35. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
  36. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    I wanted to use the awesome Castle Valley Collection for the upcoming Malbers Crocodile. So I made a few modifications to facilitate the placement of the rocks and vegetation.

    Here it is in action:



    Some of the updates:

    Brush settings:

    * layer mask for the brush raycast
    * resize prefab to the brush size
    * brush rotation indicator
    * individual brush indicator visibility

    brush settings.png

    Prefab settings:

    * quick rotation setting buttons X / Y / Z / XYZ

    quick buttons.png

    Also, now that I used it, I guess it makes even more sense to have the prefab shown as preview. I guess I have to add that.
     
  37. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,442
    Yes it would be a good thing to see the prefab preview
     
    Rowlan likes this.
  38. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    Yeah, that's way more fun with a preview. I changed the Distribution "Center (Brush Size Scale) to "Fluent (with Preview)", there's more to come in that matter, the ideas just kept on coming while using this. I'd love to have even more fluent precision prefab placement. Here's how it looks now:

     
  39. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,442
    Wow that looks very good and nice for precise placement!
     
    SickaGamer and Rowlan like this.
  40. SickaGamer

    SickaGamer

    Joined:
    Jan 15, 2018
    Posts:
    1,257
    Great job Rowan!
     
    Rowlan likes this.
  41. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    It made sense to add movement along the Up axis of the prefab while you drag the preview around. So I added that feature. The movement is relative to the bounds. eg for plates with 1 meter height you want different movement compared to rocks of 50 meter height.

    Usage: Alt + Scroll Wheel in Fluent distribution mode.

    Looks like this for the Fins and Plants, ie the same as above, but with stomping the rocks into the ground:



    The key bind might change in the future. I have to find out first how to catch keys in scene view when the scene view doesn't have the focus. I also might look into using the mouse movement rather than the wheel for finer granularity. But then again for fine tuning one can always use Unity's own transform tool.
     
    Last edited: Aug 21, 2021
    Lars-Steenhoff and TerraUnity like this.
  42. jade_xiv

    jade_xiv

    Joined:
    Sep 9, 2021
    Posts:
    1
    Hi! I'm running into an error as I'm trying to import the yapp project into Unity 2019.2.13f1

    Has anyone encountered this before? Do you know how to workaround or fix this?

    Thank you!!
     

    Attached Files:

  43. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    Thanks for reporting this. I fixed it for 2019, should work now.
     
  44. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    831
    This is a Teaser for an upcoming project continuing the Apollo's Dream series.

    The video was made with Unity 2019 using this asset.
     
    Rowlan and Baldinoboy like this.
  45. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    290
    Thanks for making this awesome tool. I am not a very creative person and struggle with anything involve art. I prefer coding but I have decided to tackle making a map. Your tool/video's are super helpful and a great starting point.

    Thanks for sharing this awesome tool!
     
    TerraUnity and Rowlan like this.
  46. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    535
    Rowlan certainly has some great qualities!
     
    TerraUnity and Rowlan like this.
  47. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    831
    This video was made using this asset. I love the ease of use of YAPP. It has become a favorite tool. And it's free too! Thanks @Rowlan !!



    Third in the Apollo’s Dream series, we make these for all people to find some peace and beauty in this world of chaos. We hope you enjoy it.
     
    StevenPicard and Rowlan like this.
  48. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,792
    Looks great. I love especially the owls. It's always a deep feeling when you go in the forest and are surrounded by them and get watched :)
     
    dsilverthorn and StevenPicard like this.
  49. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    831
    Thank you! :D
    Very much appreciated.
    Owls do seem to know something. You’ve got to love the owl. And when they are in groups and watching you, it is very mysterious.
     
    Rowlan and StevenPicard like this.
  50. glumleaf

    glumleaf

    Joined:
    Jan 30, 2016
    Posts:
    22
    This is by far the best and most straightforward prefab painter I've come across. Thank you so much for making this!

    Is it possible to place prefabs using the Poisson distribution on a slanted/curved surface while maintaining a circular and even spread? Like this (the left is how it currently works, the right is my desired outcome):

    I know the placement method gets the XZ positions from the Poisson sample and raycasts downwards to get the Y position, but I'm wondering if there's a way to maintain a nice circular and uniform spread on any arbitrary surface. The way it currently works, it's somewhat difficult to spread prefabs all over the surface of a cliffside or the interior of a cave with any sort of consistency.

    I totally understand that this might be a pretty complicated thing to handle, though! Either way, great asset.
     
Thread Status:
Not open for further replies.