Shadows Disappearing When using Fresnel Function in Masked Material

I’m not sure if this is a new bug but if not i’m surprised if this hasn’t been caught earlier - basically, when using a Fresnel function in a default lit masked material, I’m finding the shadows of my model are disappearing at certain angles in a very unusual way:

You’ll notice that this is not reflected in the actual model material in the world, here it behaves as expected.

Can this be fixed? Right now it’s turning into a big problem for me :frowning:

Thanks.

Hey brisck1,

So I would look at making your material for the leaves ‘Two-Sided’ by checking that in the material properties.

Are you attempting to use the regular Fresnel node and not the function node? The fresnel function node works a bit differently than a regular fresnel which is why I ask.

The best way for me to assist you would be for you to provide me with this simple test project so I can open it up and take a look at how you have your scene and materials completely set up.

Thanks,

That is not a bug and looks expected to me. I’ve answered on the forums.

The fix for this would be not to use the fresnel that way.

Hi Andrew, thanks for your reply, to answer some of your questions:

So I would look at making your
material for the leaves ‘Two-Sided’ by
checking that in the material
properties.

Two sided lessens the effect somewhat, but it still is happening to a degree that is pretty noticeable.

Are you attempting to use the regular
Fresnel node and not the function
node? The fresnel function node works
a bit differently than a regular
fresnel which is why I ask
.

I have tried both the Fresnel function node and the Fresnel node and both produce the same results. purely speculating, but it seems to me that alpha Fresnel for the shadows is being calculated with a Dot product of the Light Vector and Normal Vector rather than Player view vector and Normal Vector?

The best way for me to assist you
would be for you to provide me with
this simple test project so I can open
it up and take a look at how you have
your scene and materials completely
set up.

Please find a test project attached:

Fresnel Alpha Test

Thanks again!

Just want to update this with a couple of possible solutions which have come to light, the first is to add a custom code node with the following code:

#if(SHADOW_DEPTH_SHADER)
return fShdw;
#endif
return fAll;

Inputs being: fAll and fShdw

and set up like this:

Alternatively, this method also seems to work:

This can be a little bit more rough around the edges though, and the Fresnel might change depending on where the mesh is on screen .

more info can be also found on the [Forum Thread][3]

Ugg it seems like I’ve hit another snag - although the custom code node works for realtime lighting, BAKED static lighting still breaks when using the fresnel node:

How is lightmass reading alpha when baking? Is there a way to avoid this in lightmass too? (baked lighting is also important to my project)

Thanks.

Ok it seems all I need to do is use the LightmassReplace node to ignore the fresnel part and now it works perfectly with baked and real-time perfectly! Thanks so much everyone!