davychen Posted August 26, 2016 Share Posted August 26, 2016 hi guys, i've a question, please help. i have a tree mesh in the scene, and i created some instances of the tree to make a forest, i expect when i walking through the forest, the trees far before my view to fade in from alpha 0 to alpha 1. seting alpha of material works, but all instances has but one material, i can't set separate trees to different alpha. and if i set visibility of mesh, it doesn't work. from this link: http://doc.babylonjs.com/tutorials/Transparency_and_How_Meshes_Are_Rendered i saw, to use mesh alpha, i need to export model with vertices alpha channel. how can i do it with babylon exporter? thank you. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 26, 2016 Share Posted August 26, 2016 camera.maxZ = will do the trick in 99% here are more performance optimizationshttp://doc.babylonjs.com/tutorials playing around with alpha channel for trees ? Quote Link to comment Share on other sites More sharing options...
davychen Posted August 26, 2016 Author Share Posted August 26, 2016 48 minutes ago, Nabroski said: camera.maxZ = will do the trick in 99% here are more performance optimizationshttp://doc.babylonjs.com/tutorials playing around with alpha channel for trees ? thank you, Nabroski, your tips really help. it solves one of my problem, my ground is large, and i can't cover all the area in sight with so many trees, so thank you. but i still want mesh alpha fading effect, could you give more suggestions? Quote Link to comment Share on other sites More sharing options...
adam Posted August 26, 2016 Share Posted August 26, 2016 Would a fog effect work for you? https://doc.babylonjs.com/tutorials/Environment Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 26, 2016 Share Posted August 26, 2016 Yes im out of time, its a value, you have to animate it in a certain way! Thank you Adam! Bit sketchy and nooby:http://www.babylonjs-playground.com/#1JZWGU#0 Quote Link to comment Share on other sites More sharing options...
adam Posted August 26, 2016 Share Posted August 26, 2016 Maybe LOD would work for you? http://www.babylonjs-playground.com/#14ESWC using alpha: http://www.babylonjs-playground.com/#14ESWC#14 Nabroski 1 Quote Link to comment Share on other sites More sharing options...
davychen Posted August 26, 2016 Author Share Posted August 26, 2016 38 minutes ago, adam said: Maybe LOD would work for you? http://www.babylonjs-playground.com/#14ESWC using alpha: http://www.babylonjs-playground.com/#14ESWC#14 hi Adam, i think using fog is a good choice. i'll see if fog can coexist with skybox. thank you. Quote Link to comment Share on other sites More sharing options...
adam Posted August 26, 2016 Share Posted August 26, 2016 http://playground.babylonjs.com/#73AEY#0 Quote Link to comment Share on other sites More sharing options...
davychen Posted August 26, 2016 Author Share Posted August 26, 2016 57 minutes ago, Nabroski said: Yes im out of time, its a value, you have to animate it in a certain way! Thank you Adam! Bit sketchy and nooby:http://www.babylonjs-playground.com/#1JZWGU#0 hi Nabroski, thank you for the code sample, but you know, in this sample, transparent is set through alpha property of material. in my case, all the trees are instances of one tree mesh, all the instances share a common material, if i set alpha of material, all the trees will have same alpha level. Quote Link to comment Share on other sites More sharing options...
davychen Posted August 26, 2016 Author Share Posted August 26, 2016 41 minutes ago, adam said: http://babylonjs-playground.azurewebsites.net/#73AEY#0 thank you for the sample, it's very useful. Nabroski 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 26, 2016 Share Posted August 26, 2016 I don't think you can on instances they would stay like their initial state , you would need to do a clone I believe. (if im picking up what your laying down my bad if its off topic I was speed reading before work here) and how are you setting the visibility? I would recomend using .setEnabled(false); on the mesh and drop it from the draw stack entirely. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 26, 2016 Share Posted August 26, 2016 53 minutes ago, davychen said: in my case, all the trees are instances of one tree mesh, all the instances share a common material, if i set alpha of material, all the trees will have same alpha level. This is my 296 Post in this Forum, and now you understand why Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 26, 2016 Share Posted August 26, 2016 Yeah so then var originalMesh = getOriginalMesh(); var newInstance = originalMesh.createInstance("index: " + index); will make an exact duplicate of the object that shares a single reference to everything that is handled by draws like materials ect... things you can change are scale position and rotation. now a var newClone = originalMesh.clone("index: " + index); Uses the same mesh for the draw but creates new references of materials so you can change them independently. A clone is slightly more system intensive but is the way to reuse a mesh with a different material as apposed to doing a whole new draw call. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 26, 2016 Share Posted August 26, 2016 I love when the community is handling questions in such a brilliant way! Nabroski and Pryme8 2 Quote Link to comment Share on other sites More sharing options...
davychen Posted August 27, 2016 Author Share Posted August 27, 2016 23 hours ago, Pryme8 said: Yeah so then var originalMesh = getOriginalMesh(); var newInstance = originalMesh.createInstance("index: " + index); will make an exact duplicate of the object that shares a single reference to everything that is handled by draws like materials ect... things you can change are scale position and rotation. now a var newClone = originalMesh.clone("index: " + index); Uses the same mesh for the draw but creates new references of materials so you can change them independently. A clone is slightly more system intensive but is the way to reuse a mesh with a different material as apposed to doing a whole new draw call. thank you, Pryme, i think this will be the final solution. thank you Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 28, 2016 Share Posted August 28, 2016 http://www.babylonjs-playground.com/#2CHATH#5 jerome and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
davychen Posted August 29, 2016 Author Share Posted August 29, 2016 15 hours ago, Nabroski said: http://www.babylonjs-playground.com/#2CHATH#5 thank you Nabroski, very cool sample, verry useful. 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.