Pārlūkot izejas kodu

add rain mixNum param

tags/2.17.0
Caven Chen pirms 3 gadiem
vecāks
revīzija
b881efa077

+ 2
- 1
modules/material/shader/weather/RainShader.glsl Parādīt failu

uniform sampler2D colorTexture; uniform sampler2D colorTexture;
varying vec2 v_textureCoordinates; varying vec2 v_textureCoordinates;
uniform float speed; uniform float speed;
uniform float mixNum;


float hash(float x){ float hash(float x){
return fract(sin(x*23.3)*13.13); return fract(sin(x*23.3)*13.13);
float v=1.-sin(hash(floor(uv.x*100.))*2.); 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.; float b=clamp(abs(sin(20.*time*v+uv.y*(5./(2.+v))))-.95,0.,1.)*10.;
c*=v*b; 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 Parādīt failu

this._delegate = undefined this._delegate = undefined
this._enable = false this._enable = false
this._speed = 10.0 this._speed = 10.0
this._mixNum = 0.5
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }


return this._speed return this._speed
} }


set mixNum(mixNum) {
this._mixNum = mixNum
this._delegate && (this._delegate.uniforms.mixNum = mixNum)
return this
}

get mixNum() {
return this._mixNum
}

/** /**
* *
* @private * @private
name: this._id, name: this._id,
fragmentShader: RainShader, fragmentShader: RainShader,
uniforms: { uniforms: {
speed: this._speed
speed: this._speed,
mixNum: this._mixNum
} }
}) })
this._viewer.scene.postProcessStages.add(this._delegate) this._viewer.scene.postProcessStages.add(this._delegate)

Notiek ielāde…
Atcelt
Saglabāt