Fresnel Fix for Cylinder Shapes

Hey, I don’t post here often but I thought I’d share my solution to Fresnel effects on cylinders to make sure they don’t go completely invisible when viewing from the same direction it points to.

Useful for energy beam type effects.
Done in Unity but can be used in Unreal. It involves rotating the vertex normals by the cross product of the forward vector and view direction.

Enjoy!

7 Likes

As you suggested in the video, it can be done a bit simpler.
Simply subtract the axis aligned component from the view direction and normalize to get a strictly orthogonal view direction.
Then dot the normal on that to get the ratio between the current normal and that orthogonal vector pointing to the camera.
This way you just need 1 dot product and 1 square root.


For the axis, one thing I like to do is to use the tangent / binormal and make sure those are aligned to the direction of the cylinder. Like this you can also somewhat support tubes by making sure the tangents are aligned with the direction of the tube. (but it breaks if the tube curves too much)


15 Likes

Awesome! I like your solution a lot better. I was somehow close to it before by multiplying the view direction by abs(1- axis), but that solution only worked at square angles like (0,0,0), (90,0,0), or (0,0,180).

I’m glad the knowledge is finally out there too. For some reason I’ve been googling this many times over the years and never saw a solution. Maybe I just wasn’t using the right words, but I think this should be easier to find with the words “Fresnel” and “Cylinder”.

2 Likes

This is pretty cool! Thank you for sharing!

Would this still give ok results on cylinders with one end scaled way down or way up (cone-ish shape)?

Yes, cones should also work.

1 Like