Particle System Render on Color

I am trying to make a shader with ChatGPT to only render a particle if its over a specific color. However, it cannot seem to make that shader.

I don’t want to use the shape module as then I would have to import a lot of sprite to just mask out the areas.

Is this even possible?

You could just test for a specific color range and render the particles totally transparent or discard them in the pixel shader?

I tried asking chatgpt, but it was always wrong.

I need the particles to only spawn on a specific color on an entire group of sprites/line renderers/trail renderers. I don’t know if this is even possible? I think you would need to custom code that, right? But then you would have to set all the sprites to read/write and that has performance issues?

Shader "Custom/ColorRangeParticle" {
    Properties {
        _MainTex ("Texture", 2D) = "white" {}
        _Color ("Color", Color) = (1, 1, 1, 1)
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 100

        CGPROGRAM
        #pragma surface surf Standard

        sampler2D _MainTex;
        float4 _Color;

        struct Input {
            float2 uv_MainTex;
            float3 worldPos;
            float3 worldNormal;
            float3 worldRefl;
        };

        void surf (Input IN, inout SurfaceOutputStandard o) {
            // Sample the texture color
            fixed4 color = tex2D(_MainTex, IN.uv_MainTex);

            // Test if the color is equal to the specified color
            if (color.rgb == _Color.rgb) {
                o.Albedo = color.rgb;
                o.Alpha = color.a;
            } else {
                // Set the pixel color to transparent
                o.Albedo = 0;
                o.Alpha = 0;
            }
        }
        ENDCG
    }
    FallBack "Diffuse"
}