3👍
✅
- You must make your material transparent by adding
transparent: true
to its attributes. vlak3color2: {type: 'vec2', value: new this.$three.Color('#de3c31')}
is confusing. Why are you trying to make a color of typevec2
? Just get rid of the type, you don’t need it. Three.js automatically recognizes the type when it sees it’s a Color.- The fourth value of
gl_FragColor
is the alpha. Right now you’re setting it to a constant1
, so you’re getting a fully-opaque color. Try to make it fade from 0 – 1 withsmoothstep()
:
void main() {
// y < 0 = transparent, > 1 = opaque
float alpha = smoothstep(0.0, 1.0, vUv.y);
// y < 1 = color1, > 2 = color2
float colorMix = smoothstep(1.0, 2.0, vUv.y);
gl_FragColor = vec4(mix(vlak3color1, vlak3color2, colorMix), alpha);
}
👤M –
Source:stackexchange.com