Jump to content

colorKind alpha and rendering order question


Zrokky
 Share

Recommended Posts

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 : 

 image1.jpg.9eda0fff8277af98c1af9f096782d9b9.jpg

It's cool, this is the result I'm looking for! ^_^ 

But when I rotate the camera, the blue is displayed above the green.

image2.jpg.cc3e3c76e1a4d169fbd9b3f4352455fc.jpg

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! ^_^ 

Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

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? 

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