소스 검색

add rain mixNum param

tags/2.17.0
Caven Chen 3 년 전
부모
커밋
b881efa077
2개의 변경된 파일15개의 추가작업 그리고 2개의 파일을 삭제
  1. 2
    1
      modules/material/shader/weather/RainShader.glsl
  2. 13
    1
      modules/weather/type/Rain.js

+ 2
- 1
modules/material/shader/weather/RainShader.glsl 파일 보기

@@ -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);
}

+ 13
- 1
modules/weather/type/Rain.js 파일 보기

@@ -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)

Loading…
취소
저장