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

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.

Related

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.

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

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.

How to make a game object display the texture of its material in Unity3d?

I have a material called "RockyMountain" to which I have assigned a specific texture through the inspector, (Main Maps > Albedo property). The shader is set to "Standard" and the rendering mode is set to "Opaque". The other properties have default values. In the preview panel under the properties, the material is displayed appropriately with the texture being applied and all.
The problem is: when I apply this material to any game object, the object does not display the texture of its material. It merely shows a solid color that seems to be a shade of a color in that same texture.
Does anyone have any idea what I'm doing wrong?
You have to UV unwrap your object first, basically tell the object what it looks like and how textures should be applied. I doesn't know this on its own!
Here's a tutorial to get you started: https://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/UV_Map_Basics

Unity2D tile mesh render is darker than source texture

I am making a 2D tile-based game in Unity.
I have a tile mesh implemented roughly along the lines of this wiki entry. Full source code is available at PasteBin. When I look at my graphic (image file) it is precisely the same color as I see in the scene view; however, when I start the game, the mesh is darkened. I notice that when I change the Ambient Light color, it does resolve the issue (sort of): it changes the brightness, but if I set it to pure white, then the colors are too bright (see here). Furthermore, when I have regular GameObjects (such as the brick you see in the second image) they are not affected by this Light setting. I don't understand why the mesh is. Is there a prescribed way to make it totally WYSIWYG? The tileset I am using is here.
Try changing the shader on the material of the renderer to Unlit/Texture or Transparent/Unlit - if you need transparency.

How to make a sprite more opaque in Unity 3D

I am making a 2D game in Unity 3D. I have a few sprites, but they are so transparent that I can barely see them when the game is running. How can I make them more opaque?
The textures used for the sprites could be semi-transparent, the SpriteRenderer component color alpha value could be set somewhere between transparent and opaque, or the Material could have semi-transparent aspects. Try checking all 3 of these possibilities.
I have just found out that it's easier to do it with GIMP. I open the file representing the spite with GIMP. I select the parts of the sprite from witch I want to remove the transparency using the fuzzy selector (Tools->Selection->Fuzzy), I click on each of them with the right mouse button and choose Level->Tranparency-> Remove alpha channel.
That's pretty much it.