Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Other [4.0.1] NSprites - sprite rendering package

Discussion in 'Entity Component System' started by Tony_Max, Nov 29, 2022.

  1. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    378
    Only devices support StructuredBuffer in vertex shader can run NSprites.
     
    Tony_Max likes this.
  2. sauvik4redapple

    sauvik4redapple

    Joined:
    Oct 10, 2022
    Posts:
    3
    Is there any hack to use it in every device ?
     
  3. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    378
    The device's GPU has to support it. I don't know any workaround.
     
    Tony_Max likes this.
  4. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    354
    Hello!
    * can you please provide screenshot of your problem?
    * flickering may appear while using incompatible graphics API. Please check compatibility section on github readme and wiki (more detailed). Also old version of Android like 9 can't work with compute buffers which used in NSprites.
     
  5. sauvik4redapple

    sauvik4redapple

    Joined:
    Oct 10, 2022
    Posts:
    3
    What about red rectangular

    ok please check attach file
    upload_2024-3-13_18-26-11.png
     
  6. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    354
    Cute character!
    if you talking about this rectangular border around character then you can check your animation texture. Sometimes some 2D editors (like asprite) adds color filling between frames. Anyway it seems like sprite renders extra pixels around it's original rect.
    if suggest above isn't true, then it seems like shader works wrong, but I really have no idea what can it be, because what depends on texture is just sampling with recalculation UVs to account atlasing + tiling&offset of sprite and nothing more.
     
  7. Nilokilo

    Nilokilo

    Joined:
    Oct 21, 2020
    Posts:
    17
    I wanted to check out NSprite in my prototype with Entities 1.2 but it seems it does not work with this version.
     
  8. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    354
    There is an old problem with adding
    ChunkComponent
    during baking. I've fixed it somehow using
    ComponentType.ChunkComponent
    but it seems in entities 1.2 it is broken again. Will try to search workaround.

    UPD: also adding chunk component in baking system doesn't help. It seems that baking process strip out chunk components. Maybe some unity dev will tell us some day that CHUNK COMPONENT ISN'T SOMETHING YOU SHOULD REALLY USE! So I see no way except add runtime system which will fix such entities.

    UPD: it also has additional problems it seems, because I see that rendering system works wrong and try to sync buffer multiple time per frame. So I wouldn't recommend to use NSprites with unity 6 beta for now
     
    Last edited: Apr 15, 2024
  9. Nilokilo

    Nilokilo

    Joined:
    Oct 21, 2020
    Posts:
    17
    Don't worry, i can check it out later at any point in time when it's compatible. I'm using Unity 2022 LTS though. You can make an update post here in case you find a solution.
     
    Tony_Max likes this.
  10. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,294
    Chunk components get lost in the void during incremental baking. The only safe places to add them are in EntitySceneOptimizations and at runtime. You'll need both.
     
  11. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    354
    Glad to see you here! Thank you for info. It seems that
    EntitySceneOptimizations
    world filter works and same system see no entities without chunk component updating at default world!.

    Please try NSprites v4.0.1
     
    Nilokilo likes this.
  12. uncoilking

    uncoilking

    Joined:
    Sep 17, 2020
    Posts:
    8
    Update to NSprites v4.0.1 and NSprites-Foundation v8.0.0 !
    All sprites are not displayed, prompting "Shader error in 'Universal Render Pipeline/2D/SimpleSpriteShader': undeclared identifier 'Remap' at line 140 (on d3d11)"
     
    Tony_Max likes this.
  13. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    354
    Thank you for mentioning. The problem is URP doesn't expose
    Remap
    function in it's
    Common.hlsl
    so in older versions of unity (below 2023) you use older URP.
    I've fixed it in 8.0.1 with just local
    RemapInternal
    func.
     
  14. uncoilking

    uncoilking

    Joined:
    Sep 17, 2020
    Posts:
    8
    On some old devices, the screen is not working properly. It is recommended to be compatible with some old devices.
     

    Attached Files:

  15. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    354
    Please, check compatibility with graphics API. In short you can use only EachUpdate mode with all your properties and use partially supported graphics API. Also some devices like mobiles with android 9 have small number of supported ComputeBuffers which makes impossible to use with current NSprites Implementation. However I have plans to adapt NSprites for use BRG which should bring wider support for various graphics API and devices.
     
    Laicasaane likes this.
  16. uncoilking

    uncoilking

    Joined:
    Sep 17, 2020
    Posts:
    8
    Looking forward to a widely compatible version
     
    Tony_Max likes this.