Unity2022.3.9 Select the Graphics API is OpenGLCore, build and run the exe, Graphics.Blit is invalid

Windows 10
unity 2022.3.9

In unity editor
Graphics.Blit(souceImage, targetImage); is OK
Graphics.Blit(souceImage, targetImage,Myshader); is OK

build and run exe
Graphics.Blit(souceImage, targetImage); is OK
Graphics.Blit(souceImage, targetImage,Myshader); is invalid

I have no idea what your question is, sorry.

All we know is Graphics.Blit is giving you some error, but you don’t specify what or in what context.

Here’s my code
public class TestOpengl : MonoBehaviour
{
private Material MyShader = null;
[HideInInspector]
public Texture2D MyImage;
public Texture2D DefaultImage;

private int cookieSize = 1024;
private RenderTexture cookie = null;
private RenderTexture cookie2 = null;
void Start()
{
MyShader= new Material(Shader.Find(“NewUnlitShader”));
CreateCookie();
}

// Update is called once per frame
void Update()
{

}

private void CreateCookie()
{
if (MyImage== null)
{
MyImage= DefaultImage;
}
cookie = new RenderTexture(cookieSize, cookieSize, 24, RenderTextureFormat.ARGB32);
cookie.wrapMode = TextureWrapMode.Clamp;
cookie.useMipMap = true;
cookie.filterMode = FilterMode.Trilinear;
cookie.format = RenderTextureFormat.ARGB32;

Resources.UnloadUnusedAssets();
Renderer renderer = GetComponent();
renderer.material.mainTexture = cookie;

Graphics.Blit(MyImage, cookie, MyShader);
}
}

The NewUnlitShader is unity default shader
Select the Graphics API is OpenGLCore, build and run the exe, the MyShader is invalid

You should never use Shader.Find() unless you’re 100% sure the shader is being included in the build.

Shaders not referenced directly or indirectly by any object in at least one scene included in the build will be stripped away. Same applies to all Unity assets (materials, textures, models, etc). Attempting to use a shader which doesn’t exist will result in pink (invalid) shading at runtime.

You can force Unity to include a shader in the build by adding it to “always included shaders”: