How to use custom shaders in WebGPU

I’m trying to do something that supports both renderers but seems like it can’t. This is what I came up with to manipulate the color node rather than position. But no idea how to add the median shader method. All those math methods are imports. This breaks trying to do with webgl renderer so maybe I might have to just do straight up wgsl instead.