AlphaComposite and vertex fog.

When using new Blending mode AlphaComposite it’s impossible to premultiply fog contribution. This makes impossible to achieve full transparency. This makes my water shader depth fade look really bad.

Hi Jenny,

With the alpha composite blend mode in order to get full transparency you need to plug in 0 into both emissive color and opacity. The scene color is taken into account and added into emissive color. Here is post where Ryan Brucks approximates the alpha composite blend mode in a translucent material:

Hope that helps,

Hello.
I have to disagree.
In that material above emissive is unplugged and default value for emissive is zero. Problem with alpha composite is only related to Vertex Fog incatter. Transparent is rendered after fog and with alpha composite opacity does not “post” multiply output color. So this cause fog inscatter to be added twice. This is easy to test and verify. Fix would be to multiply fog inscatter color with opacity at material shader.

forwarding this to the original creator of ue4’s alpha composite.

Personally I think this is exactly how alpha composite should behave, but what do I know :stuck_out_tongue:

Problem is that you don’t have control over Tranlucensy vertex fog so you can’t premultiply that which causes fog contribute twice to given pixel which is clear bug.

Hi Jenny,

I apologize for the initial misunderstanding. I don’t think this is an issue and I’ve set up a few tests for this.

I was able to achieve full transparency with vertex fog in scatter enabled and the emissive and opacity inputs are zero. I also have the opacity set to one and a red color applied in a different screenshot for comparison. The only way I was able to reproduce your issue was by checking “used with editor compositing” under the material usage settings.

Opaque Test

** Emissive and Opacity at Zero**

Setting used to reproduce issue

107283-mat+settings.jpg

let me know if that helps,

I made simple test project to reproduce this bug. This is default empty project… Only changes that I made is to lower atmospheric fog starting distance.(just to make it more pronounced). Cube is using same material as above. Zero opacity, zero emissive and alpha composite with vertex fog. Bug is clearly a real issue.

link text

I made fix to BasePassPixelShader.usf
Adding these line just before final color calculation fix this issue. I guess this has to be dublicate to mobile version of this shader too.
#if MATERIALBLENDING_ALPHACOMPOSITE
VertexFog.rgb *= Opacity;
#endif

Could you verify if the following path fixes your issues (based on your comments ^^)?

Yes. That should be added to BasePassPixelShader.usf and to MobileBasePassPixelShader.usf. Not sure is there any other paths that need to be fixed too.

for the confirmation, I’ll search for any extra edge cases and submit the fix ASAP. for spotting it guys ^^