Shader alpha query

I’ve got a query which I expect has a fairly obvious answer, but, I’m just not sure what terms to search for in order to find a solution.

I’ve got 2 shaders, one draws a landscape, the other draws particle effects over the top. What I’m seeing is if I fade out my particles, it ‘eats’ the landscape (showing the background colour.) This is (I think) some sort of blending issue, or ‘alpha write’ or perhaps something else…

…can anyone tell me what I should be looking for here?

1 Like

Most certainly, if you provide a live example of your code, showing the issue.

You need to set depthWrite to false on the material of the particles.

@Fyrestar I tried this and then the particles didn’t display at all without depthWrite set to true (on both landscape and particles!)

but, I randomly tried setting alphaToCoverage as true and that seems to partially resolve the issue (the particles don’t fade properly, but they also don’t eat the landscape.)

@tfoller it’s a fair request - I’ll build a cutdown version :slight_smile:

Disabling depth write for alpha blended particles is mandatory, they can only depth test with the scene. With enabled depth write anywhere alpha is lower than 1 it will blend with the background / the last thing rendered not depth testing against it, your terrain gets holes as it tested it’s depth with the depth written by the particle in front of.

However you might as well have something else causing trouble if you say they disappear then, it’s better to setup a simple live example, you might spot the issue there already.

It’s because alphaToCoverage is basically like using alphaTest - but prettier, as it’s rendering soft edges from multi-sampling.