Global Tiling in HDRP Combined with Parallax Occlusion Makes Messed up UVS - unity3d

I'm trying to make a custom shader with Shader Graph on HDRP. The intention is to automatically tile textures based on global position so I don't have to worry about remaking materials when I resize things etc. (I'm sure you can imagine the usefuleness of this). But when I do that, combined with the Parallax Occlusion Mapping node (built into HDRP) for height mapping the UVs get all messed up, and the height mapping doesn't even seem to work for some reason.
I thought that if I fed any source UVs into the Parallax Occlusion Mapping node that it would work just fine, but for some reason it doesn't in this case (it's especially obvious when zoomed far in that something is wrong with the UVs). I'm fairly new to shader graph so I'm not exactly sure how to resolve this issue. Let me know if you need anything else from me.
Here is the relevant shader graph nodes (not pictured is pretty much just mapping textures directly into the output node, if you think it might be relevant I can post those too)
Here is the zoomed out version of the scene (with some sample textures) without my global tiling activated (top) and with (bottom). As you can see the tiling works but the height disappears:
And it gets worse if you zoom in (no tiling top, with tiling bottom):

You are missing to connect PixelDepthOffset to the corresponding entry in the Master node. It looks like it's shifting correctly the UV, but the rendering pipeline is not aware it should also change the depth pass accordingly.
You can enable the depth offset in the options of your master node, as follows:

Related

World space UI gets blured with Depth Of Field effect when intracting with skybox

Im making a game in which players have world spaced UI tags on top of them. but when I use Depth Of Field effect and there is no object behind that UI tag (SKYBOX is being rendered behind) the UI gets highly blured for no reason :
Example
I tried changing the World Camera on the name tag's canvas but didn't worked.
I didn't found any solutions for this problems since people don't usually use Depth Of Field.
I'm using Unity Universual Renderer Pipeline and its Volume.cs
This is reasonable, common transparent shaders don't write the depth buffer, so the DOF effect shader cannot know the distance from these HUDs.
To solve this problem, enable write depth feature for these object. Check this example: https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal#15.0/manual/renderer-features/how-to-custom-effect-render-objects.html

Accessing a secondary texture normal map in shader graph?

I'm using Unity 2020.1.3f1's URP, with the new 2D renderer system.
As of right now, I have objects that change between the built in "Sprite-Lit-Default" material, and a material with the custom built pixel outline shader detailed here: https://danielilett.com/2020-04-27-tut5-6-urp-2d-outlines/
This worked well and good, but I recently added lights, and a normal map to my sprites as a secondary texture in the import settings. The default lit texture has no problems displaying the normal map, but when I attempted to modify my shader graph to include the normal map, it doesn't import like the sprite texture does when _MainTex is set as the reference.
I've tried _NormalMap (which is the name of the secondary texture in the importer!) as well as _NormalTex, but it always ends up not importing the normal map. I even attempted changing _MainTex to a Texture2D, but given that kept sparking an error, I didn't think it was the right way to go about it. (This one to be specific.)
Error assigning 2D texture to 2DArray texture property '_MainTex': Dimensions must match
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
Am I missing something here? All the tutorials I can find online only show people dragging the normal map in through the inspector, but this material is going to be used by many different sprites, so that seems...counterintuitive.
On top of this, the default material/shader has no issues with this, so I feel like I'm either missing something, or I'm going to end up having to code my sprites to change material through code instead of the animator, just for this small, annoying quirk..
Blackboard Properties, and nodes. This just goes into the normals input.
Inspector panel showing the missing normal map slot.
And the Secondary Textures in case I somehow misnamed it, why not?
(EDIT)
So, an update on this, for anyone else who runs into this same issue.
I managed to find a section of the shadergraph documentation that seems to be the only part talking about this:
It is required to name the reference for MainTex as _MainTex to render Sprites. It is also recommended to name the references for Mask as _MaskTex and Normal as _NormalMap to match the Shader inputs used in this package.
So from what I gather from that, _MainTex is the only one that's automatic in ShaderGraph.
After a full day of looking up tutorials, I've noticed that every single one of them simply set the normal map and extra textures as the default textures so they'll show up without being assigned manually.
I think this is possible with hand-written shaders, but I've decided to just go with a simple unlit shadergraph on a hand-drawn sprite outline, displayed on a separate gameobject parented to the main object.
I'm not posting this as an answer in case someone else finds a solution to it in the future, and since this isn't...really a solution in my eyes.
I don't know if you have figured this out yet but I'll try to answer since I had the same problem. Create a new Texture2D node, convert it to a property, and have the reference as _NormalMap, connect that to the sample texture 2D node as normal, and plug that into the sprite lit master. Now go into the sprite editor, assign the normal maps as a secondary texture, and make sure the name is the same as in your shader, _NormalMap (or something else, as long as it's the same). This currently has worked for me, shader graph detects the normal map texture by reference automatically. Attached below are some images to help and the finished result on the character sprite, which uses a custom shader I picked up from a tutorial and added the normal map to.
Shader Graph Sprite EditorSprite Editor 2 Normal Map result

How can I use baked lighting on sprites? / How to light up a large area in 2D?

I'm having trouble figuring out how to light up large area(s) of sprites in Unity 2D. My previous knowledge on Unity's lighting is zero.
I first tried using a large amount of point lights and using the "Sprites/Diffuse" material, but about only five would actually render at a time, so I guess there's a limit on that.
Then I tried putting in an area light. That didn't do anything, so that's when I started doing research about baked lighting on sprites (and baked lighting in general). I found stuff like this but I couldn't get it to work either because it's outdated or because I don't know what I'm doing. Other answers I've come across seem to assume that the reader knows anything about lighting in Unity in the first place which, to be honest, I don't. Unity's documentation website had some information on it, but no tutorials that go into how to set up baked lighting.
I've tried a bunch of different combinations of materials (like using the "Standard" shader for the sprites instead of "Sprites/Diffuse", emission, ect.) and I enabled "Baked Global Illumination" in Lighting>Settings.
If baked lighting isn't possible on sprites (or isn't worth the trouble), what are the alternatives?
Edit: I made sure not to have the lights pointing the wrong direction, and I do realise that Unity2D is just like painting onto a piece of paper in Unity3D. I was able to get point lights to work, but only a few at a time. I don't need to do the entire screen at once, I need to do a large specific area at once.
some tips...
working with sprites your in 2d... when you add a light, switch to 3d mode, and rotate to make sure your light is pointed at your objects, and oriented so as not to be on the same plane, or level with them, as this will cast all the light behind them.
if your trying to light up everything on the screen(in camera) attach an area light to the camera at the cameras position, point it where the camera points, and then in the inspector on the right, you can change its variables. intensity, range, width, height etc.
Emissive Texture:
https://www.youtube.com/watch?v=oa6kW5HhRd4
For some reason, I never even thought about going into the asset store. I found this for free, and it looks like it will work: Light2D.

Texture doesn't look the same

I am new to Unity and having problems with the textures. Whenever I import a texture and apply it to the terrain it doesn't look the same, sometimes it's for example way too dark and sometimes it's way too shiny. Here is an example:
I have been googling for a while without finding much about it, does someone know what is causing this and how I can fix it?
The reason for this, I expect, is because you are just dropping a texture image onto an object without changing anything. By default, this will create a new material asset, which is what is actually added to the object.
Look up Materials if you don't already understand how they work. The default settings are the Metallic slider at 0 and the Shininess slider at 0.5. Obviously these settings need to be changed depending on the texture, as not every texture is going be a non-metallic, kind of shiny substance.
It is also in these settings that you can add things like Normal Maps, Bump Maps, etc, to make them look more realistic.
Reasons for it being too dark might simply be that the your lighting isn't reaching that particular surface. In order to have a global light source, add a Directional Light to your scene.

Applying textures to a plane game object results in spreading

As visible in the attached image, when I apply a grass or ground texture to a plane, it all spreads around and looks like it is being stretched to fill the whole floor...
I cannot seem to find any settings that would address this. I have already triedx setting the wrap mode to repeat, according to this manual page...
Could someone please help me understand why this is caused and how I can fix it?
In the shader options you can change tiling on the X and Y direction. Greater tiling means more repeats of the texture on the plane. Tiling is defaulted to 1 when dragging a texture on which explains the stretched out look you got. For a fairly large plane try 100 by 100 or whatever fits.
To open the shader settings for the material you are using, select Forest Floor inside the inspector panel.
There is a tool on the asset store, the "Auto Texture Tiling Tool", which automates the process and has a ton of features for applying and tiling textures. It is way more useful than the Tile settings on materials. Since it is independent from shaders and materials, you can use the same materials with different tiling settings. Check it out here: https://assetstore.unity.com/packages/tools/utilities/auto-texture-tiling-tool-41613