Shaders in WebGL Build version go pink, but are fine in Windows Build

Hi,

This is my first time building with WebGL and I don’t know why this issue is happening. When I build my game for Windows, all the materials load correctly. However, when I build it with WebGL the shaders break.

I’ve placed the shaders in the Graphics section of Project Settings, and I’ve tried to load them with Resources.Load but I’m not sure I’ve done it correctly.

Any help would be greatly appreciated!!

9782091--1402884--upload_2024-4-20_17-15-8.png

WebGL version:

Windows:

whats the error message in browser? (F12 opens browser console usually)

This is all I could see.

9782268--1402947--upload_2024-4-20_19-50-33.png

9782280--1402953--upload_2024-4-20_19-54-4.png

pink means your shader didnt work usually

I understand that but why do they work in the windows build and not the webGL version?

because webgl has less capabilities…

Use this

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FindShader : MonoBehaviour
{
    protected void Start()
    {
        Material mat = GetComponent<SpriteRenderer>().material;
        mat.shader = Shader.Find(mat.shader.name);
    }
}