VR Headset issue: objects displayed in one eye because of default shader. (in my case TextMeshPro shader) - unity3d

I have:
Unity
High Definition Render Pipeline (HDRP)
Single pass rendering (no ability to change)
VR Headset
Part of objects displayed only in one eye.
Investigation show that the reason of this -- non-compatible shaders for such environment. For particle system I have resolved such problem with own shader created using ShaderGraph (below is solution)
But My problem of this question is:
I have no idea how to write correct shader for TextMeshPro Text.
Can anybody help with this?
THIS FIX WORKS FOR PARTICLE SYSTEM one eye issue: Shadergraph shader (works well with transparency, Color over lifetime, etc)

Related

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

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!

Are masked sprites and Stencil Buffers in Unity only visible on one eye if deployed on HoloLens2?

Is it possible that Sprite Renderer in a HoloLens2 Unity Project, which are masked via a SpriteMask are only visible on one eye in the final HoloLens2 build (UWP via VisualStudio2019 deployed on HoloLens2 device).
I also experienced the same behaviour on elements which are masked with a StencilShader.
I am using a 24-bit depth buffer for my unity project if that helps, otherways the StencilShader wouldn´t work.
To display certain objects to one eye, for different rendering configurations, different ways need to be used.
With MultiPass, you should be able to set a camera to render to only one eye(Camera component -> Output-> Target Eye), so doing per eye stuff is super easy. With Stereo Instancing, you can draw in Shader but you will need to multiply the projection matrix of the current eye.

URP Shader Graph shaders time node doesn't work in certain situations

I have several shaders that use the Time node to animate certain UI elements for my mobile game.
In certain cases (which I am unable to reproduce), the shaders will be stuck on a specific time and not animate.
For example, a shine shader might be stuck mid-shine.
Some important things to note:
Time.timeScale is 1 - all my tweens using scaled delta time are working correctly
When this happens all shaders using the time node in the active scene will "freeze in time"
This only reproduces on actual Android devices (iOS untested)
All parameters affecting time in said shaders are positive, valid numbers
There are no errors or warnings
When I transition from my main menu scene to the game scene, time based shaders will work correctly - when I come back to the main scene, it will reproduce again (obviously it's something specifically there)
Running on Unity 2019.4.11f1 with URP & Shader Graph 7.5.1, but it did reproduce in older versions of Unity/URP as well
Sample shader - The preview actually looks exactly like the issue as it will appear in game when frozen:
For any lost souls who stumble upon this issue (although I doubt it's by design as it seems like a bug).
The problem is that time isn't updated in shaders in scenes without a camera.
The camera doesn't have to render anything; it just needs to exist.
My main menu is pure UI elements and had no camera; adding a camera to the scene fixed the issue.
It is important to note that this behavior only happens once you build to an Android device; not sure if it reproduces on other platforms.

Light Baking Issue

Before I have real-time lighting because of the performance issue, I decided to do light baking for my 3d game.
So I have mark 3d environment as static because it remains on screen always without movement.
Also changed direction light mode to Mixed because I have few moving game objects too.
But after the baking process gets completed, I got this kind of output:
In above, you can see in the above image what happened with my environment after baking and I have also included light settings if you need it.
You have to enable lightmap UVs in your 3d imported model file.
I got this reply from one Unity forum member so exact wording, I am posting here:

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;