Zrokky Posted June 22, 2017 Share Posted June 22, 2017 Hy everyone! I'm making a game and need a little help with the transparency stuff. So, in the game I have one material that has a texture (a png image that contains transparent parts). The mashes are made out of planes, merged together and the planes shows parts of the texture (think about it like Minecraft). I can set the colors of each plane in the mesh with the colorKind vertexdata.. except the alpha part. So I tried to find some topics about it and saw somewhere a tip to set the hasVertexAlpha on the mesh to true and add the texture to the opacityTexture. That worked, now I can set the RGBA on any parts of the mesh but the rendering order goes wrong Here's an image: the red and the green are one mesh (that has two planes, the green is above the blue), the blue is the other mesh. The green is half transparent using the colorKind alpha : It's cool, this is the result I'm looking for! But when I rotate the camera, the blue is displayed above the green. And here is playground link to what I'm experiencing in the game: https://playground.babylonjs.com/index2_5.html#8XDI7F#2 So in short, I want to have a material with a diffuseTexture that has transparent parts and use the colorKind RGBA on every plane in every mesh. What am I doing wrong and how can I fix it? Thanks for the help! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 23, 2017 Share Posted June 23, 2017 Why do you need alpha in the vertex attributes? https://playground.babylonjs.com/index2_5.html#8XDI7F#3 Does it work for your needs? If not you will have to use mesh.position only for positioning. If you use vertex data to offset your mesh, the scene won't be able to sort the meshes correctly (it only uses the position) Quote Link to comment Share on other sites More sharing options...
Zrokky Posted June 23, 2017 Author Share Posted June 23, 2017 Nope, I want the green to be half transparent But I kinda' understand the sorting problem. Should I use multimaterial on the red-green mesh (or seperate the two planes into two meshes) or is there any easy way to keep the green and red planes in one mesh and do something similar like setting the vertex alpha and get the green plane drawn as half transparent and the red as non transparent? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 26, 2017 Share Posted June 26, 2017 Unfortunately no as they need to be sorted but you can make them children of a parent mesh if you want to handle them together Quote Link to comment Share on other sites More sharing options...
Zrokky Posted July 3, 2017 Author Share Posted July 3, 2017 I seperated them into different meshes. Works perfectly, thanks for the help! GameMonetize 1 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.