- Home /
2D sprites with diffuse and lighting causes lines between tiles
Hi, when I switch from the standard default material for sprites to the diffuse material, I get lines appearing between my tiles, especially when moving the camera
This only happens when a light source is affecting them
Does anyone know a fix for this?
Cheers!
Answer by Andreas Loew · Mar 14, 2016 at 04:12 PM
Hi,
this is a problem with rounding / interpolation in OpenGL. It can happen in several places - so you might try one or more of the following:
Try to move the camera only in full pixels. Avoid sub pixel coordinates. This might be hard to achieve in Unity...
Add a border of 1 or 2 pixels around your sprites that repeats the outer pixels. This avoids dragging in transparent pixels from outside the sprite.
Best Andreas
Thanks Andreas, it actually turned out to be my alignment was out by a pixel, I just couldnt see it. Once they are perfectly aligned the problem (or lack of a problem) went away :)
Answer by M_1t · Jul 11, 2019 at 06:42 PM
Sometimes you just have to build in order for the lines to go away. It may seem obvious but I spent hours trying to fix it before I tried building it and then testing.
Answer by I_Am_Err00r · Jul 11, 2019 at 07:49 PM
I know exactly what you are talking about, and my experience with 3D lights on sprites is no thank you.
I wouldn't know how to code a 2D lighting system, Unity is supposed to have one coming out with 2019, so you might want to wait if you can, but this tool has saved me so much time trying to tweak with 3D lights and sprites and works exactly like I was hoping it would, you might want to consider purchasing it:
https://assetstore.unity.com/packages/tools/particles-effects/smart-lighting-2d-112535
I highly recommend that over any other 2D lighting solution, and the author of it is a really cool guy who responds to questions within seconds on his forum.