Consistent Transparency

Hey guys, I’ve been trying to fake Ambient Occlusion in a really cheap way (using gradients), the issue is, when these gradients touch with other gradients, their transparency blends together, making a darker color.

Here’s an image to explain clearly:
image

What solution do you think I could use to get a consistent transparency that doesn’t get blended with others? I know this is how blending is supposed to work, but I need to work around it somehow.

I think what I need is to render Alpha without translucency.

I don’t know how you would do it but you could render them in the order of closest first so the ones behind it don’t render due to depth testing?

Yep I think that could work.

Any ideas on how to approach this? Custom shader, or modifying the layers system?

Honestly, not really sure. There used to be a render order property on either the model or the meshinstance but I don’t know if that’s valid any more with the new layer system

Edit: this is what I used before: https://playcanvas.com/editor/code/446331?tabs=6108752

I don’t think that will work with the new layer system.

I’m checking out the engine code and I think if I manage to just not count the other meshes on the same custom ‘fake AO’ layer, then this translucency effect wouldn’t happen.

1 Like

@devMidgard made some progress on this, posting his related github issue here for reference:

2 Likes