Download

Help Regarding Glass Shading with transparency maps and Two Sided!

I have a material/shader which represents glass with raindrops ontop of it.
The problem with this shader is that it only works one sided, and I want it to be two sided.

As of now, if I check two sided the material becomes extremely dark on one side and you can’t look through it.

My problem is that I want the material to be seen from all angles, and on the other side that the normals of the raindrop’s green channel to be flipped.

How do I achieve this, without doing it the hacky way by creating two planes ontop of eachother with normals facing different ways?

Windows isn’t letting me upload attachments now, i’ll upload them as soon as windows lets me!

EDIT:

Oke here are the screenshots and a gif, i waited for the approval to upload them!

I was not able to reproduce the “becomes extremely dark on one side and you can’t look through it” problem.
However, you can fix the normal map issue by using a “lerp” with a “twosidedsign” as the alpha input. Use this lerp to switch between flipped and nonflipped normal map.

Having the actual geometry contain two overlapping polygons facing opposite directions is not “hacky”, it’s the better way to do it. When you use two-sided materials the geometry needs to be rendered twice.

This is not true. Having two overlapping polygons will double the geometry and vertex shader cost. Using two-sided material just disables back face clipping and will not render anything twice.

UE4 already does that for you internally, if you are using tangent space normals in material.

I uploaded some screenshots of my material and a gif, maybe that helps?

Indeed it doubles the drawcalls if i’m not mistaken.

Can you explain in greater detail, on how to set this up?
Since i’m sure UE4 does not auto detect which side needs to flip the green channel of the normal map.

It does not.

GPU has built in flag SV_isFrontFace. When two sided rendering is used pixel normal is multiplied with MaterialParameters.TwoSidedSign which is negative when pixel that is rendered is from backfaced triangle. Normal map does not have anything to do with this. Remember that normal calculation can be arbitary.

yes but what I want in this material, is that I can choose or tell UE4. to flip the green channel, on the side that’s being double sided.
If I want this for the hacky way, i just duplicate the texture and flip it’s green channel that way. but i don’t want to do that because it’s busy work and hacky.

how does duplicating an object with a different material, not increase draw calls?

Sorry I understood wrong.

Correct way to do it is using twosidedsign node.

Aah oke i will try that one out!