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

Question Trying to make sprites work in 3D world (URP).

Discussion in 'Universal Render Pipeline' started by Josiah_Ironclad, Sep 13, 2022.

  1. Josiah_Ironclad

    Josiah_Ironclad

    Joined:
    Sep 24, 2019
    Posts:
    156
    I recently decided to change my game from 2D to 3D, but keeping most things as 2D sprites. I already changed the 2D renderer to the 3D one. I'm using Unity 2021.3.7f1, and URP 12.1.7.

    There is absolutely nothing I can think of or tried that has worked. Sprites sort based on Y position, and there is no way of changing that in the 3D renderer like in the 2D one where you could set a custom sort axis. It becomes even more chaotic when I introduce transparent water, as things very much on land will appear under the water if they overlap with it on the camera.

    I tried converting them to planes with textured materials, but either the mesh is huge and incorrectly oriented, or the sprite appears stretched. Nothing I find online helps, as I've seen people using regular sprite renderers that work beautifully, as well as plane mesh renderers.

    I tried playing around with shaders, and the default "Unlit/Transparent Cutout" seems to work best, works with transparent water, and z sorting, the only problem is it turns all transparent pixels fully black, and all I can do is slide the alpha cutoff, which vaguely removes fully transparent areas, but never really gives semi-transparent pixels.

    Nothing I tried making with Shadergraph works either.
     
    Last edited: Sep 13, 2022
  2. Predulus

    Predulus

    Joined:
    Feb 5, 2018
    Posts:
    90
    Hi, did you find anything? I'm currently searching for a better solution than what I've been using.
     
  3. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    960
    You're likely using a shader that doesn't write to the depth buffer (ZWrite On). Generally speaking using alpha transparency and writing to the depth buffer can cause a lot of issues if you're not careful but for simple screen-aligned sprites, thankfully, things are a lot simpler and you can generally just expect it to work since they will be rendered back-to-front from the camera.
     
  4. Predulus

    Predulus

    Joined:
    Feb 5, 2018
    Posts:
    90
    Thanks.

    I found this works quite well.