URP Unlit shader broken in webGL 2022.3 (working in 2022.2)

I have this shader that was working in 2022.2 webGL and still works in the editor at the 2022.3 but is pink in the webGL build for 2022.3? not so good with shaders so any help would be really appreciated, just need a shader that works in in urp webGL 2022.3 that is unlit with texture colour and transparency and is not pink.

Shader "Universal Render Pipeline/Unlit Transparent Colour Texture" {

        Properties
        {
            [MainColor] _BaseColor("BaseColor", Color) = (1,1,1,1)
            [MainTexture] _BaseMap("BaseMap", 2D) = "white" {}
            [Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 4
        }

        SubShader
        {
            Tags {"Queue" = "Transparent"  "RenderType" = "Opaque" "RenderPipeline" = "UniversalRenderPipeline"}

            Pass
            {
                Tags { "LightMode" = "UniversalForward" }

                ZTest[_ZTest]
                ZWrite On
                Blend SrcAlpha OneMinusSrcAlpha

                HLSLPROGRAM
                #pragma vertex vert
                #pragma fragment frag

                #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

                struct Attributes
                {
                    float4 positionOS   : POSITION;
                    float2 uv           : TEXCOORD0;
                };

                struct Varyings
                {
                    float2 uv           : TEXCOORD0;
                    float4 positionHCS  : SV_POSITION;
                };

                TEXTURE2D(_BaseMap);
                SAMPLER(sampler_BaseMap);

                CBUFFER_START(UnityPerMaterial)
                float4 _BaseMap_ST;
                half4 _BaseColor;
                CBUFFER_END

                Varyings vert(Attributes IN)
                {
                    Varyings OUT;
                    OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
                    OUT.uv = TRANSFORM_TEX(IN.uv, _BaseMap);
                    return OUT;
                }

                half4 frag(Varyings IN) : SV_Target
                {
                    return SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv) * _BaseColor;
                }
                ENDHLSL
            }

        }
 
}

The standard urp unlit shader that comes with 2022.3 does all the things,and it works in the webGL too, thank you unity developers.

I manged to get some where with the built in unlit but its not performing as needed. I have some functionality where the object that the shader is applied to can be overlayed or not depending on user settings. Not sure if there is an easy way to do this with the built in unlit. any help advice would be very much apprenticed

I encountered a similar issue where my URP “hand-written” shaders (no shader graph) would produce a pink color when built in WebGL. It turns out i had copy-pasted an old Tag from the URP doc to write the shader.

This tag seems to have been renamed and it seems that if you don’t have the correct tag when you build in webgl, the shader in stripped or at least invalid with no explicit error.

Therefore, make sure you change this:

Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalRenderPipeline" }

to

Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" }

IE: in your shader, rename the tag value UniversalRenderPipeline to UniversalPipeline

2 Likes