thrice Posted September 23, 2017 Share Posted September 23, 2017 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? Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted September 24, 2017 Share Posted September 24, 2017 you say alpha have optimized problem? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 24, 2017 Share Posted September 24, 2017 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. Quote Link to comment Share on other sites More sharing options...
thrice Posted September 24, 2017 Author Share Posted September 24, 2017 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 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 24, 2017 Share Posted September 24, 2017 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 25, 2017 Share Posted September 25, 2017 ShaderMaterial expects that you give the code for shaders. So setting material.alpha to 0 does not change the code of your shader. You have to add an uniform to support it. So your assumption was right: Just need to add your own uniform and set it before rendering the mesh:) NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
thrice Posted September 30, 2017 Author Share Posted September 30, 2017 @Wingnut Ya visibility doesn't work either for a mesh with a shader material applied unfortunately. But no, I always appreciate the help regardless! Cool thanks Delta Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.