Prevent Alpha from adding up

I’m trying to create two transparent boxes that do not add up alpha values, as you can see in the border area where the alpha values seem to be adding up. My goal is to make the two boxes appear as one.

Can anyone help me with this issue? Please check out the playground link to see the problem.

Perhaps an opacity texture would be plausible in this scenario.

Is it for your game? I suppose we are not talking about two boxes but rather a number of boxes. Where substract is probably not an option. You could have used the alphaIndex but it won’t work from all angles. Not sure either what OIT could help here. Say your boxes would be made from planes, you could use the stencil, but I don’t know how to make it work on a box mesh. That’s too far fetched for me :dizzy_face: The solution of an opacity texture would most likely be the easiest and the one a loose graphic designer like me would use. Else, I sure would be happy to read about the expert answer for this @Evgeni_Popov ?

Yes, it is for my game and we are talking about a lot of meshes.

To explain, I stream landscape data and stitch it together in real-time. Currently, I solve this issue by using textures that are transparent at the borders.

However, since I am using shader material and transparency (for example, water) for some landscape biomes, I am looking for an alternative solution.

This issue has been a headache for me.

Anyone who solves this issue will become a hero for me :smiley:

I thought so. Let’s just wait for the expert. I’m clearly not qualified for this.
Meanwhile, have a great day :sunglasses:

Edit: I was just thinking. May be @lucas-divinestar has some tip. He did some waterfalls and fancy stuff that seems to use transparency on cubes.

1 Like

I have played around with the stencil feature on the playground and achieved some results. However, there are some issues when viewed from above.

You can see the result here:

Here is the result of my game, after fixing the alpha issues I had with the shader material.

Before, I had to use a texture image with transparency to fix this issue. Thank you for nudging me in the right direction, Mawa :slight_smile:

Soon can players enjoy animated water :smiley:

3 Likes

Yes, I went about as far as that. I can also have it ok from above but with one side angle always showing the inner face of the cube. There must be some maths to apply to the function accounting the camera angle to make it work 100%. I’m just not very good with maths :grin:

1 Like

The stencil option is probably the best one. I think you don’t need the material to be transparent anymore with this solution? Your artefacts arise because the material is transparent and because of the order the faces are drawn: the bottom of the cube is drawn first, so when viewed from top, the stencil prevents the other faces to cover it.

2 Likes