Is it possible to make dark "light" in unity? - unity3d

This quiestion may be dumb, but is there a way to create a pointlight in unity2d that darkens instead of producing light? I'm using URP by the way.

Click the Fog Colour box, set the ambient light to 29 on each of the RGB sliders. You can see the change in the scene, pick a colour that is dark but not pitch-black. Click the Ambient Light Colour box, set the ambient light to 51 on each of the RGB sliders. You can see the change in the scene.

Use Freeform Light, Check alpha blend on overlap, change the color to black.

This is possible in URP's 2D renderer, but you have to dedicate one of your four blend styles to just negative light:
Create or locate your URP Render Data Asset in your Assets directory.
Choose a Blend Style that you are sure is not being used in your project, rename it to something like "Negative Light".
Change its Blend Mode to "Custom".
Under "Custom Blend Factors", change "Multiplicative" from 1 to -1.
To make a 2D light source emit darkness, just change its blend style to the one you just created.

Related

Why component "Sample Texture 2D" in Unity Shaders distorts my sprite?

I have this texture and when I add it to the "Sample texture 2d" component, it is drawn where there is simply no sprite (transparent background). It looks like this. With the help of a shader, I did outline. And because of this, when I connect outline with texture, they blend where there is no texture. How do I solve this problem?
Shader Graph's "Sample Texture 2D" Node doesn't preview the alpha channel (transparency) correctly, although it does keep the alpha value (since it returns a vec4, rather than a vec3).
It's unclear what you want to do here. If you want to make the outline be a solid color, rather than using the texture, use a "Blend" node rather than the "Add" node you're currently using, with the "Overlay" mode selected.
Many image editors save the background colour even for full alpha values. If the texture isn't set to sprite Unity displays the hidden "artist smears" areas.
If the preview bugs you, you can reexport the image with GIMP and save with "Save background color" disabled. Unity will display alpha as black, which might be more pleasant to look at.

How to change the way colors blend with the scene in Shader Graph

I am trying to imitate my own 2D lights in URP using code and shader graph.
For now, everything looks as should, except that I want to have some of the light "bleed" onto the walls as shown in the image:
But on some darker objects it's not possible to determine what color they are:
Those boxes are brown btw.
Here is the shader:
I set the color to be HDR in hope that I can increase the intensity and therefore make it look more like a light source, but by doing that I lost color information.
Is there a way to change how does the light/shader blend with the scene? For example; make it multiplicative or additive?
Thank you in advance.

Unity 3D - Baked light is too dark

So I am baking Subtractive light in my VR build.
I have the models set to static, generated UV's for all of them and played a lot with the lighting settings.
The problem is that the sigle baked directional light looks too dark and "burnt" after baking.
How can I keep the brightness of the pre-baked scene after baking?
Posting images of before/after baking and settings below:
To increase the brightness of shadow you can change "Intensity" parameter in your directional light settings.
This "burnt" effect looks kinda pixelated so to fix this you could in your lightmapping settings increace lightmap resolution or lightmap size. If it didn't help, you could increase "scale in lightmap" in mesh renderer.
Another option is to create a copy of your directional light so that you have two directional lights in your scene. Then assign one light mode to 'Realtime' and adjust the intensity to get the scene brightness looking the way you want and assign the other light mode to 'Baked' and change the intensity to get the baked shadows looking better.
Baked light should always be the same (or better) brightness under direct lighting conditions.
There can be a multitude of issues in your scene, and why it's giving you this effect.
Please check the following in this order:
Does your models have proper UV maps
Does your models have enough scale in lightmap (small lightmaps can create faulty shadow effects)
Does your scene has enough reflection probes for indirect lighting (not enough light from the shadowed side can "shadow" the lit side.
Do you have ambient occlusion enabled? Maybe you need to fiddle with the values there.
From experience "Baked Indirect" gives better results than "Subtractive"
Are your settings in URP or HRDP or LRP are correct?
Is your "Sun" the right brightness?
What you should expect with "good settings"
Example lighting settings that the result above were achieved:
Change Direct Samples to 32, Indirect samples to 512, Environment size to 256, and change lightmap size from 512 to 1040. Make sure also that any emission materials are changed from Realtime to Baked along with of course having such objects set to static. That should take care of some of the lighting and illumination issues. Also double check that these materials are all checked for GPU instancing.
Since you are using Directional Light, Try adding a Bakery Skylight into your scene. That fixed the burnt shadows problem for me after baking. Shadows are more lighter now.

Scene in complete darkness in Unity

I want to create a scene in complete Darkeness, which will be iluminated just by the lightnings of a storm. But I am already failing in the first step, I am not able to make the scene completely in darkness, even if I remove all lights in the scene and set background of the camera as black, I still get this:
And Hier my Hierarchy where you can see there are no lights:
What am I missing?
You can try to set the ambient light to black, so it will be all in darkness. You can do this programatically with this line:
RenderSettings.ambientLight = Color.black;
And also, to switch off any light you may have in your scene (just in case)
Light[] ligths = FindObjectsOfType(typeof(Light)) as Light[];
foreach (Light ligth in ligths) {
ligth.enabled = false;
}
Take care also of the follwing three things, which may be adding some light into the scene.
Turn off or delete any light maps.
Ensure shaders are not using self-illuminating or particle shaders.
Ensure that "use scene lighting" is turned on in the scene view.
However I think in your case with the ambient light set to Black will be enough. Your scene seems quite simple.
To light your scene entirely from lights placed, you need to drop your Ambient Light settings. Ambient light is the light that is added to every object so that things do not appear entirely black - but there are many cases where you want them to.
Answer
Ambient Light settings can be found by going Window > Lighting > Settings.
Make sure that theEnvironment Lightingsource is set toColor`. Here you can also tweak the color using the RGB picker to have greater control over how the ambient light looks.
You may want to use a color that is slightly above black so that things can still be very faintly seen, without your lighting effects.
One thing to note, some materials may be set up to emit or use their own light settings - but these can usually be tweaked by modifying the material.
Another note, you can preview the lighting in the editor (or conversely - see what you are doing) with the lighting switch in the editor. This will toggle lighting effects on or off (including ambient light settings) for the Scene view.
In most cases the answers already given are correct.
But also attention to the Light Probes! ;)
Try disabling it on the object's Mesh Renderer.
Making things pitch black at night without artificial light involved several steps for me. I wanted a Sun that rose and set, so first I made a script to simply change my Directional Light's (gameobject Sun) x rotation over time.
Then I made a script to adjust my Sun's intensity, with the intensity starting at 0 when the sun rose and quickly rising to 1 at about 15 degrees, and contrariwise at about 165 degrees it goes from 1 back down to 0. So far so good....
Sun.intensity = intensity;
Next I made the script set the ambient light and reflection intensity to the same.
RenderSettings.ambientIntensity = intensity; // RenderSettings controls found in Lighting tab
RenderSettings.reflectionIntensity = intensity;
And just for good measure I made sure to set these:
RenderSettings.ambientEquatorColor = Color.white;
RenderSettings.ambientGroundColor = Color.white;
RenderSettings.ambientSkyColor = Color.white;
I noticed that when they were black, for example, even with intensities at 1.0 the ambient light was very, very low.
Finally, I had to use a custom shader to blend between a daytime skybox and a nighttime skybox. This because if you have the Skybox as the source for environment lighting (in your Lighting tab) then the ambient light will be affected by the color of your skybox. I.e., you want a bright daytime skybox and a dark nighttime skybox.
There you go. Now when the sun had set the terrain was completely black, only lit by scene lights like torches. I'm also using Ceto's water system, so I had to control the Ocean_TransparentQueue gameobject's UnderWater script to adjust the Absorption/Inscatter intensities as well, the same as above.

Keeping true color of 3d objects in Unity

For 2d game I need 3d objects with default colors. For example, this cube, all of whose faces are painted in different colors, but it looks dark without a light, and with a light brightness of the faces is changing. How can I keep the true color of the cube?
I might not understand well your question, but you can use Unlit/Color shader.
This shader doesn't compute lighting, so it keeps color no matter the light conditions.
Using Unlit colors can be good choice, however keep in mind that there's also ambient light property in the Lightening window.
So you can keep default material, get rid of all light objects in the scene, and adjust ambient value to get the effect you want.