I am trying to create a radial gradient background for my scene. I’ve found that two of my options are:
a) setting it up with CSS using ‘canvas.style.background’, but this won’t be reflected on the objects in the scene.
b) creating a plane with a custom shader material
After a lot of figuring out what any of that means, I’ve managed to find a gradient material shader that somewhat works, but isn’t radial. How can I make it radial as opposed to linear?
Also, is it possible to create a radial gradient with “scene.background”?
var material = new THREE.ShaderMaterial({
uniforms: {
color1: { value: new THREE.Color(`hsl(200, 40%, 70%)`)},
color2: { value: new THREE.Color(`hsl(110, 40%, 70%)`)}
},
vertexShader: `varying vec2 vUv;
void main(){
vUv = uv;
float depth = 1.;
gl_Position = vec4(position.xy, depth, 1.);
}`,
fragmentShader: `varying vec2 vUv;
uniform vec3 color1;
uniform vec3 color2;
void main(){
gl_FragColor = vec4( mix( color1, color2, vec3(vUv.y)), 1. );
}`
})