Jump to content

Fading in particles and transparent clearColor

Tomm Huth

Recommended Posts

I'm playing around with the particle system, trying to create subtle background particles wafting randomly around. I think i have something (https://www.babylonjs-playground.com/#WJBZQH), but I'd like to fade in particles - not just out. Particles suddenly appearing is a little jarring. Is that even possible? I know a "soft birth" of particles has been mention here before, but I couldn't really make much sense of it as is also tried to do alot more. 

Also: how can i use particles with a transparent scene clearColor? With that, particles are simply not visible until they appear over some geometry in the scene.

Any tips?

Link to comment
Share on other sites

Ha! I think there was something with my colors that messed things up, but

particleSystem.color1 = new Color4(1, 1, 1, .1)
particleSystem.color2 = new Color4(1, 1, 1, .85)
particleSystem.colorDead = new Color4(1, 1, 1, 0.0)

particleSystem.blendMode = ParticleSystem.BLENDMODE_STANDARD

works like a charm. I don't know why tho, so if anyone has any background info on this that would be great. How does particles get blended with the environment? My texture is an alpha channel png.

Now if only i could get the particles to fade in. I tried the suggestion from 

 but that did not work.

Link to comment
Share on other sites

I'm trying to, but its not obvious to me what to do. 

I'm trying this

if (particle.age < particle.lifeTime * .35) {
                particle.color.a = particle.age / (particle.lifeTime * .35)

            if (particle.age > particle.lifeTime * .7) {
                let x = (particle.age - particle.lifeTime * .7) / particle.lifeTime * .3
                particle.color.a = 1 - x

but it does not work, but i cannot find how the math is wrong. Fade in works, but fade out does not. Is this a case of to many decimals?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...