Hello, I encountered a weird behaviour that’s breaking my build and I have no idea of where to even start looking so I thought of asking here.
I’m working with Unity 2019.4.29f1 and URP 7.7.1, and I’m using the Blit renderer feature from GitHub - Cyanilux/URP_BlitRenderFeature: Blit Render Feature for Universal RP's Forward Renderer. Set specific source/destination via camera source, ID string or RenderTexture asset. Also options for _InverseView matrix and _CameraNormalsTexture generation. .
In my project I created a blit pass, that has a material with its shader. From a script, attached to a game object in my scene, I basically have to get the main camera, store it in a field for later use, and set some camera properties to the material used for the blit. In particular, I set a float to be equal to Camera.fieldOfView, which works fine in the editor, but breaks for me in build.
I was able to recreate a minimal example for my problem so I’m gonna show that.
This is my blit, material and shader setup. I’m saving the material in the Resources folder.

The shader is made in Shadergraph, and for this example I’m just taking the fov property and using it to lerp between 0 and 120 to get a color value.
The script attached to my game object looks like this
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TesterScript : MonoBehaviour
{
public Material material;
Camera mainCamera;
private void Start() {
mainCamera = Camera.main;
Debug.Log("Start value: "+material.GetFloat("_verticalViewAngle"));
Debug.Log("Setting value to "+ mainCamera.fieldOfView);
material.SetFloat("_verticalViewAngle", mainCamera.fieldOfView);
}
private void Update() {
Debug.Log("Material current value:" + material.GetFloat("_verticalViewAngle"));
Debug.Log("Camera fov current value:" + mainCamera.fieldOfView);
/* do other stuff with mainCamera */
}
}
Note that I initialize the property to 0 by hand, so in the editor before I hit play everything is just black. Then when I start the game my scene looks like this
However, when I build the project and run it everything just remains black
although the log file says something different (I can’t explain that start value:1)
Start value: 1
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)
Setting value to 60
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)
Material current value:60
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)
Camera fov current value:60
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)
Material current value:60
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)
Camera fov current value:60
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)```
Interestingly, when testing on my actual shader and script (instead of this toy example) in the log file I was getting a completely different number for the "Material current value", specifically 91.49284, which however still didn't match the actual result on my screen.
As I mentioned, I have no idea of what might be causing this issue so any help is greatly appreciated!