| @@ -1,6 +1,7 @@ | |||
| uniform sampler2D colorTexture; | |||
| varying vec2 v_textureCoordinates; | |||
| uniform float speed; | |||
| uniform float mixNum; | |||
| float hash(float x){ | |||
| return fract(sin(x*23.3)*13.13); | |||
| @@ -18,5 +19,5 @@ void main(){ | |||
| float v=1.-sin(hash(floor(uv.x*100.))*2.); | |||
| float b=clamp(abs(sin(20.*time*v+uv.y*(5./(2.+v))))-.95,0.,1.)*10.; | |||
| c*=v*b; | |||
| gl_FragColor = mix(texture2D(colorTexture, v_textureCoordinates), vec4(c,1), 0.5); | |||
| gl_FragColor = mix(texture2D(colorTexture, v_textureCoordinates), vec4(c,1), mixNum); | |||
| } | |||
| @@ -16,6 +16,7 @@ class Rain { | |||
| this._delegate = undefined | |||
| this._enable = false | |||
| this._speed = 10.0 | |||
| this._mixNum = 0.5 | |||
| this._state = State.INITIALIZED | |||
| } | |||
| @@ -46,6 +47,16 @@ class Rain { | |||
| return this._speed | |||
| } | |||
| set mixNum(mixNum) { | |||
| this._mixNum = mixNum | |||
| this._delegate && (this._delegate.uniforms.mixNum = mixNum) | |||
| return this | |||
| } | |||
| get mixNum() { | |||
| return this._mixNum | |||
| } | |||
| /** | |||
| * | |||
| * @private | |||
| @@ -55,7 +66,8 @@ class Rain { | |||
| name: this._id, | |||
| fragmentShader: RainShader, | |||
| uniforms: { | |||
| speed: this._speed | |||
| speed: this._speed, | |||
| mixNum: this._mixNum | |||
| } | |||
| }) | |||
| this._viewer.scene.postProcessStages.add(this._delegate) | |||