Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Official 2D Sprite Shape 6.0 released for Unity 2021.1

Discussion in '2D' started by rustum, May 10, 2021.

  1. rustum

    rustum

    Unity Technologies

    Joined:
    Feb 14, 2015
    Posts:
    190
    2D Sprite Shape 6.0 released for Unity 2021.1

    Sprite Shape.png

    What’s new?
    With the release of Unity 2021.1 2D Sprite Shape 6.0 is now available. In this release:
    • The Sprite Shape edge height is now interpolated linearly between control points that are both linear and smoothly if otherwise.
    • See the full changelog here.
    About Sprite Shape
    Sprite Shape is a flexible and powerful world building Asset that features Sprite tiling along a shape's outline that automatically deforms and swaps Sprites based on the angle of the outline. Additionally, you can assign a Fill texture to a Sprite Shape to create filled shapes with tiled textures as backgrounds or other large level-building props. Read more in the Sprite Shape documentation here.

    Getting Started
    In an existing project in Unity 2021.1:
    1. Open Package Manager by going to Window > Package Manager
    2. Select Unity Registry in the Packages drop-down menu.
    3. Choose 2D Sprite Shape from the list and click on Install at the bottom right of the Package Manager window. 2D SpriteShape Package.png
    Creating a new project in Unity 2021.1 by selecting the 2D Template in Unity Hub will also install 2D Sprite Shape 6.0 by default.

    Explore the Samples
    2D Sprite Shape comes with Samples showing the features in action and Extras scripts that show how to extend the functionality of Sprite Shape.

    To get the samples:
    1. Open Package Manager by going to Window > Package Manager
    2. Select Unity Registry in the Packages drop-down menu.
    3. Expand the Samples section.
    4. Click the Import button next to the sample you want to import. 2D SpriteShape Samples.png
    What can you do?
    Try it out and let us know what you think of the package. We want to know what works as expected, what doesn’t and what is missing.
     
  2. Deleted User

    Deleted User

    Guest

    Yeah, I must be particularly dumb because I cannot even reproduce the more basic of the samples... Either the outline is entirely orange, or the green one is down on the right instead of on the top.

    Okay, after toying a bit with your sample, I understand that the outline colour is linked to the points, move the points and the outline colour will move with it.

    Capture d’écran_2021-05-13_00-04-31.jpg
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,272
    Yeah, the SpriteShape can only change which texture it uses when it passes a non-continuous node. Otherwise it keeps using the angle value of the first counter-clockwise node that's not continuous.

    This behavior is not documented as far as I can tell, and I have no idea why they did that. Maybe @rustum has some insight?

    There's also a bunch of other stuff that's just not written down in the docs. There's a lot of things you have to know about how to build the textures and how to set the sprite borders on import in order for things to not look like a disaster that you just have to figure out by testing and by working backwards from the samples.

    So while the SpriteShape can give you great results, nobody bothered to sit down and write how to get those great results from the tool.
     
    RemDust, NotaNaN, samlletas and 3 others like this.
  4. Deleted User

    Deleted User

    Guest

    Yeah, I have given up on that for now. I had in mind that I could animate sprites using that tool but it seems that 2D Animation will do that very well after all. And it's easy to use too! :)
     
  5. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
  6. Deleted User

    Deleted User

    Guest

    enhawk likes this.
  7. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
  8. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,272
    april_4_short likes this.
  9. Deleted User

    Deleted User

    Guest

    I cannot agree with that; I cannot speak for all the packages either but I've learnt how to use some of them reading their documentation. The SpriteShape one is lacking, true, but you cannot judge all the others by this one. :)

    Also, I'm not sure you can find this specific documentation using a search engine, people need to get the right reflex: if you need to learn about a package:
    1. open the package manager,
    2. go to the package you need to learn about,
    3. click on the documentation link on the right.
    Capture d’écran_2021-05-27_16-44-04.jpg
    :)
     
    ToolmakerSteve likes this.
  10. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,516
    Normal map rendering is broken with 2drenderer using spriteshape.
     
  11. Deleted User

    Deleted User

    Guest

    Normal map is broken in URP 11 anyway. :) Works in URP 12.
     
  12. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,516
    Right... where did you get that information?
     
  13. Deleted User

    Deleted User

    Guest

  14. basklein_

    basklein_

    Joined:
    Apr 30, 2015
    Posts:
    1
    Is there any way to merge SpriteShapes? Or even just make it look as if they are merged?
    I'm trying to use SpriteShapes to build rooms that close in on themselves, so there are quite a couple of points where my shapes overlap themselves or other shapes and I would like those to blend into each other to create a closed loop. (I've attached an image to better explain what I mean.)
    Now I know that SpriteShapes, as they are now, are more intended for platformers and the like, but I feel like even platformers could greatly benefit from such a feature.

    Is this a planned feature, or are there already ways of solving this problem?

    I think one way to fix this would be to allow users to manually set which sprite a segment should use. We can already disable corners, so I think being able to change the line sprite would be nice too.
     

    Attached Files:

    NotaNaN and RemDust like this.
  15. Quetzal_Studios

    Quetzal_Studios

    Joined:
    Jan 2, 2017
    Posts:
    7
    Are there chances that SpriteShapes will use Secondary Textures someday? Custom materials?
     
  16. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,516
    SpriteShape does seems like it is rendering normal map, but it is not rendering it properly. It does not take shape tangent into account, which makes it look wrong. Not really usable with normal map right now. At least with 2drenderer.
     
  17. UncleAlias

    UncleAlias

    Joined:
    Aug 18, 2017
    Posts:
    27
    Since I updated SpriteShape to 6.0.1, the edge colliders on my platforms now end where the spline ends instead of where the sprite ends. Is this part a new feature? Any ideas on how to fix it? Is this happening to anyone else?
    2021-06-26.png
     
  18. UncleAlias

    UncleAlias

    Joined:
    Aug 18, 2017
    Posts:
    27
    Is it possible to upgrade to Unity 2021.1 without upgrading to SpriteShape 6.0.0?
     
  19. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,516
    If you call BakeMesh();

    and then have scene unloaded so the SpriteShapeController is destroyed I get :

    InvalidOperationException: The previously scheduled job SpriteShapeGenerator writes to the Unity.Collections.NativeArray`1[Unity.Mathematics.float2] SpriteShapeGenerator.m_ColliderPoints. You must call JobHandle.Complete() on the job SpriteShapeGenerator, before you can deallocate the Unity.Collections.NativeArray`1[Unity.Mathematics.float2] safely.
    Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckDeallocateAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <adfa4b62400849189388df71c9e26e89>:0)
    Unity.Collections.LowLevel.Unsafe.DisposeSentinel.Dispose (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle& safety, Unity.Collections.LowLevel.Unsafe.DisposeSentinel& sentinel) (at <adfa4b62400849189388df71c9e26e89>:0)
    Unity.Collections.NativeArray`1[T].Dispose () (at <adfa4b62400849189388df71c9e26e89>:0)
    UnityEngine.U2D.SpriteShapeController.DisposeInternal () (at Library/PackageCache/com.unity.2d.spriteshape@6.0.1/Runtime/SpriteShapeController.cs:247)
    UnityEngine.U2D.SpriteShapeController.OnDisable () (at Library/PackageCache/com.unity.2d.spriteshape@6.0.1/Runtime/SpriteShapeController.cs:267)

    Any Idea?
     
  20. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    632
    Reposting from (https://forum.unity.com/threads/spriteshapecontroller-invalidoperationexception.1136695/) for visibility.

    SpriteShape generator runs in a Job. If BakeMesh is called, please make sure to complete this Job before destroying the Object or Unload the scene.

    var jobHandle = spriteShapeController.BakeMesh();
    // You can also call BakeCollider to update Collider here.
    jobHandle.Complete();

    Otherwise the Job might be running in parallel while the GameObject is being destroyed, hence the error message. Thanks.
     
  21. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    431
    It's been almost 2 years since I feel like merging and creating holes in spriteshape should exists.
    At first glance Sprite Shape seems great to create a metroidvania, it turns out it's an awful idea...

    Such a shame actually, I was so high on it -_-
     
  22. Deleted User

    Deleted User

    Guest

    I haven't tried yet but you coul probably create holes using ProBuilder: https://unity.com/features/probuilder
     
  23. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    431
    I'll take a look, but it's a bummer that the very tool designed by Unity to help 2D level design doesn't allow user to create closed shape, open them up later (level design is evolving, nothing new here)

    I know I can "simulate" a hole by displaying an empty sprite in the Shape, but I absolutely need to be able to "cut" the collider also to allow the player to walk through !
     
  24. Deleted User

    Deleted User

    Guest

    Well, ProBuilder is for 3D mainly but maybe you could make objects that are usable in 2D. :)
     
  25. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    431
    Which implies rethink the entire project ^^
    I have a 2d artist who draws "tile maps" and other 2d assets, converting to pro builder feels like a huge pain :/
     
  26. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    802
    Just wondering if there will ever be the ability to set the corner type of a node? I always need it to be stretched and a lot of times I forget to change a new nodes to it. I tried making a script to automagically set the type to "stretched" but there was no api for it.

    Thanks!
     
  27. indie6

    indie6

    Joined:
    Dec 15, 2012
    Posts:
    101


    Timestap: 4:45

    Is there a way to do the inverted closed fill, as seen in the above Ferr2D video
     
    Last edited: Aug 22, 2021
  28. indie6

    indie6

    Joined:
    Dec 15, 2012
    Posts:
    101
    Same here, I really need this feature for a game.. and there are 2 options currently

    Ferr2D (last updated 13 April 2019)
    Spline Terrain 2D(Updated this year, talked to the developer and he said he will start working on a new update)

    I think Spline Terrain 2D is the best tool by far and has a lot of features!
     
    RemDust likes this.
  29. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    431
    It would be really useful to have different colliders depending on the surface angle (in my case I'm thinking Ground and Walls), probably as 2 children with their own colliders and layers ?

    That would help managing collisions, pathfinding, and all sort of raycast in a SpriteShape environment ! Right now raycasting is almost pointless because only one layer can be hit for every collision...

    I feel like the collider generation in the extras could benefit greatly from such a feature

    Please tell me what you think =)
     
    Last edited: Sep 6, 2021
  30. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,516
    Whenever I build addressable or game, I get bunch of warnings like :

    An exception was thrown from a function without the correct [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")] guard. Exceptions only work in the editor and so should be only thrown in a function protected by this guard
    at UnityEngine.U2D.SpriteShapeGenerator.GetCornerSpriteInfo(UnityEngine.U2D.SpriteShapeGenerator* this, UnityEngine.U2D.SpriteShapeGenerator.JobSpriteInfo* $___struct_ret, int index) (at C:\Subterrain\SubterrainMT\UnityProject\Library\PackageCache\com.unity.2d.spriteshape@6.0.1\Runtime\SpriteShapeGenerator.cs:322)
    at UnityEngine.U2D.SpriteShapeGenerator.TessellateCorners(UnityEngine.U2D.SpriteShapeGenerator* this) (at C:\Subterrain\SubterrainMT\UnityProject\Library\PackageCache\com.unity.2d.spriteshape@6.0.1\Runtime\SpriteShapeGenerator.cs:2152)
    at UnityEngine.U2D.SpriteShapeGenerator.Execute(UnityEngine.U2D.SpriteShapeGenerator* this) (at C:\Subterrain\SubterrainMT\UnityProject\Library\PackageCache\com.unity.2d.spriteshape@6.0.1\Runtime\SpriteShapeGenerator.cs:2507)
    at Unity.Jobs.IJobExtensions.JobStruct`1<UnityEngine.U2D.SpriteShapeGenerator>.Execute(ref UnityEngine.U2D.SpriteShapeGenerator data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) (at C:\buildslave\unity\build\Runtime\Jobs\Managed\IJob.cs:30)

    Using Unity 2021.1.23f SpriteShape 6.0.1
     
    midsummer likes this.
  31. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    632
    This is really strange as GetCornerSpriteInfo is only called with valid values from within Generator code (1 - 8 from the caller). Could you please submit a simple repro case ? Will take a look asap.
     
  32. midsummer

    midsummer

    Joined:
    Jan 12, 2017
    Posts:
    38
    I see the same console warning when I make a build of my project.

    I'm using Unity 2021.1.20f and SpriteShape 6.0.1. I think I first saw this happen after the 6.0.1. update? Burst is version 1.5.6.

    EDIT: I see 32 warnings in the console when I make a build. At first glance I thought they were all identical, but they are actually the same warning for a whole bunch of different methods in UnityEngine.U2D.SpriteShapeGenerator.
     
    Last edited: Oct 4, 2021
  33. midsummer

    midsummer

    Joined:
    Jan 12, 2017
    Posts:
    38
    Is the exception really being thrown or is that warning really just a complaint about an unguarded throw statement making its way into a build where it may or may not be thrown? I didn't see any [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")] thingies anywhere in the functions mentioned (or the entire SpriteShapeGenerator.cs file). I'm perhaps a bit out of my league here, not that familiar with Burst.

    EDIT: I just checked that there's 12 unique warnings and 12 throws in the script file.
     
    Last edited: Oct 4, 2021
  34. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,516
    I am also using Burst and maybe it has something to do with it.
     
  35. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    632
    @midsummer @castor76 Could you guys kindly submit a simple repro project please ? This will help us take a look at this issue asap.
     
  36. midsummer

    midsummer

    Joined:
    Jan 12, 2017
    Posts:
    38
    @Venkify this is probably the easiest way to see the issue? I'm using editor version 2021.1.20f1. macOS Big Sur 11.6.

    1. Make a new project using the URP template.
    2. Import SpriteShape package 6.0.2 (or 6.0.1, maybe older)
    3. Build the app (Mac Intel, you will get no warnings).
    4. Import Burst 1.5.6
    5. Build the app. See warnings in console.
     
  37. midsummer

    midsummer

    Joined:
    Jan 12, 2017
    Posts:
    38
    @Venkify Here's another little bug that I encountered recently by accident. I've reported it using the bug reporter, but here it is just in case. This one's simple, but no-one should try this with an asset that's in any way important because this breaks stuff.

    1. Create a new SpriteShapeProfile and select it.
    2. Right-click any of the Sprite fields under the Corners heading (as long as it's not the very first one).
    3. Select Delete array element. See the errors in the console. The asset is now corrupted and the deleted array element can't be fixed even by switching the inspector to debug mode.
     
  38. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    632
    Thanks for the Update. The console warnings have been fixed in the latest version 8.0.0 (Will be backported to older versions soon). You can safely ignore those warnings though.
     
    midsummer and castor76 like this.
  39. bconstantin

    bconstantin

    Joined:
    Feb 4, 2019
    Posts:
    15
    Hello,

    Can we have access to the generated mesh ? I wanted to edit it in code, but can't find a way to.
     
  40. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    632
    Please take a look at SpriteShapeGeometryCache for one such sample. This is where geometry data of SpriteShape is stored if CacheGeometry option is enabled in Inspector.
    Runtime\SpriteShapeGeometryCache.cs
     
    bconstantin likes this.
  41. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    632
    Thanks for reporting. The issue has been fixed and will be available in the next version. Will post an updated once its publicly available. Thanks.
     
    midsummer likes this.
  42. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    I released a mobile game using inverted sprite shape (hole punched into sprite shape)

    If anyone wants to know how to make something like this, I can make a tutorial if there is enough interest. I use it to contain my gameplay space here: https://bugtilt.com

    levelgeneration.gif Screen Shot 2021-10-29 at 20.30.56.png
     
    wedgiebee, NotaNaN and Venkify like this.
  43. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,516
    Hi. I am not sure if this is the right place to post it about, but I have been reporting and raising issue with SpriteShape renderer not writing correct normal value into the normal buffer of 2drenderer.

    I have reported it as a bug, but it is sent as "usability" issue by QA team. And been ignored for long time now.

    I am not sure if incorrect rendering of normal value to the buffer should be considered as usability issue. Because as far as I understand, rendering is something that should be correct. And if it is wrong it should be flagged as a critical issue?

    When sprite shape bends sprite, it needs to render its normals into the buffer using its tangent value considered with it so the normals are written in a correct way. Right now, sprite shape dose not do this and lighting is completely wrong on spriteshape with normal map on it for 2drenderer.

    Can this be acknowledged and fix be considered please?

    I suspect that if sprite shape has this issue, any mesh bending or modifying rendering for 2drenderer would have the same issue present, such as 2d bone binding animation.
     
    Last edited: Nov 12, 2021
    NotaNaN likes this.
  44. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,516
    I get : Invalid memory pointer was detected in ThreadsafeLinearAllocator::Deallocate!

    whenever I call something like :

    jobHandle = spriteShapeController.BakeMesh();
    jobHandle.Complete();

    Or it even happens if I just spawn a prefab with spriteshapecontroller with it.

    Unity 2021.2.7f1
    Using spriteshape 7.0.3

    I am pretty sure this also has got to do with using Burst...

    Strangely this only happens in window build, not in the editor.

    I tried to make simple repro case, but my repro case did work. Perhaps because I am not doing anything else in the repro case. So maybe using burst with my other codes along the spriteshapecontroller is causing the issue.

    Code (CSharp):
    1. Invalid memory pointer was detected in ThreadsafeLinearAllocator::Deallocate!
    2. UnityEngine.StackTraceUtility:ExtractStackTrace ()
    3. Unity.Collections.NativeArray`1<UnityEngine.U2D.SpriteShapeGenerator/JobShapeVertex>:Dispose ()
    4. UnityEngine.U2D.SpriteShapeGenerator:SafeDispose<UnityEngine.U2D.SpriteShapeGenerator/JobShapeVertex> (Unity.Collections.NativeArray`1<UnityEngine.U2D.SpriteShapeGenerator/JobShapeVertex>) (at C:/Subterrain/SubterrainMT/UnityProject/Library/PackageCache/com.unity.2d.spriteshape@7.0.3/Runtime/SpriteShapeGenerator.cs:399)
    5. UnityEngine.U2D.SpriteShapeGenerator:Cleanup () (at C:/Subterrain/SubterrainMT/UnityProject/Library/PackageCache/com.unity.2d.spriteshape@7.0.3/Runtime/SpriteShapeGenerator.cs:2595)
    6. UnityEngine.U2D.SpriteShapeGenerator:TransferSprites (Unity.Collections.NativeArray`1<UnityEngine.U2D.SpriteShapeGenerator/JobSpriteInfo>&,UnityEngine.Sprite[],int) (at C:/Subterrain/SubterrainMT/UnityProject/Library/PackageCache/com.unity.2d.spriteshape@7.0.3/Runtime/SpriteShapeGenerator.cs:641)
    7. UnityEngine.U2D.SpriteShapeGenerator:PrepareSprites (UnityEngine.Sprite[],UnityEngine.Sprite[]) (at C:/Subterrain/SubterrainMT/UnityProject/Library/PackageCache/com.unity.2d.spriteshape@7.0.3/Runtime/SpriteShapeGenerator.cs:655)
    8. UnityEngine.U2D.SpriteShapeGenerator:Prepare (UnityEngine.U2D.SpriteShapeController,UnityEngine.U2D.SpriteShapeParameters,int,Unity.Collections.NativeArray`1<UnityEngine.U2D.ShapeControlPoint>,Unity.Collections.NativeArray`1<UnityEngine.U2D.SplinePointMetaData>,UnityEngine.U2D.AngleRangeInfo[],UnityEngine.Sprite[],UnityEngine.Sprite[],bool) (at C:/Subterrain/SubterrainMT/UnityProject/Library/PackageCache/com.unity.2d.spriteshape@7.0.3/Runtime/SpriteShapeGenerator.cs:2546)
    9. UnityEngine.U2D.SpriteShapeController:ScheduleBake () (at C:/Subterrain/SubterrainMT/UnityProject/Library/PackageCache/com.unity.2d.spriteshape@7.0.3/Runtime/SpriteShapeController.cs:776)
    10. UnityEngine.U2D.SpriteShapeController:BakeMesh () (at C:/Subterrain/SubterrainMT/UnityProject/Library/PackageCache/com.unity.2d.spriteshape@7.0.3/Runtime/SpriteShapeController.cs:499)
    11. UnityEngine.U2D.SpriteShapeController:OnWillRenderObject () (at C:/Subterrain/SubterrainMT/UnityProject/Library/PackageCache/com.unity.2d.spriteshape@7.0.3/Runtime/SpriteShapeController.cs:464)
    12. UnityEngine.Rendering.ScriptableRenderContext:Internal_Cull (UnityEngine.Rendering.ScriptableCullingParameters&,UnityEngine.Rendering.ScriptableRenderContext,intptr)
    13. UnityEngine.Rendering.ScriptableRenderContext:Cull (UnityEngine.Rendering.ScriptableCullingParameters&)
    14. UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Rendering.Universal.CameraData,bool) (at C:/Subterrain/SubterrainMT/UnityProject/Library/PackageCache/com.unity.render-pipelines.universal@12.1.2/Runtime/UniversalRenderPipeline.cs:400)
    15. UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderCameraStack (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera) (at C:/Subterrain/SubterrainMT/UnityProject/Library/PackageCache/com.unity.render-pipelines.universal@12.1.2/Runtime/UniversalRenderPipeline.cs:562)
    16. UnityEngine.Rendering.Universal.UniversalRenderPipeline:Render (UnityEngine.Rendering.ScriptableRenderContext,System.Collections.Generic.List`1<UnityEngine.Camera>) (at C:/Subterrain/SubterrainMT/UnityProject/Library/PackageCache/com.unity.render-pipelines.universal@12.1.2/Runtime/UniversalRenderPipeline.cs:264)
    17. UnityEngine.Rendering.RenderPipeline:InternalRender (UnityEngine.Rendering.ScriptableRenderContext,System.Collections.Generic.List`1<UnityEngine.Camera>)
    18. UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,System.Collections.Generic.List`1<UnityEngine.Camera/RenderRequest>)
    -- Edit --
    Tried the exact same scene without SpriteShapeController, and it does not produce the errors... So it is definitely SpriteShapeController..

    -- Edit --
    I found the cause of the issue. The sprite that I was using was in the sprite atlas. I have created the bug report (1391968 )
     
    Last edited: Jan 1, 2022
  45. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    632
    Sorry for the delay in response. Will take a look at this asap and post an update.

    Will take a look. Based on your inputs, I understand that a static SpriteShape is fine but when animated it does not work as expected ? Perhaps a test/sample project will help us understand the issue better. Thanks.
     
  46. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,516

    Ok so two issues :

    1. Sprite Shape Controller with sprite being used is in the Sprite Atlas ( Invalid memory pointer was detected in ThreadsafeLinearAllocator::Deallocate! ) Error. Case : 1391968

    2. Sprite Shape Renderer does not work properly with 2DRenderer normal maps. It output wrong normal value into the Normal buffer for 2DRenderer, not respecting the tangent value. Happens no matter what, animated or not. Case : 1345015

    I have submitted both issue with bug report, and for Sprite Shape Renderer Normal bug, I did it like June 2021, but I assume that it is still not fixed. I even create a video illustrating the issue, but Unity QA decided that this issue was more of "Usability" issue. But if you think about it, when it comes to the rendering, it is either done correctly or it is not doing it correctly. There is no room for half way "Usability" issue. If it looks wrong, it looks wrong?
     
  47. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    632
    For 2D Renderers, default Normal is (0, 0, -1.0f) and default Tangent is (1, 0, 0, -1.0f). Any deform or custom shapes using sprites (SpriteShape/Skinned Sprites), hence only needs updating Tangents and Normal will remain the default. This is also what URP2D expects (Shaders shipping with URP 2D package also does not make use of Normals from Vertex Data).
    Perhaps if you provide a sample or an expected outcome image, it would be helpful.
     
  48. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,516
    After looking at the sprite shape controller again, I found option that I am sure it was not there before last time I checked, which is enable tangents. Is this something "recently" added? cause using it does make it work! If it was always there, perhaps I could not see it or missed it somehow.

    So , it is a good stuff that it is working now.. so I thought..

    This may not be just for the Sprite Shape Renderer or (could possibly to do with the shader) but if you scale your object say -1 for x axis, the normal seems to be flipped, and I can understand why it does it. However, for 2D project or for Sprite type renderer's it is probably much more desirable to make the lighting behave the same for flipped sprites using transform scale. It is very much common practice to use transform's scale value to flip the direction of say a character from left to right and so on, so it is much better to make the shader to treat the scaled object into account. I am not sure using flip option for the other sprite renderer would fix this issue, but for sprite shape, it does not even have that kinds of options. Even if "flip" option for the sprite renderer would work, if you have say 10s of sprite renderers making up say a character, then it is much better to be able to just scale the root object.

    The image below shows the problem of scaled sprite shape controller with -1 in X scale. You can see the thin line should lit brighter where light is nearer than the other side of the line. This does look fine if it was not scaled -1.

    I am not sure about the skinned sprite renderer but I am pretty sure it would have the same problem.

    upload_2022-1-4_23-14-44.png

    Having said above, come to think about it, I am not sure what the best solution would be. But my best bet is to have shader handle this by taking object's scale when calculating lighting? I said object scale while I was talking about this, but I think for shader, all it may need to do is to detect if the given pixel is facing other way and then use that to flip the "normal" or "tangent" before calculating the lighting.
     
  49. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    632
    SpriteShape does work with SpriteAtlas. But please ensure Tight-Packing and Allow-Rotation are disabled in SpriteAtlas as well as Sprite. This should fix the issue.
    However Deallocate should not fail with that error though. Will take a look in that and post an update here. Thanks again.
     
  50. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    632
    @castor76 Could you please let us know if disabling Tight-Packing and Rotation in SpriteAtlas fixed the issue ? Thanks.