Sky Shader example

Hey, im trying to implement the Sky Shader example, but I get a black screen. This is what I implement. I dont need a sun, or is it necessary? I set my camera.far very high

this.sky = new Sky()
this.sky.scale.setScalar(100000)
this.scene.add(this.sky)

var uniforms = this.sky.material.uniforms;
uniforms[ "turbidity" ].value = 10
uniforms[ "rayleigh" ].value = 2
uniforms[ "mieCoefficient" ].value = .005
uniforms[ "mieDirectionalG" ].value = .8
uniforms[ "luminance" ].value = 1
1 Like

Yes a sun is necessary.

By sun do you mean directional light? It’s all happening in a shader and the example does not use one so that shouldn’t be needed.

@Fluqz you’ll have to post more of your code or a jsfiddle for people to help with why it’s not displaying

Just a Vector3 not a directional light, the uniform sunPosition which is by default 0,0,0.

2 Likes

For anyone still confused by Fyrestar’s solution here is the code answer with the sun vector

private createSky(): Sky {
    const sky = new Sky();
    sky.scale.setScalar( 450000 );
    sky.material.uniforms['turbidity'].value = 10;
    sky.material.uniforms['rayleigh'].value = 3;
    sky.material.uniforms['mieCoefficient'].value = 0.08;
    sky.material.uniforms['mieDirectionalG'].value = 0.8;

    const sun = new Vector3(1,10,0);
    sky.material.uniforms[ 'sunPosition' ].value.copy( sun );

    sky.visible = true;
    return sky;
  }