Some weird scene view glitch - unity3d

In unity when I get close to objects, they start getting cut off until I get to close and then they disappear (https://i.stack.imgur.com/zWEzY.png) (https://i.stack.imgur.com/lQsji.png).
I tried searching on YouTube, but nothing helped

What you're seeing is the result of the camera's Near Clip Plane.
In 3D rendering, cameras have a fixed depth buffer. That means they can only render what's included in that range of depths.
In your Camera behaviour's settings, you'll see options for adjusting the near and far clip planes, which define the boundaries for the depth buffer. To fix your problem, you need to make the near clip plane smaller.
While it may be tempting to just make this range huge so everything is included, floating point imprecision will make that cause a rendering glitch known as "z-fighting". So, you want to define your clip planes in a range that makes sense for your game, but as a general rule of thumb, the far clip plane should be no more than 1000x the near clip plane.

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,

Infinite plane background

How would i go about creating as a background for a 3d scene a plane with a texture that stretches into the horzon? I have tried a skybox but i think a skybox will also be needed "behind" the infinite plane.
It depends whether you need to have an actual geometry that will be seen from close up - if not, you can bake it into the skybox.
In some cases (i.e. when the user has stereoscopic display on their head) you will need to have actual geometry.
Its not exactly clear from your question if you want to create a 'floor' or a 'wall', but in both cases I would link it with player position somehow. A floor could follow players X an Z, while a 'wall' could be made a child to the camera, this way it would never leave the viewport.
Skybox would still be the cheapest by a significant margin, we can give more advice if you provide some additional information. i.e. what are you trying to achieve

How to get rid of "shadow teeth" in Unity?

I tried everything but nothing can affect this. The only thing is when I change shadow resolution to "low", it becomes more smooth (obviously), but still not the best. Those shadows also look better if angle of view is less acute. Quality settings are the best, light source is a spotlight. Material on those things uses standard shader. What do I do wrong?
Image is enlarged.
You...can't. :(
The problem is that the shadows being cast are essentially just a texture. And texture points (aka "pixels") are square. This shadow texture is then "cast" from the light source (think about the light as being a camera: every pixel that it can see that is an object, that becomes a "dark" pixel in the lightmap; its a bit more complicated than that, but not by much).
Your objects and light are definitely not square up from each other. And in fact, can never be as your cubes are rotated five to ten degrees from each other forming a curve. Which means that some edge, somewhere, is going to get jaggy. This also explains why changing the light's position and orientation to a different angle affects the result: those edges more closely (or less closely) align with where the lightmap pixels are.
You can try various settings, such as Stable Fit or higher quality shadows (this is really just "use a bigger texture" so those jaggies get smaller as the same volume is covered by more shadow-pixels) but fundamentally you're not going to get a better result.
Unless...
You use baked lighting. Open up the Lighting window (Window -> Lighting), set your lights as baked rather than forward/deferred (this means they will not be realtime and may not move or otherwise change) and then in the Lighting window, bake your lights.
This essentially creates a second texture that is wrapped around your objects and gives them shadows and the pixels line up differently and generally give smoother shadow edges when the object's faces align with the shadow-casting edge (such as your stacked cubes). The textures are also much larger than the runtime light textures because it doesn't have to be recomputed every frame (realtime lights are restricted so they don't consume gigabytes of video RAM).
Baking will take a while, let it do its thing.
Have you tried with Stable Fit (under Quality settings)?

Purpose of mipmaps for 2D sprites?

In current Unity,
For use in Unity.UI as conventional UI ..
for any "Sprite (2D and UI)", in fact it always defaults to having "Generate Mip Maps" turned ON. Every time you drop an image in, you have to turn that "off" and apply.
As noted in the comments, these days you can actually use world space UI canvasses, and indeed advanced users may indeed have (say) "buttons that float over the head of Zelda and they are in the far distance". However if you're a everyday Unity user adding a button, just turn it off :)
In Unity, "sprites" can still be positioned in 3D space. For example, on a world space canvas. Furthermore, mipmaps are used when the sprite is scaled. This is because the mipmap sampling is determined by the texel size rather than the distance.
If a sprite is flat and perfectly scaled then there is no reason to use mipmaps. This would likely apply to your icon example.
I suspect that it is enabled by default for 2D games where sprites will often not be perfectly scaled. To clarify, a sprite does not need to be on a canvas. Sprites can exist as their own GameObject with a Sprite Renderer (not on a canvas.) When this is the case, scaling the camera view will change the sprite's size on the screen resulting in mipmapping due to the texel size changing. This results in making the sprite always perfectly scaled challenging without a canvas.

How to create a non-perpendicular near clipping plane in Unity?

I have a need for setting up clipping planes that aren't perpendicular to the camera. Doing that for the far plane was easy: I just added a shader that clears the background.
I just can't figure out how to do the same for the near clipping plane. I've tried to think of solutions dealing with multiple shaders and planes, a special cutting shader, having multiple cameras for this or somehow storing the view as a texture, but those ideas are mostly imperfect even if they were implementable. What I basically need is a shader that would say "don't render anything that's in front of me". Is that possible? Can I eg. make a shader to make the passed pixels "final"?