Ugly water shader which is not influenced by the directional light - unity3d

I recently started working with unity and tried making my first real water shader with shader graph (URP).
In general it works fine, but I have some really ugly effects with the lighting.
First, when I set the smoothness of the water to about 1 (to make it shiny as water is), it is "split into two areas" (see the screenshot). One is nice and looks like water, the rest is grey. Why?
Second, when I turn the Global Directional Light to night time, the land is dark, the water isn't. Why?
Here you also can see this "grey water effect".
This is my shader graph
and these are my environment settings

Just found a part of the solution: The problem with the ugly reflection was that the water plane had a Y scale of 0. When I change it to something greater than 0, it works.
But that does not solve that it isn't affected by the environment light.

Related

Unity - how to provide diffuse lighting

I have a simple scene of the interior of a house (less roof). It does not in any way need to look realistic, just to be geometrically correct, therefore the walls and furnishings and fittings are simply constructed from primitive objects - cubes and cylinders etc.
The layout is fine, the problem is the lighting - very black shadows. The scene has the standard single directional light source.
What I need to do is provide overall diffuse lighting - equivalent to an overcast day.
I should point out that I am pretty much a novice on all this - lighting, shaders etc, though I have been reading a lot.
From what I read it appears that this is controlled by shaders, shaders being attached to materials, materials being applied to the objects. However, it doesn't seem to make much sense to me. Surely, a shader, if part of the object by virtue of being attached to the material, can only deal with how light might be reflected off the surface - but the light has to get there first.
Therefore, there must be a way of providing an overall diffuse light in the first place?
Or have I got this completely wrong? How does one get rid of the blackness on the non-illuminated side of an object? So far the only way I have found is to make the surface emit light, ie glow a bit, which surely must not be right.
Your general understanding of how this all works is correct. One way to look at it object request rendering, looks up the material, the material binds shader to a set of parameters. The shader then gets executed, once per light in the scene that affects it (this is simplyfying things but we'll get to that in a bit). This is why lights are expensive (in forward rendering that is), until optimizations start to kick in, this means rendering the scene n times.
So yes, you could just add a constatnt factor in the shader, to achieve the effect of 'ambient' or 'diffuse' lighting. But that shader, in order to support all the features like reflectivity etc, would have to be crazy complicated.
Fortunately, with unity we also get a middle layer called Standard Shader, which does pretty much all of the math underneath, and releases you from the necessity for writing shader code.
For a gentle, diffused look, you definitely want to look at baked Indirect Illumination features of Unity, maybe even lit everything with area lights only.
Its probably also a good idea to looki into light probe groups. They work with spherical harmonics, encoding only the low frequency components of the lighting data, effectively only using slow changing factors like general direction of the light.
Finaly look into reflection probes (and skyboxes while at it), theres few good free HDR probes available that will emit light into your scene (when baking lightmaps and baking lightprobes), enabling surprising realism, compared to default unity skybox.
If you don't want harsh directional light, just disable it (although it's often useful to know what is your strongest light source in your sene - even if its a skybox with some clouds, i would probably keep a scene light just to know faster if anything goes wrong

Unity baked lighting blotchy and cubic

I've set every object in my scene to 'static' and the bake runs automatically, but the result is unusable: blotchy, blurred cubic lighting...
Here are my lighting settings:
What am I doing wrong? I've tried changing the atlas size, the 'scale in lightmap' of the house object and various other settings, but can't seem to make the bake behave.
Any ideas much appreciated.
You might want to check the see how far from 0 the mesh is. I Had mine about -6000(y) and it had extremely blotchy/spotty lightmap results. I moved it much closer to 0(like -10y), re-baked and everything was fixed.
It looks like UV overlap. For issues like this where some sections are bright white, red, or green (where they really shouldn't be), try
increasing the lightmap padding
toggling stitch seems on the render (mesh renderer or whatever it is for the object with white patches)
Play around with the other lighting settings
rebuild the UVs (A lot of forums will end with this, it can be quite manual. Luckily 1- 3 has always worked for me so far)

Unity - Turning off ambient light is not making my scene completely black

I have been looking around for a way to make my scene 100% dark, except for the single light source, and all of my sources mention turning off ambient lighting which I have done.
As you can see, light still permeates my scene.
It appears that only the X axis has been darkened where the Y and Z are still lit by a light source that I don't have. The only light source is the single orange source at the center of my scene. This is extremely frustrating because all help sites say to turn off ambient lighting which I have done, I have not found any other solutions.
I had a directional light that I had forgotten about, rookie mistake

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;

Lighting an instantiated prefab, baked versus realtime

I'm generating a dungeon out of prefabs which means I design a room, save it in the resource folder and instantiate it at a random position with a random rotation while the game is running.
The problem I have is the lighting.
Because of the above mentioned generation process it has to be dynamic but it doesn't seem to work. Below you can see the comparison between a baked and realtime rendered room:
Baked (I also don't know where these strange lighting borders (on the walls), which are looking like someone painted the light with watercolors are coming from):
Realtime:
As you can see, the realtime room doesn't seem to reflect light in any way.
These are my lighting settings:
And this is my 'sun':
What am I doing wrong?
Your lighting settings have Ambient Light set to 0- with realtime lighting, this means nothing that can directly see the source of a light will be lit at all. The screenshot with baked lighting looks different because it has a baked lightmap.
If you're trying to get the real-time lighting to look exactly like the baked, soyy, but Unity refuses to bake lightmaps at runtime. The closest you can probably get is by setting your Ambient Light to a color and its intensity above zero. Playing around with Light Probes probably won't be much good, since you need to light an entire room in a vacuum.
An alternate solution, depending on how well you know Unity, would be to Frankenstein together different scenes, which is mentioned briefly in Unity's Intro to Global Illumination, though I can't find it anywhere else.
Relevant links:
Baked Lightmaps: http://docs.unity3d.com/Manual/GIIntro.html
Light Probes: http://docs.unity3d.com/Manual/LightProbes.html
Ambient Light: http://docs.unity3d.com/Manual/GlobalIllumination.html