No "Pixel Snap" option in 'Sprite-Lit-Default' material causing some sprites to tear - unity3d

The Problem:
I have a pixel-art based project that uses tilemaps and etc. Previously with just the default material Sprites/Default, I have this "Pixel Snap" option:
However, ever since I upgraded to LWRP/URP; and used 2D Lights (my game has a day/night cycle); all of the sprites have to be upgraded to a new Sprite-Lit-Default material which allows my sprites to be affected by the 2D Lights. The only problem I noticed in this new material is that it hasn't got any "Pixel Snap" option:
And after I used this new material, I notice some of my sprites (specifically the ones on the Tilemaps) tear. It's not game breaking and it occurs sometimes, but it's really quite annoying (and let's face it, it looks bad for your game to have that bug).
I haven't noticed this tearing bug on my other sprites (player, trees, obstacles, etc) only particularly on the tilemaps.
What I've Done So Far:
My sprites are set to Point (no filter), and Compression is set to None. On my tile sprites, there are no transparent edges etc. Even if I use Unity's Pixel Perfect Camera, the problem is still there.
Duplicated my tilemaps and offset the other ones to -0.01 or -0.02 on its X axis (so just in case it would tear, the player would still see the same tilemap).
None of these things have fixed the problem so far.
Are there any ways to bypass/fix this issue?
Thanks a lot!

What Solved My Problem
I placed the tilemap sprites on a sprite atlas, set the filter to Point, set the compression to None, left everything else by default, and then clicked "Pack Preview".

Related

Why do my lights keep flickering in my unity 2d game?

I placed 9 Point Lights within my 2D game on unity, however they keep flickering and not showing when I run the game and in editor, I don't know what's happening, I've tried changing the z value but that doesn't work.
Here is a video as I am horrendous at explaining things.
Lighting Issues Video
I'm relatively new to unity.
Assuming few Scenarios like you are using latest updated Shaders.
There are few possibilities I think you could give it a try.
Solution 1:
This could be because of Z Buffer problem usually caused due to camera clipping values.
Try Adjusting, by increasing the near clipping plane on your camera or decreasing it.
Solution 2:
Check if the Lights placed are not overlapping, sometimes the lights overlapping also may cause flickering,

How can I use baked lighting on sprites? / How to light up a large area in 2D?

I'm having trouble figuring out how to light up large area(s) of sprites in Unity 2D. My previous knowledge on Unity's lighting is zero.
I first tried using a large amount of point lights and using the "Sprites/Diffuse" material, but about only five would actually render at a time, so I guess there's a limit on that.
Then I tried putting in an area light. That didn't do anything, so that's when I started doing research about baked lighting on sprites (and baked lighting in general). I found stuff like this but I couldn't get it to work either because it's outdated or because I don't know what I'm doing. Other answers I've come across seem to assume that the reader knows anything about lighting in Unity in the first place which, to be honest, I don't. Unity's documentation website had some information on it, but no tutorials that go into how to set up baked lighting.
I've tried a bunch of different combinations of materials (like using the "Standard" shader for the sprites instead of "Sprites/Diffuse", emission, ect.) and I enabled "Baked Global Illumination" in Lighting>Settings.
If baked lighting isn't possible on sprites (or isn't worth the trouble), what are the alternatives?
Edit: I made sure not to have the lights pointing the wrong direction, and I do realise that Unity2D is just like painting onto a piece of paper in Unity3D. I was able to get point lights to work, but only a few at a time. I don't need to do the entire screen at once, I need to do a large specific area at once.
some tips...
working with sprites your in 2d... when you add a light, switch to 3d mode, and rotate to make sure your light is pointed at your objects, and oriented so as not to be on the same plane, or level with them, as this will cast all the light behind them.
if your trying to light up everything on the screen(in camera) attach an area light to the camera at the cameras position, point it where the camera points, and then in the inspector on the right, you can change its variables. intensity, range, width, height etc.
Emissive Texture:
https://www.youtube.com/watch?v=oa6kW5HhRd4
For some reason, I never even thought about going into the asset store. I found this for free, and it looks like it will work: Light2D.

Unity3D: Why is particle lighting making directional shadows disappear?

UPDATE: As #BenHayward suspected, this is a bug. <link>
I have a very simple setup of cubes on a plane comprising a grid of quads. A directional light is shining down at the scene at an angle, producing a set of shadows from the cubes onto the quads.
Now I'm trying to produce an explosion effect with Unity's particle system, but when I add a point light to the particle system it causes all the directional-lighting shadows to disappear, whether they're in line of sight of the particle or not.
The shadows reappear when the particle is destroyed. Replicating the particle effect with pure C# doesn't cause any problems.
(Oh, and obviously I'm using the deferred rendering path.)
Any ideas? This is driving me off the wall.
[EDIT: I should have mentioned that the point light added to the particle system is set to cast shadows. The Unity standard particle pack has shadow-casting disabled by default. They too cause the problem when I turn the shadow-casting on.]
Based on the project that you linked to, it seems as though the particle system is causing the shadow cast from the directional light to flicker on and off quickly. I suspect this is a bug, since if it were intended behaviour, I wouldn't expect it to flicker in this manner.
In cases where this is not a bug, the problem can be caused by a couple of issues:
You can only have a certain number of dynamic (shadow casting) lights in your scene which are seen by the camera frustum. By default, this number is quite low (I think it's 4). You can increase this number by going to Edit > Project Settings > Quality. Set the Pixel Light count higher from its default value. You will need to increase this value to be greater than the total number of lights in your effect. Higher values will allow more lights to be rendered on the screen, but this reduces performance.
It depends on the shaders which you are using to receive the shadows. Some shaders will only render shadows for one directional light. The light which is used isn't necessarily too easy to determine. If you are using the standard Unity shader this shouldn't be a problem. But if you are using a mobile compatible surface shader or something you've written yourself then this could be the cause of the problem.
Also, for an explosion, I'd recommend using just one single point light (not lights attached to each particle), as this is all that is required. Any more lights would result in considerable performance impact on the GPU especially if there are more than one explosion in the scene at any one time.
I recreated the scene as you described, i can't recreate your issue.
i mostly followed this tutorial, and added a few cubes in a plane:
https://unity3d.com/learn/tutorials/topics/graphics/adding-lighting-particles
I will need a screenshot of your lights componnents, both the directional and the point light, the particles, and the cubes (mostly the material); I cannot comment because i dont have enough reputation yet, so i'll delete this once you add the screenshots;

Unity3D: Can I layer scenes or can I mask scene elements to prevent overlap?

I have a work-in-progress spaceship interior built with Unity (utilizing pre-built assets). It won't move much. The space around it will, similar to how I made an HTML/Three.js version of this concept (although linked example does move ship around space scene while scales are also animated).
With the three.js version, I was constantly fighting with "space" entering the ship; warp beams and planets colliding with the front info screen or passing through the chair (destroying the illusion of massive scale). I was able to resolve most issues, but it was a challenge when everything was in the same scene.
In Unity, is there a way to keep the ship scene separate from the surrounding space "scene", whether it is part of the same scene or in a separate one on another layer, or the same scene with masks that prevent overlap? I don't need a very literal answer, but any guidance that leads to a solution will be promptly accepted.
Yes, it's a very basic and useful aspect of Unity - the layers system.
As you guess you can find endless doco about it at Unity, cheers
Note too - Unity of course has superb occlusion culling built-in. Almost always this will "just work" for you.
Note that (if I read you right) you're doing a scene with a tremendous difference in scales (like "10 cm" objects AND "1000 km" objects at the same time). As you probably know you basically can't do this in a game engine, it's tricky to pull off.
Just BTW this is more a question for gamedev.com

Unexpected sprite tearing?

I making a 2d game and I am having some very random problems... My sprites are not displaying as they should be. Below is a screen shot of what I see when I run my game. This bug is present in the game window and the scene window, both when the game is running and not running. And the glitch is not because of the tiles being offset (The background is made up of tiles), if you look closely the player sprite is also glitched up. I have tried restarting unity and my computer, one of which has worked. I have been having this problem ever since i started using tilesets (using one PNG image and cropping out smaller sprites by setting the sprite mode to multiple, instad of using just one PNG image where there is only one sprite and the sprite mode is singular). How do I fix this? (BTW I am using Oryx's lo-fi fantasy and sci-fi sprites at www.oryxdesignlab.com)
This happend when your atlas is not sliced correctly. When you making 2D game there are several important things about sprites.
Set Filter Mode to Point
Set Fromat to 16 bit or TrueColor (in special cases)
Make sure that your atlas is sliced properly.
Edit:
Adjust "Max Size" - make sure is value represents number equal or bigger than spritesheet size
The best way in sliceing atlas in Sprite Editor is NOT to use automatic. I got glithes like that in my project too and those steps can eliminate them.
Have a look at your Sprite in the Sprite Editor. I think you can get to it by double clicking.
Your sprites will have sort of boxes around them to identify each individual sprite (if you set your texture to multiple). One of these boxes will not have sliced correctly, and will have overlapped into another sprite, hence why you're seeing what looks like the arm of another sprite in your picture :)