Opacity in material that is not masked or translucent

I am trying to create some grass geo and have textures that use opacity to cut out the grass shape on low poly geo. To get that opacity in the engine, I set the material to masked opacity. But that method generally uses the opacity mask to either set that pixel to completely seethrough or opaque depending on the threshold. This gives hard edges around where the texture opacity falls off.

I can use the opacity slot correctly when I set it to a translucent material but then I am seeing though the mesh from some angles and its not the type of shader I want anyway.

Is there a way to have a standard shader (like opaque) but have the opacity slot enabled to allow simple opacity with values in between 1 and 0 for cutting out shapes?

Hi dokipen -

There is two things you will probably want to do to achieve the look you are going for and maintaining you opacity mask. The first is to make sure that your texture has an unmatted alpha, this is not just an applied alpha channel, but a process which multiplies up the dim values of pixels along your alpha edge to ensure the correct values get translated into the shader. There is a wonderful tutorial that Bill Kladis does which is free to view on youtube, here. You will also want to adjust your clipping value based on the alpha and effect for which you are going.

Masked Materials are always going to be slightly “blocky,” but with the two method above you can achieve something which is much better looking in the long run.

Let me know how it comes out -

Eric Ketchum

Thank for the link Eric that was helpful. I understand the issue. That bring me to the point now where I think that isn’t the problem. The problem is that the static mesh is made out of lots of smaller intertwined cards. Some of the cards at the back are being rendered in front of the front cards. It’s not clear how the renderer chooses which pixel to be the final one but I’m guessing that the normal of the mesh decides if it should be seen of not. It’s a two sided material. It can be seen clearly when looking at a preview cube in the material editor though. One side of the cube renders correctly when the other three sides renders the back sides of the cubes. Is this expected behaviour with two sided materials?

I’ve encountered this problem as well. I’m guessing that the engine renders the triangles of a static mesh according to how they were numbered in your 3D package? If you used individual sprite card meshes it might work - but would incur many draw calls.

Sure thing…

As you can see some polygon render in front of others. It’s most easily seen in the cube in the material editor where the polygon on the left renders in front of the one behind it on the left but the rear right polygon renders on front. Its just a freshly made material that is translucent, two sided and has slots in emissive colour and opacity

9608-grassmeshmaterial.jpg

Hi dokipen -

I think I am confused as to the problem you are having. Can you post a screenshot of your material so I can see exactly what you are talking about?

Thank You -

Eric Ketchum

Hi dokipen -

I think I understand your problem a little better now. For what you are trying to do Translucency may not be the best route to go. I would suggest taking a look on the forums at Ulrich’s grass shader which works very well and provides a simulated opacity through subsurface lighting but keeps the sorting of a masked material. Many different users have come up with some great answers to foliage shading and have posted in that forum thread.

Thank You

Eric Ketchum