+1
En revisión

Alpha Clip problem in Beta 0.22

Lionel Gallat hace 11 años actualizado por David Tang hace 10 años 10
Hi, I just updated to 0.22 and my alpha cutout shader doesn't work properly anymore. It acts as if it were a cutout + transparent shader. Meaning the cutout effect (from the diffuse texture's alpha channel) works fine but the mesh now looks like it's got some sort of gradient/depth info into the Alpha port of SF's main node.

As a result it looks slightly transparent (although there's nothing plugged into SF's Alpha port and the Blend Mode is set to Off). Everything was fine prior to my upgrade. Is that a known bug or did something change in the way alpha clip now works? Thanks...
After a little investigation is turns out the problem is visible when SSAO post-effect is activated on the game camera.

That's weird. As I said it wasn't causing any issue prior to 0.22...
(Since I can't modify the post I'll just reply to it)

Update:
For now I'll switch to Unity's Ambient Obscurance post-effect (instead of SSAO), which doesn't exhibit the same problem.
Ok, I believe there might be something amiss with the way Alpha Clip works in 0.22. This is my shader with nothing in the Alpha Clip port:



And the exact same shader with the diffuse texture's alpha plugged into the Alpha Clip port:



Please note as well that this looks exactly like the tessellation problem I mentioned before (http://shaderforge.userecho.com/topic/372272-tesse...), although no tessellation is involved in this shader.

Another telling symptom on the second picture is the fact that depth of field is much too strong (same setting on both pictures though); it really feels like Unity's getting confused as to the real distance at which the sphere is.
Well, the saga continues... I saw the last comment on this page: http://shaderforge.userecho.com/topic/305397-doubl... and so I opened my shader source code and commented out the line saying:

[HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5

And now Alpha Clip is working again (with correct depth of field and no more transparency/alpha problem)!
Hurgh, what a mess. So that line fixes it in some cases, and breaks it in others. The question is in which cases does it break?
I think some depth rendering stuff is reading alpha from whichever texture property you have called MainTex, and applying that as an alpha clip, with a cutoff set to 0.5 now, by default. Are you clipping with the alpha channel of a MainTex texture?
Also, is depth blending set to Alpha blended or Off? (Should be off)
Yes I am plugin the alpha channel of the main texture into the Alpha Clip port.

And for now manually removing that _cutoff line by hand every time I recompile the shader...


Hm, alright. What about my first two questions?
> So that line fixes it in some cases, and breaks it in others. The question is in which cases does it break?

After some more tests I re-implemented the _cutoff line in the shader source (but made it visible in the inspector) and it turns out playing with the slider does not actually change the cutout transition (?!).

But if I set the slider just a pixel under the mid-point (something like 0.49) everything looks fine, but setting it to or above 0.5 triggers the problem I reported in this very thread.

> Also, is depth blending set to Alpha blended or Off? (Should be off)
It's set to Off.
+2
Having the same problem in SF 0.35. Whenever I set up an Alpha Clip, the shader will allow shadows from the background to pass through. This only happens in Deferred Lighting. Removing the _Cutoff line (mentioned above) fixes the problem.