'Why Unity shader is pink in editor game mode, but is correct in editor scene mode?

I am using Universal Render Pipeline, I built a shader which apparently works good.

here is the image showing the result, please note that I am in the scene tab

here is the image showing the result in the game tab

I started getting this problem when I set _CameraOpaqueTexture for the shader. I enabled opaque textures in the pipeline settings.

I also tried to use a render texture correctly connected to a camera but result is the same.

I tried to include the shader in the project settings, tried using different cameras, disable post processing but the result is still the same.

Do you guys have an hint on how to fix this problem?

Any help is much appreciated



Solution 1:[1]

I Found what the problem is, in my shader I was using these functions:

struct v2f
        {
            ......
            UNITY_FOG_COORDS(1);
           ......
        };

and then:

v2f vert (appdata v)
        {
            .......
            UNITY_TRANSFER_FOG(o,o.vertex);
            ......
        }

I don't know exactly why using these is not working, maybe is a mistake by my side, but avoiding those functions I can actually see my shader in game.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 General Grievance