[SOLVED] Opacity shader chunk - different results from different viewing angles

Hi there!

I have a problem when using a custom shader with the opacity chunk in my project. The shader yields different results from different viewing angles, meaning the transparency is calculated correctly when viewed from the “left” and incorrect when viewed from the “right”.

The shader should make the mesh invisible above a certain height, with a falloff area where the shader goes from opaque to transparent. The parameters can be adjusted on the “legs” entity.

From left to right: Front view, correct/expected transparency viewed from “left”, incorrect transparency when viewed from “right”

The shader does not change the behaviour when I rotate the mesh, which makes me think that the error is independent from the coordinate system of the scene.

Does anyone know how I can fix this problem?

Here is a minimal version of the problem: https://playcanvas.com/editor/scene/1181225

It’s a render order issue. As it’s one mesh, the engine renders the polygons in an undefined order so therefore the leg closest to the camera is rendered first, then the leg behind.

The best bet here is to have each leg as a separate mesh, that way the engine can work out which mesh is furthest away from the camera and render that one first.


I’m wondering if disabling ‘depth testing’ on the material would help but I can imagine there still would some issues on the areas where there is partial transparency.

This seems to be the problem. I will try it out!

Deactivating “Depth Write” or “Depth Test” does not fix the issue. Maybe because of the mentioned issues with the render order.

Yep, this fixed the problem. I split the model in two mesh parts and now transparency is rendered correctly