Or:
function fadeInScene() {
Effect.ShadersStore['fadePixelShader'] =
'precision highp float;' +
'varying vec2 vUV;' +
'uniform sampler2D textureSampler; ' +
'uniform float fadeLevel; ' +
'void main(void){' +
'vec4 baseColor = texture2D(textureSampler, vUV) * fadeLevel;' +
'baseColor.a = 1.0;' +
'gl_FragColor = baseColor;' +
'}'
let fadeLevel = 1.0
const postProcess = new PostProcess('Fade', 'fade', ['fadeLevel'], null, 1.0, camera)
postProcess.onApply = effect => {
effect.setFloat('fadeLevel', fadeLevel)
}
let alpha = 0
scene.registerBeforeRender(function() {
fadeLevel = Math.abs(Math.cos(alpha))
alpha += 0.01
})
}