Issue with material data in -batchmode -nographics

Hello, while. moving to Unity 2022.2.9f1 from version 2019.2.19f1 i’ve faced to the problem. When i run standalone build in the “-batchmode -nographics” mode i can’t get data information about material. However in normal mode it works correct. Wherein there are several errors that shader is not supported on this GPU. Is there any easy way to solve this problem?

“ERROR: Shader Custom/Lightmapped_Diffuse_Rotation shader is not supported on this GPU (none of subshaders/fallbacks are suitable)”

The “checker” script:

using System.Text;
using UnityEngine;

public class TestMats : MonoBehaviour
{
    public Material mat;
    void Start()
    {
        Print(mat);

#if !UNITY_EDITOR
        Application.Quit();
#endif
    }

    void Print(Material mat)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append($"mat: \n\t{mat.name}[{mat.shader.name}] \n\tmainTexture: {mat.mainTexture} \n\tcolor: {mat.color} \n\tGetColor(_Color): {mat.GetColor("_Color")} \n\tOffset: {mat.mainTextureOffset} \n\tScale: {mat.mainTextureScale}");
        sb.Append($"\n\tmat.HasTexture: {mat.HasTexture("_MainTex")} \n\tmat.HasProperty(_MainTex): {mat.HasProperty("_MainTex")} \n\tHasFloat(_Angle): {mat.HasFloat("_Angle")} \n\tHasProperty(_Angle): {mat.HasProperty("_Angle")}");

        string[] floats = mat.GetPropertyNames(MaterialPropertyType.Float);
        string[] vectors = mat.GetPropertyNames(MaterialPropertyType.Vector);
        string[] textures = mat.GetPropertyNames(MaterialPropertyType.Texture);

        sb.Append($"\nFloat properties:\n\t {string.Join(", ", floats)}");
        sb.Append($"\nVector properties:\n\t {string.Join(", ", vectors)}");
        sb.Append($"\nTexture properties:\n\t {string.Join(", ", textures)}");
        Debug.Log(sb.ToString());
    }

}

Check result, normal mode:
‘.\TestMats.exe’ -logFile log_out.txt
log_out.txt:

*mat:* 
*Material[Custom/Lightmapped_Diffuse_Rotation]* 
*mainTexture: sample (UnityEngine.Texture2D)* 
*color: RGBA(1.000, 1.000, 1.000, 1.000)* 
*GetColor(_Color): RGBA(1.000, 1.000, 1.000, 1.000)* 
*Offset: (0.00, 0.00)* 
*Scale: (1.00, 1.00)*
*mat.HasTexture: True* 
*mat.HasProperty(_MainTex): True* 
*HasFloat(_Angle): True* 
*HasProperty(_Angle): True*
*Float properties:*
*_ScaleX, _ScaleY, _Angle*
*Vector properties:*
*_MainTex_ST, _MainTex_TexelSize, _MainTex_HDR, _Color, _LightMap_ST, _LightMap_TexelSize, _LightMap_HDR*
*Texture properties:*
*_MainTex, _LightMap*

“-batchmode -nographics” mode:
‘.\TestMats.exe’ -batchmode -nographics -logFile log_out_batch.txt
log_out_batch.txt:

*mat:* 
*Material[Custom/Lightmapped_Diffuse_Rotation]* 
*mainTexture: sample (UnityEngine.Texture2D)* 
*color: RGBA(0.000, 0.000, 0.000, 0.000)* 
*GetColor(_Color): RGBA(0.000, 0.000, 0.000, 0.000)* 
*Offset: (0.00, 0.00)* 
*Scale: (1.00, 1.00)*
*mat.HasTexture: False* 
*mat.HasProperty(_MainTex): False* 
*HasFloat(_Angle): False* 
*HasProperty(_Angle): False*
*Float properties:*

*Vector properties:*

*Texture properties:*

As it seems from log i can’t get neither custom properties nor color set in material. This is repeated with both the standard shader and mine.

Shader:

Shader "Custom/Lightmapped_Diffuse_Rotation" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB)", 2D) = "white" {}
    _LightMap ("Lightmap (RGB)", 2D) = "black" {}
    _Angle("Rotation", float) = 0
    _ScaleX("ScaleX", float) = 1
    _ScaleY("ScaleY", float) = 1
}

SubShader {
    LOD 200
    Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Lambert
float _Angle;
float _ScaleX;
float _ScaleY;
float2 transform(float2 texcoord)
{
    float a = _Angle * 3.1415926535 / 180;
    //float3 point = float3(texcoord.x - 0.5, texcoord.y - 0.5, 1);
    float3x3 rotationMatrix = float3x3(cos(a), -sin(a), 0,
                                            sin(a), cos(a), 0,
                                            0, 0, 1);
    float3 newPoint = mul(rotationMatrix, float3((texcoord.x) - 0.5, (texcoord.y) - 0.5, 1));      
    return float2((newPoint.x + 0.5) * _ScaleX, (newPoint.y + 0.5) * _ScaleY);
}

float2 transform2(float2 texcoord)
{
    float a = _Angle * 3.1415926535 / 180;
    texcoord.xy -= 0.5;
    float s = sin(a);
    float c = cos(a);
    float2x2 rotationMatrix = float2x2(c, -s, s, c);
    rotationMatrix *= 0.5;
    rotationMatrix += 0.5;
    rotationMatrix = rotationMatrix * 2 - 1;

    texcoord.xy = mul(texcoord.xy, rotationMatrix);
    texcoord.xy += 0.5;
    return texcoord;
}


struct Input {
  float2 uv_MainTex;
  float2 uv2_LightMap;
};
sampler2D _MainTex;
sampler2D _LightMap;
fixed4 _Color;
void surf (Input IN, inout SurfaceOutput o)
{
  o.Albedo = tex2D (_MainTex, transform(IN.uv_MainTex)).rgb * _Color;
  half4 lm = tex2D (_LightMap, IN.uv2_LightMap);
  o.Emission = lm.rgb*o.Albedo.rgb;
  o.Alpha = lm.a * _Color.a;
}
ENDCG
}
FallBack "Legacy Shaders/Lightmapped/VertexLit"
}

8874786–1211940–TestMats.zip (83 KB)

Hi all. After i didn’t find any answer to my problem i’ve decided to write additional component. It duplicates all properties of material and all properties(textures, colors, scale etc.) are applied by this script. Therefore in -batchmode -nographics mode i can easily get all necessary data by this script despite uncorrect work of material.