Dither clouds

This commit is contained in:
Joshua Seigler 2018-10-12 14:03:43 -04:00
parent 8721b90d84
commit 0b5065bc97
7 changed files with 16 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View file

@ -11,6 +11,11 @@ class Clouds extends THREE.Object3D {
this.cloudTexture.wrapS = this.cloudTexture.wrapT = THREE.RepeatWrapping;
this.cloudTexture.repeat.set(3, 3);
this.cloudShadow = loader.load('textures/clouds-dithered.png');
this.cloudShadow.wrapS = this.cloudShadow.wrapT = THREE.RepeatWrapping;
this.cloudShadow.magFilter = THREE.NearestFilter;
this.cloudShadow.repeat.set(3, 3);
this.material = new THREE.MeshBasicMaterial({
map: this.cloudTexture,
transparent: true,
@ -21,12 +26,12 @@ class Clouds extends THREE.Object3D {
mesh.customDepthMaterial = new THREE.MeshDepthMaterial({
depthPacking: THREE.RGBADepthPacking,
map: this.cloudTexture,
alphaTest: 0.3
map: this.cloudShadow,
alphaTest: 0.25
});
mesh.rotation.x = -Math.PI/2;
mesh.position.y = 10;
mesh.position.y = 15;
mesh.castShadow = true;
this.add(mesh);
@ -35,8 +40,10 @@ class Clouds extends THREE.Object3D {
}
onUpdate(time) {
this.cloudTexture.offset.x = (time / 1000) % 200;
this.cloudTexture.offset.y = (time / 5000) % 400;
this.cloudTexture.offset.x = (props.cloudSpeed / 1000 * time) % 200;
this.cloudTexture.offset.y = (props.cloudSpeed / 5000 * time) % 400;
this.cloudShadow.offset.x = (props.cloudSpeed / 1000 * time) % 200;
this.cloudShadow.offset.y = (props.cloudSpeed / 5000 * time) % 400;
}
}

View file

@ -10,8 +10,8 @@ class Lighting extends THREE.Object3D {
dirLight.position.multiplyScalar( 20 );
dirLight.castShadow = true;
dirLight.shadow.mapSize.width = 1024;
dirLight.shadow.mapSize.height = 1024;
dirLight.shadow.mapSize.width = 2048;
dirLight.shadow.mapSize.height = 2048;
dirLight.shadow.radius = 2;
let d = 100;

View file

@ -46,8 +46,6 @@ export default class Webgl {
initPostprocessing() {
if (!this.usePostprocessing) return;
this._composer = new THREE.EffectComposer(this._renderer);
let ssaoShader = THREE.SSAOShader;
ssaoShader.uniforms.onlyAO = true;
this._passes.forEach((effect, i) => {
if (i == this._passes.length - 1) {
effect.renderToScreen = true;

View file

@ -1,5 +1,5 @@
const props = {
rotation: 0.01,
cloudSpeed: 0.5,
};
module.exports = props;

View file

@ -16,7 +16,7 @@ loop.add(webgl.onUpdate);
// ##
// GUI
const gui = new dat.GUI();
gui.add(props, 'rotation', 0.01, 1);
gui.add(props, 'cloudSpeed', -1, 1);
gui.close();
webgl.add(new Ground());