0
\$\begingroup\$

I'm making a project where every tile is a sprite renderer, this would work fine in the old unity system (from the fact that it used it until recently), but upgrading to the LWRP broke the sorting of the sprite renderers. Previously, I didn't have to change the order at all, but now they phase in and out of each other based on the position of the camera, like the picture shown below. They all use LWRP/2d/Sprite-Lit-Default, as any other of the LWRP materials do not use the texture from the sprite renderer and instead make it all black.

Image

I do not want to use sorting layers because I have meshes sprinkled in, and what i have seen there is no way to control if the mesh is on anything but order 0, besides some hacky way. Even using a box mesh it gets cut off when the floor is closer to the camera.

Image

Here is what it looks like far away, the floor should be there the entire time and not have the darkness of the walls seeping down into them.

Image

I don't think I can use mesh renderers either, as I want a way to control the texture from each individual object, and share a material through all of them. I think if I used a mesh renderer I would have to use a material for each different tile, and I would not be able to tile them like I am doing now.

\$\endgroup\$
  • \$\begingroup\$ "I think if I used a mesh renderer I would have to use a material for each different tile, and I would not be able to tile them like I am doing now." You would be incorrect in thinking such a thing. \$\endgroup\$ – DMGregory Jan 8 at 0:17
  • \$\begingroup\$ Great! Could you be a bit more helpful and tell me how it would work? When I have a mesh renderer i’m only able to input a material, not a sprite per gameobject. Thank you. \$\endgroup\$ – baiomu Jan 8 at 1:47
  • \$\begingroup\$ That's a different question than the one you've posted above. You can edit your question or ask it as a new post, and a user here can post an answer in response. \$\endgroup\$ – DMGregory Jan 8 at 1:49
1
\$\begingroup\$

I solved this problem by not using the LWRP Lit sprite shader. I created my own in Shader Graph that samples _MainTex and that fixes the sorting problem. The main cause was that the LWRP sprite shader made them automatically two-sided, while the old system they were one sided and that was causing my problem.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.