Unlit shader issue with fog in Unity's Univeral Render Pipeline - unity3d

Edit
I figured out a tempoary fix for my initial question "how to disable this weird fog": Disable the fog in the lighting pannel (genius, right ?)
However, since I might need fog later, and it does not behave as I would expect, I still need to fix this issue.
Note: This only happens with exponential fog modes, not with linear.
I'm having issues with unity's universal render pipeline: A light grey fog, whose strength depends on the camera heading (see video)
(see how the plane geometry affects the fog)
The steps to reproduce are very simple (or just download the project here):
Create a universal render pipeline project
Delete the "example assets" from the scene
Create a floor with a quad (create quad, rotate, scale)
Create a new material
Shader: URP / unlit
Base map: black
That's it.
Rotate around, see how the "unlit" plane is actually affected by a fog whose strength depends on the heading of the camera
Rotating the quad has the same effect as rotating the camera.
Rotating the directionnal light has no effect (except on the skybox)
Removing the Directionnal light has no effect (except on the skybox)
Removing the Post processing volume makes the "fog" stronger in all directions so the camera heading effect is less noticeable but still there
This happens in game mode as well as in the editor
Getting close to the ground makes the fog lighter
the camera position has an impact as well (this is more visible when testing with a plane rather than a quad)
system info:
tested on unity versions: 2019.4.18f1, 2019.4.20f1 (LTS), 2020.2.1f1
Windows 10 Home 19042.804
Is it possible this is a bug in the URP/unlit shader ?
Thanks for any help!

Related

How to optimize lights in Unity

I'm building a virtual exhibition platform in unity. There are about 50 stalls and I used a directional light and 124 point lights light up the scene. I didn't use any real time lighting, only baked lighting is used. But at runtime frames get dropped. when I inactivate all pointlights it works smoothly. How can I optimize lights?
You can improve your performance by doing the following,
Add Light Probes, this can minimize the number of point lights in use.
Change Render Mode to Auto, this will reduce the load significantly in your case as there are a lot of point lights in use.
Apply a culling mask, make sure the light affects only the required object in the stall.
Use Fake Shadow instead of using Soft Shadow.
Switch to URP or HDRP.
Alternate way :
Build and bake each stall separately in Blender or Maya. Then add them to unity. This way you don't need to add that many point lights and bake.
124 Point Lights that is a LOT of lights, but you could use Deferred Rending path on your Camera (but if you need VR I'm not sure its supported).. You can set the Point Lights to be Baked, use Baked lighting and light probes instead. Set everything that won't move in your scene to be Static objects (very top right corner box). also remember to go into Rendering -> Lighting and Generate the Lighting and look at the options presented there.
Light probes video

URP Lit Shader on 2D sprite delayed reaction to directional light - Unity 2021.3.11f1

So I have a HD2D Setup in Unity, meaning a 3D world containing 2D sprites (billboards). I am using URP and created a Lit Shader with the following configuration:
This Shader is attached to a material and this material is attached to my sprite. My problem is, when I rotate the global directional light, the sprite with this shader attached has sort of a delay in adjusting its darkness to the global light (in the video, the environment is bright (morning) but the sprite is still very dark in color (see next picture) and vice versa). This behavior can be seen in the video I uplaoded here:
https://www.youtube.com/watch?v=uAm71ftfy2Y
Desired outcome:
The sprite gets darker as the sun fades (similar to the white Quad that can be seen in the video scene).
Does anyone have an idea which setting I need to tweak here? Thanks for any advice.
I figured it out. For some reason, URP Pipeline was not set under Edit-->ProjectSettings-->Graphics. Once set, I was able to set [X] Will be affected by shadows in shader graph. This solved the problem

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 - Light deactivated when facing opposite direction

I placed a light in my scene.
It is lighting the ground when i'm facing that light but when I turn the opposite direction, the light on the ground vanishes.
I think this might be some Unity's default behaviour.
Is there a way I can solve this issue?
Unity uses frustum culling to save performance, so it only draws items that are within the camera's viewing area. As a result of this, the particles behind you are not drawn, and any lights attached to them aren't either.
Scene-crucial lights aren't normally attached to particles, so it's normally not a concern if they're hidden along with their particles.
For conventional lights (not attached to particles), Unity should render the light as long as it affects objects within the camera frustum. If you use a conventional light, you should see better results.
Looks like you may have to disable occlusion culling. Unity3D Manual

How to achieve Terraria/Starbound 2d lighting?

I am making a 2d game in the perspective of Terraria/Starbound. I want the lighting to look similar to this:
Ive tried to get lighting like this by adding a material on all the sprites in my game and then giving them a sprite diffuse shader. Then I made a point light wherever I needed light. There where two problems with this though: 1) Where the light was most intense, it was draining the color of a sprite and made it lighter. 2) I noticed a big FPS drop (And I only had 1 point light!).
Is there any way of achieving lighting like this without having to write my own lighting engine? Ive search the asset store and Ive searched to see if unity has any way of handing 2D lighting from this angle but I have found nothing.
If I do have to write my own lighting engine, would that be to complex for someone who is relatively new to unity and has only had ~ 8 months experience?
Assume you are using tile map.
You need to have a field of view map, which can be achieved by reading this: http://www.redblobgames.com/articles/visibility/
Using such map, you know exactly the color tinting for each tile. Now, just blend the color to the SpriteRenderer of every tile on the map.
Somebody already created a line of sight plugin:
http://forum.unity3d.com/threads/light-of-sight-2d-dynamic-lighting-open-source.295968/
Here's my hacky solution on GitHub
There's 2 cameras.
Empty tiles on the tilemap are filled in with white blocks (only one camera renders this)
A gaussian blur is applied to the camera rendering the white blocks
Then, blend the two cameras, darkening everything not covered by the white blur.
You can adjust the "light" penetration by changing the white tile's sprite's Pixels Per Unit.