Jump to content

Fading out a mesh with ShaderMaterial texture (and a related shader question)


thrice
 Share

Recommended Posts

Quick question: Is there any way to fade out a ShaderMaterial'd mesh? mesh.material.alpha = X does not seem to have any affect on the alpha value, unless I am doing something wrong.

Am I missing something or is it not possible? (I can probably fake it by adding an alpha uniform to the fragment shader and explicitly passing it in, however this would be painful to animate).

Also, if I go the uniform route, I'm not sure how much overhead (if any), it adds, setting the uniform value for the shader before render. I've noticed a lot of games similar to mine (digital card games), will have their shader effects timed in sync for a particular effect, which led me to the assumption that there is probably a performance reason behind it? (because having the effects fire on a different start time would look better) - But maybe I'm way off mark with that assumption, anyone happen to know?

Link to comment
Share on other sites

Hi @thrice and Naz and everyone.

Umm, could you gently lower the texture.level?

https://www.babylonjs-playground.com/#10OZXZ#4

Line 50.  You know me... I take the easy way out, whenever possible.  :)

This lowers the entire texture level.  Perhaps you just wanted the EFFECT to go away, but still maintain display? 

I would need to turn-on a light in the scene... to accomplish things like that, and the light switch is WAY across the room.  :)

Link to comment
Share on other sites

Well, as far as I can tell, ShaderMaterial seems like a combination of material + texture, and I don't see a level property on the shader material? I only see alpha on the shader material, but setting the alpha to 0 doesn't seem to affect the shader material.

And, I'm actually trying to fade out the entire mesh not just the effect

Link to comment
Share on other sites

Ok, thx.  Umm... do you NEED to use a property on the shaderMaterial... as your fade-in/out adjuster?  Is that a requirement?

How about mesh.visibility?  https://www.babylonjs-playground.com/#10OZXZ#5

(line 50 again)  :)

See, post-processes are far downstream from depth/alpha blending/testing, so they are not affected by those things.  (hehe, like I have a clue.)  :)  Could be true, though.  Hopefully, smarter people than I... will comment soon.  Hopefully, Wingnut will quit giving bad suggestions and be quiet long enough for an expert to answer, eh?  :)

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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