2 transparent objects

Here is a test scene i set up to replicate my issue.


both objects have some transparency to them.
as you can see the sphere is good then when it goes to the box it gets clipped when it passes a ceratin point and STILL IN THE Box the clipping is now not happening
also looks like the shading changes as well.
I know its something with the depth buffer but not sure how to fix it
or if its a bug

This seems similar to the issue I was facing here:

transparent objects are sorted back to front and rendered in that order. So what you see is that at some point, one comes to the front of the other, they render in different order and you get a pop.

  • You could implement depth peeling for order independent transparency … but that gets expensive quickly.
  • you could use additive blend mode which is independent of the order - but that the look is different as well
  • or you could use manual sorting on the layer and sort the objects in a constant way - but that wont really fix the issue, you will just avoid the pop when order swaps

what are you trying to do?

Well for my use case i want one object to always take priority and be on top so i figure I can do that with layers.

1 Like

ah well my layer idea is not going to work because of the below documentation.
Taking out the transparency all i would like to do is have my object always rendered on top. If I disable depthtest to all my materials on my model i can see parts of my model on the other side of its self

Note : Putting a model component inside a layer that is rendered after the world layer will not make the model render on top of everything in the world layer! The Standard Material used to render models has a property called depthTest . When this is true (the default) before each pixel of the model is rendered the GPU will test to see if there is something else in front if this pixel. Even if that pixel was drawn in an earlier layer depth test ensures that only visible pixels are drawn. If you wish to ignore the distance from the camera when rendering a mesh, disable depthTest in your material.

Do you always want something to render on top, completely ignoring anything that was rendered before it?


Oh that’s doable, there’s a couple of ways to do this. I see if I can make an example later

The TLDR is to clear the depth buffer before rendering that layer

you can create a layer, lets say TopLayer in the Editor, and add it to render after the World Layer.
From script, set the layer to clear depth buffer using clearDepthBuffer property, set it to true.
Assign object(s) you want to be on top into that layer.
And set up the camera to render both World and TopLayer layers.

thank you both. I will look at
From script, set the layer to clear depth buffer using clearDepthBuffer property, set it to true.

Quick example: https://playcanvas.com/editor/scene/1121422

oh awesome super easy.
Thank you

Bear in mind, as this layer clears the depth buffer, any layers after it will also render on top of what was rendered prior to this layer.