Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Official 2D Sprite Shape is out of preview for 2019.3

Discussion in '2D' started by rustum, Jan 30, 2020.

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

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    194
    Why not unity just buy the ferr2D or hire the developer to work for them? I also don't know why people most of the time use tilemaps but reject the idea of using sprite shape 2D.
     
  2. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    It's not really a feasible option to hire a 3rd party developer, who probably is busy with other things, for a simple asset that they already have a functioning version of. And SpriteShape and Ferr2D are wildly different which is not really a bad thing even though the goal of both being relatively the same. Despite Ferr2D currently being 'better', it still has a lot of flaws. In my opinion SpriteShape has more potential given that it's more integrated into Unity's framework, they just need to find the time to improve it and add features. But I understand why that would be low priority right now.
     
  3. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    I gotta check our Ferr2d. I have problems with using continuous shapes and different sprites in different directions, and I’d also like to make a shader for the fill and outlo r to make shadow effects for our 3/4 topdown game. Can ferr2d do that?:)
     
  4. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    I checked the vids on Ferr2d and it seemed to fit our project very well, with the different types if gradients you can put on the fill and also it seems to support different sprites even if it’s a continuous line.

    But it seems abandoned and the reviews say it doesn’t support 2d lights. Can anyone confirm that?
     
  5. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    194
    The developer works for hololens for Microsoft. He seems very happy with it. But he is not making updates on the Ferr2D plugin now.
     
  6. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    @nicmarxp The sprite that is used along the spline can be specified through 1) Angle Range 2) Variants.
    Angle Range : This will set the Sprite along the spline for the Angle specified from point to neighbor. An Angle Range is calculated on start of Every point that is set to Linear of Broken Tangent mode. For Continuous Tangent mode, Angle Range Sprite is only calculated on point where the Continuous mode starts and the same sprite is used for subsequent points where the Tangent mode is Continuous. If you want to set a different sprite within this Continuous sequence of points you can use Variants.

    Please take a look at the Enclosed demo.
     

    Attached Files:

    nicmarxp likes this.
  7. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    @pastaluego
    SpriteShape provides 3 different Quality for Spline Detail which are usually good for most set of Inputs (4, 8, 16). Beyond 16 the topology is generally indistinguishable. However you may want to have even more fine grained Subdivision that may result in better UV along very acute curves. While 4, 8, 16 are the ones that are set by default, you can experiment with higher Spline Details to achieve the better UV. Please take a look at the enclosed demo and the sample script.


    We believe Corner sprites are provided to solve such cases.

    Thanks again for the feedback.
     

    Attached Files:

  8. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    Thanks a lot, the broken points helped.

    What I'm trying to achieve is something like this. Do you think it would be possible?
    The confusing part is drawing everything pointing in the same direction, and making the seam between the sprites work, but it doesn't seem impossible.. :)

    pond.png
     
  9. zlremillard

    zlremillard

    Joined:
    Nov 19, 2014
    Posts:
    11
    Hello!
    Let's say I want to build something like the "vine" from the image in the first post of this thread and I would like to "reveal" the vine with an animation where it appears that it's growing along the spline.

    How could I achieve something like that? I've tried playing with a cutoff shader based on the uv but it affects each segment of the spline individually instead of the entire Sprite Shape. Is the mesh generated by Sprite Shape properly uv-mapped so that it can be filled from 0 to 1 in its entirety?
    Thanks!

    spriteShape.png
     
  10. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Does the SpriteShape API or API for the underlying Spline allow you to get positions along the spline at points other than the nodes?
    I'd like to add some functionality to SpriteShape to position GameObjects along the spline. I'd like to be able to position them anywhere along the spline (not just the nodes) and I'd like to be able to get the tangent/perpendicular for that point as well.

    Is this possible with the SpriteShape API's?

    -Jeff
     
  11. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Please take a look at Sprinkler script in SpriteShape Samples. Please use the attached script that extends the sample Sprinkler script to place a node at any random position in the Spline not just control-points.

    Please note: The attached script is just a demonstration of how it works. You may want to extend it to suit to your needs. We may update and refine this script in the Samples in near future. Thanks.
     

    Attached Files:

    Peyot and jeffweber like this.
  12. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    I believe this can be done with Seamless variants and/or multiple SpriteShapes overlayed on top of another to achieve this.
     
  13. UWSUMUT

    UWSUMUT

    Joined:
    Jul 14, 2020
    Posts:
    9
    Hello, I have made a sprite shape profile with multiple sprites for different angles but sprite variants won't be shown if the tangent modes are set to continuous. They only work in linear or broken modes. Is there any way to achieve the same effect with smooth, curved corners?
     
    Last edited: Oct 30, 2020
    RemDust likes this.
  14. mikeacall

    mikeacall

    Joined:
    Oct 7, 2020
    Posts:
    1
    @Venkify Not sure the best place to ask this question, please direct me if this isn't the right place. I'm using 2D sprite shape. On my shape, hen i use a linear tangent, i can't get the vertex to stretch. As seen in the top picture. If i set the vertex to continuous the vertex stretches and looks better, but ends up mucking up the next vertex, causing the corner image to not display. Any thoughts?
     

    Attached Files:

    Last edited: Nov 5, 2020
  15. JauntyBearGames

    JauntyBearGames

    Joined:
    Mar 26, 2018
    Posts:
    57
    hi everyone, I'm trying to auto-destroy my platforms by calling OnBecameInvisible. This function is not triggered for sprite shape renderers; maybe I've got it wrong, has anyone tried? Would it be possible to support this event? thanks
     
  16. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    Is there any way to detect if a sprite shape was updated at edit time?

    We're using both SpriteShapes and Tilemaps, and for the Tilemaps we're heavily using
    Tilemap.tilemapTileChanged
    in order to do post processing of the generated geometry. It'd be really convenient to have something similar for SpriteShapes, but I can't find anything in the API.
     
    NotaNaN likes this.
  17. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,503
    Hey, you might be able to accomplish this with a custom Culling Group.
    https://docs.unity3d.com/Manual/CullingGroupAPI.html

    Unity provides a detailed example for setting up custom Particle System culling.
    https://blogs.unity3d.com/2016/12/20/unitytips-particlesystem-performance-culling/

    Basically you can define sphere(s) and receive callbacks for visible/invisible etc.
     
  18. KoolGamez

    KoolGamez

    Joined:
    Apr 11, 2020
    Posts:
    29
    Can someone direct me to a resource that explains how to use this tool to create procedural shapes in Unity? I have tried searching for it and can't seem to find a comprehensive explanation/tutorial. My goal is to create endless shapes like twisting top/down roads or a smooth hills (like the ones in alto's adventure) using this asset
     
  19. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    194
    Can someone list me the PROS and CONS of Spriteshape? I hate making tiles. I really don't want to use tiles. I am wondering if I can totally replace tiling with Spriteshape.

    If Spriteshape does not meet the requirements maybe I will buy Ferr2D or Spline Terrain 2D

    But the problem with 3rd party tools is the support and after a while they stop developing the tools. Thus, becoming outdated.
     
    Last edited: Nov 21, 2020
  20. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Is it possible to have a gradient fill on a sprite shape. Either out of the box or using custom shaders?
     
  21. jrmgx

    jrmgx

    Joined:
    Oct 21, 2016
    Posts:
    41
    I've see that issue 1274400 has been fixed for version 5.1 of the spriteshape package and that's nice (I'm having this issue) but it's been reported on version 3.0.12 (unity 2019.4 LTS, the one I'm using) is it going to be back ported?
    If not (it will be a shame as 2019.4 is LTS), but anyway is it possible that I can do it myself?
     
  22. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Thanks for the post. Variants should work in Continuous mode as well. Please let us know the version of SpriteShape you are using. A quick demo is attached:

    SpriteShapeVariants.gif
     
  23. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    A control point will be considered a Corner (Stretched or Auto) only if its neighbors are also in Linear mode.
    The reason is when using non-Linear neighbors, the corner can become distorted at acute angles and will result in geometry artifacts. As of now, please workaround by adding a linear point closer to the corner on both sides and it should now add a corner at the Control point. We will consider allowing more flexibility in the future. Will post an update once we have some info.
     
    RemDust likes this.
  24. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    OnBecameInvisible() as well as OnBecameVisible() are both supported and should work well for SpriteShapeRenderer. Please submit a bug report with a simple repro project. Also please let us know the version of SpriteShape used. Thanks.
     
  25. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Please take a look at the function
    bool HasSplineDataChanged() in SpriteShapeController.cs
    You could add a similar function in your project and check for a change in hash. Hope this helps.

    We will consider this in an upcoming version. I will keep this thread updated. Thanks.
     
  26. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Yes, I would suggest creating a custom shader that blends the fill texture and the gradient texture.
     
  27. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Thanks for the post. We will ensure this gets backported in the upcoming version (3.1.5 hopefully). Will keep this thread posted. Thanks again.
     
    jrmgx likes this.
  28. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    87
    Hi! I'm having a hard time creating interiors, is it possible to invert Sprite Shapes? I've searched everywhere but haven't found an answer... This would also be helpful for other stuff like caves and so on.

    inverted (wanted).png right-now.png
     
  29. MGNClam

    MGNClam

    Joined:
    Jul 20, 2019
    Posts:
    2
    Is it possible to use this to quickly lay down floor for level, where 2 things happen (And yes, i know i could in theory do this with tiles)

    1. I only want the floor to rise/fall in x angle increments. So for example, the floor is either 15, 30, 45 or 60 degrees.
    2. I ideally want to snap each section to a grid along the X-axis, so I can properly space out jumps/etc.
     
  30. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    431
    Am I the only one thinking that SpriteShape would benefit from a "multi LAYERS" feature ?
    I often end up duplicating my spriteshape objects to use the same splines with different Profiles (mainly for Sorting Order and perspective purposes)

    It's quite tedious and make modifications in level a bit painful ;)
     
  31. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    I would suggest to use 2 SpriteShape objects with some points sharing common position. You may want to take a look at ConformingSpline sample in SpriteShape extras that allows editing 2 Shapes but share common points. Please note you may want to edit the script to suit your needs (only share data for certain control points and not all).
     
  32. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Could you please provide more info or a demo screenshot ?
    You can enable Snapping while in Edit mode as well.
     
  33. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    87
    Thank you for the suggestion, appreciated. Do you mean one for terrain/ground/walls and the second one for the roof? It would still cause visible seams? I think the "invert" option would be much easier and better for level designers, is this something in the works, and/or possible? Thanks again
     
  34. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Is it possible, within a custom editor script, to get the currently selected nodes of the SpriteShape spline?
     
  35. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    @jeffweber Please take a look at

    OnInspectorGUI of SpriteShapeControllerEditor class in the file Packages\com.unity.2d.spriteshape\Editor\SpriteShapeControllerEditor.cs

    selection.elements is probably what you want to get the selected points in Editor mode.
     
    jeffweber likes this.
  36. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Thanks for the update. Will take a look to consider this. Will post an update.
     
  37. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Cache Geometry does not behave correctly when set on a Prefab.

    I created a prefab for my SpriteShapeController. On that prefab, I set "Cache Geometry" to true.

    Now, when I use the prefab in the scene, I can see it in edit mode, but when I run it disappears.

    Now, if on that prefab instance, I un-check and re-check "Cache Geometry" everything works fine again. Cache Geometry just doesn't seem to work with prefabs, I always have to check the box explicitly in the scene for it to work.

    -Jeff
     
  38. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    @jeffweber
    We are aware of this issue and will fix it the earliest. Will post an update..
     
  39. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    @RemDust Please take a look at ConformingSpline.cs script available with SpriteShape Extras that provides functionality to copy Spline data of the child Object from the specified Parent Object as you edit the Parent object.
     
    RemDust likes this.
  40. dowhep

    dowhep

    Joined:
    Dec 2, 2020
    Posts:
    1
    Is it possible to reduce the size of the border of closed SpriteShape without scaling the whole object down?
    upload_2021-2-16_23-11-41.png
    I really liked the freedom SpriteShape provides and the potential feel of "water drop/paint stain" (for lacking a better description). However, I have not been able to find a method within the controller that is able to change the width of the border. Or is there a better replacement for my purpose?
     
  41. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    205
    @Venkify Would it be possible/practical to set the stencil buffer (in the exact same way a SpriteMask would) using the SpriteShape?

    I'm working on a 2D top-down game, and we have puddles on the ground that are used as the stencil for drawing reflections on top of them. Right now we're using sprites for the puddles (and SpriteMask), but it would be excellent if we could use SpriteShapes instead so we could quickly make the puddles the exact shape that we'd need.

    The problem I'm running into is that we can't use SpriteMask with SpriteShapes, and I'm not exactly sure the inner workings of how SpriteMask works to make my own custom solution for the SpriteShape.

    I think it might be as easy as using a custom shader for the Fill/Edge material that adds a Pass that sets the stencil buffer? But I know that the SpriteMask has a special "range" (Sorting Layer / Order In Layer) that it sets the stencil for, and I can't find enough info on that to create my own solution.

    Thanks for any help!

    Edit: I was able to get a basic configuration work for this by making a copy of the Sprite-Lit-Default shader and customizing it by adding this stencil setting:

    Code (CSharp):
    1. Stencil {
    2.          Ref 1
    3.          Comp always
    4.          Pass replace
    5. }
    This happens to be okay for my specific usage (making a mask for reflections in the puddles), but it only applies the Stenciling at the same point in the rendering process as the SpriteShape is rendered. When using a SpriteMask it lets you set a custom range, so you could technically set the stenciling before the actual Sprite is renderered, or after, etc.

    Would love to know if that would be possible to do - maybe another separate Pass in the shader? Or maybe creating another SpriteShapeRenderer but having it somehow reference the original one's mesh and then using a custom shader that only sets the Stencil (and doesn't actually render any colored pixels)? Wish I could see the inner workings of how the SpriteMask worked !
     
    Last edited: Feb 24, 2021
  42. jrmgx

    jrmgx

    Joined:
    Oct 21, 2016
    Posts:
    41
    Hello, I have a bunch of questions about spriteshape and corners
    This is my Sprite shape profile:

    and this is a video where from left to right let's call point 1, 2, 3


    Question about point 1 and spriteshape controller in general:
    - Why this empty space (there is like an empty triangle shape not filled with the fill texture?)
    - What is the meaning of "Corner Threshold" option?

    Question about point 2:
    - Why it never goes into a corner? My adjacent points are all linear but still no luck.

    Question about point 3:
    - Basically the same as point 1 and 2, I have that empty space on the left, and then I try to get a corner on the right with linear points with no luck.

    Note that the official doc does not mention "Corner Threshold"
    I use 3.0.15 with unity 2019.4 LTS last patch
     
  43. jrmgx

    jrmgx

    Joined:
    Oct 21, 2016
    Posts:
    41
    Also, it would be a dream to have corner on non-linear spline too, that way I could easily have a better feel on these kinds of terrain (auto generated). I'm stuck on unity 2019.4 LTS with SpriteShape 3.015
     
  44. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Thanks. You can try adjusting the height of each control-point to adjust the 'height' of the border. Or you can change the Pixel Per Units of the Edge Sprites. Please let us know if this helps.
     
    dowhep likes this.
  45. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Sorry for the delay in response. Yes, this has been backported and is available in 3.0.15
     
  46. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    I believe these are pre-requisites for a control-point to be considered a valid Corner.
    1. The Edge Sprite and the Corner Sprite should be of same height.
    2. Both the selected and adjacent control points have the same Height.
    3. Sprites rendered at the Corner point and its neighboring points must have the same Sprite pivot.

    More info on CornerThreshold here :
    https://docs.unity3d.com/Packages/com.unity.2d.spriteshape@5.0/manual/SSController.html

    Also enclosed is a demo of how it works. In simpler terms, the angle α in the screenshots should be smaller than the CornerThreshold for the control-point to be considered as Corner.
     

    Attached Files:

  47. KetanAcidTripArts

    KetanAcidTripArts

    Joined:
    Aug 31, 2020
    Posts:
    1
    Is this possible to export created shapes as png file?
     
  48. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    87
    Hi! Did you have a chance to look at it (inverting shapes feature)? As me and my team are still struggling with closed interiors, like rooms and caves, to look good without having visible seams. Please have a look at the two pictures I posted before, would appreciate it a lot. I think this would be useful for a lot of other stuff too
     
    RemDust likes this.
  49. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Based on your post, wouldn't a closed shape fulfil the requirement (The closed shape in red in the attached screenshot). Its not quite clear what you would like to have. Could you kindly post a mockup Image of exactly what you are looking for ? That would be really helpful.
     

    Attached Files:

  50. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    87
    That picture (marked "2" in the corner) is actually a mockup of what I want to achieve, sorry if I was being unclear, and the first picture (marked "1" in the corner) is what it looks like right now. How do I close the shapes as in the picture? I can't seem to find that feature. I'll attach some more examples...

    I want to be able to invert the shapes, which gives me the ability to create interiors and caves, I'll attach another mockup, found from google. I need the colliders to be on the outside, not on the inside (for obvious reasons)


    interiors-right-now.jpg
     
    Last edited: Mar 1, 2021
Thread Status:
Not open for further replies.