I use shadermaterial to create an object without transparent top and bottom. It doesn’t seem to work when I turn on both sides. This is part of my code.
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: -height / 10,
bevelSize: 0,
bevelThickness: 0,
bevelSegments: 0
})
const texture = new THREE.TextureLoader().load('./flowMap1.png')
texture.encoding = THREE.sRGBEncoding
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
this.material = new THREE.ShaderMaterial({
uniforms: {
'color': {
type: 'c',
value: new THREE.Color(this.options.color)
},
'texture0': {
type: 't',
value: texture
}
},
vertexShader: `
#include <common>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
varying vec2 vUv;
varying vec3 vNomal;
void main() {
vUv = uv;
vNomal = normal;
vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
vec4 mvPosition = viewMatrix * worldPosition;
gl_Position = projectionMatrix * mvPosition;
#include <logdepthbuf_vertex>
#include <fog_vertex>
}
`,
fragmentShader: `
#include <common>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
uniform sampler2D texture0;
uniform vec3 color;
varying vec2 vUv;
varying vec3 vNomal;
void main() {
#include <logdepthbuf_fragment>
float opacity = 1.;
vec4 map = texture2D(texture0, vUv /4.);
vec4 muti = vec4(color, opacity) * map;
if(abs(vNomal.y) > 0.95){
muti = vec4(color, 0.);
}
gl_FragColor = muti;
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
}
`,
transparent: true,
side: 2
})