Need help with color space using a custom fragment shader

Hello. I am using custom shaders to solve a problem where I needed independent UVs for the texture map and alpha map. I began with the code in the accepted answer here.

This worked perfectly until I needed to update threejs to the latest version. I then began receive this error:

THREE.WebGLProgram: Shader Error 0 - VALIDATE_STATUS false
Program Info Log: Fragment shader is not compiled.
ERROR: 0:209: ‘mapTexelToLinear’ : no matching overloaded function found
ERROR: 0:209: ‘=’ : dimension mismatch
ERROR: 0:209: ‘assign’ : cannot convert from ‘const mediump float’ to ‘highp 4-component vector of float’

204: vec4 diffuseColor = vec4( diffuse, opacity );
205: #if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
206: gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
207: #endif
208: vec4 texelColor = texture2D( map, vUvB );
209: texelColor = mapTexelToLinear( texelColor );
210: diffuseColor *= texelColor;
211: #if defined( USE_COLOR_ALPHA )
212: diffuseColor *= vColor;
213: #elif defined( USE_COLOR )
214: diffuseColor.rgb *= vColor;
215: #endif

I was able to resolve the error by removing this line from the fragment shader code:

‘texelColor = mapTexelToLinear( texelColor );’,

Unfortunately, after doing that the color space on the resulting texture seems off. The video apears washed out. I have set

renderer.outputEncoding = THREE.sRGBEncoding;

All my other textures are rendering correctly, so changing this configuration is not a good option.

I know very little about writing fragment shaders and I cannot find any documentation about the function mapTexelToLinear. Please let me know if you know how I can restore its functionality to correct the color space.

There should be no need to use mapTexelToLinear beginning in r152. The video is decoded from sRGB to Linear-sRGB by the GPU, assuming the video texture has been annotated with texture.colorSpace = THREE.SRGBColorSpace.