Shader material how get (map) texture?

Hello everyone, I have one problem here)
I decided to use my shader for (scene.overrideMaterial) and I need to somehow get the map texture.

MaterialsShader = {
    uniforms: {
        time: { type: 'f', value: 0.0 },
    },
    vertexShader: 
        "varying vec2 vUv; \n\
        void main(){\n\
            vUv = uv;\n\
            vec4 mvPosition = modelViewMatrix * vec4(position, 1.0 );\n\
            gl_Position = projectionMatrix * mvPosition;\n\
        }",
    fragmentShader: [
        'varying vec2 vUv;',
        'uniform float opacity;',
        
        '#ifdef USE_MAP',
    	
    		'uniform sampler2D map;',
    	
    	'#endif',

        'void main(){',
            'vec3 color = vec3(1.0,0.0,0.0) * opacity;',
            
            '#ifdef USE_MAP',
            
            	'vec4 mapTexel = texture2D( map, vUv.xy );',
                
                'gl_FragColor = mapTexel;',
                
            '#endif',

            //'gl_FragColor.rgb = color;',
        
		'}'].join("\n")
}

But for some reason the texture itself does not exist, I get black material.

var uniforms = THREE.UniformsUtils.clone( MaterialsShader.uniforms );

    uniforms = THREE.UniformsUtils.merge( [uniforms, THREE.UniformsLib['common'],THREE.UniformsLib['lights']] );


var material = new THREE.ShaderMaterial({
    uniforms        : uniforms,
    vertexShader    : MaterialsShader.vertexShader,
    fragmentShader  : MaterialsShader.fragmentShader,
});

How can I get a (map) texture?

Hello korner,

Could you make a JSfiddle with the whole code? I am not able to see how the texture is passed to the shader.

Have you tried to remove the #ifdef USE_MAP directive in the fragment shader?

fragmentShader: [
        'varying vec2 vUv;',
        'uniform float opacity;',
        'uniform sampler2D map;',
    	
        'void main(){',

          'vec4 mapTexel = texture2D( map, vUv.xy );',
          'gl_FragColor = mapTexel;',
          
		'}'].join("\n")

I did not put it right, I had to get a texture from the material that is on the object for my shader)

I looked at the library code, how the material works in the overlay mode, after the tests I realized that it would not be possible to get a texture from the material.

But I found another way, every object has an event (onBeforeRender) in this event I’m thinking of looking at what type of render goes, if standard then render with standard materials, if special then render with my shader.

Briefly explain why I needed it) So I want to render only the particles, which would then highlight them, the version was rendered in a separate scene, but it was not an option)