Home Technical Talk

[TUTORIAL] Object Angle Based Fade

Hey guys, I just wrote a quick guide about how to fade a object base on its angle, using Ue4, its useful for faking light shafts, glow and stuff using planes without making so obvious that its just a plane.


You can find the more details and a bit of explanation on the workflow on my website: https://rohmizuno.com/object-angle-fade/

If you want the fading to occur on the sides+top:


Just the to top of the object (scroll down for a alternative and lighter solution):



If you know a cheaper or alternative way to achieve the same result feel free to let me know here, or if you have any questions.



Replies

  • marks
    Offline / Send Message
    marks greentooth
    SurfaceOpacity = dot ( SurfaceNormal, CameraViewVector)
    Seems like it does very broadly the same thing 
  • Gannon
    Offline / Send Message
    Gannon interpolator
    very nice, brings back the feels from UE3 pick ups
  • Bruno Afonseca
    marks said:
    SurfaceOpacity = dot ( SurfaceNormal, CameraViewVector)
    Seems like it does very broadly the same thing 
    That's more of a fresnel opacity kind of thing, right? You can combine both for making more complex stuff :) Regardless I thing the dot product is the way to go:




    0,0,-1 in camera space means pointing towards the camera and the ObjectOrientation points to the object's z+ axis. If you get the dot product of both, you'll get 1 if the object's z+ is pointing towards the camera, 0 if it's perpendicular and -1 if it's pointing away.

    Abs turns the negative values positive, and Saturate clamps them between 0-1 so you can use either depending on what you want :smile:

  • rohMizuno
    yeah, Mark's solution does seems to be giving me some type of fresnel, maybe I am missing something?
    and thank for sharing that information @Bruno Afonseca I did not know you could use a 3vector like that (makes a lot of sense now that I think about it). It works great from fading the object from the top and it saves about 5 instructions :)
    How would you do about making it work on the front of the object?
  • S-ed
    Offline / Send Message
    S-ed polycounter lvl 10
    @rohMizuno Well, Vector is just an array of floats, [0,0,1] is a CameraVector, so [0,0,-1] is the opposite one.
    And yes, @marks solution would produce a fresnel (inverted), it also won't work for camera oriented sprites (their normal always aligned to the camera).
    Shortest version of what your second example was in the first post:

  • RN
    Offline / Send Message
    RN sublime tool
    I remember seeing a version of this effect in Half Life 2, it was a spotlight that transitioned between a beam and a flare depending on how it faced the camera. It's the lighthouse effect:
    https://www.youtube.com/watch?v=pZyo97Z73oM
  • rohMizuno
    I am just adding here something that F A I T H shared on twitter:

    "if you use dot product with exposed vector 3 parameter, you can then specify which axis to use in material instance per case:

    "

    I also updated my blog post with most of the information that you guys provided here, so thanks a lot for sharing and helping!
  • frmdbl
    Offline / Send Message
    frmdbl polycounter
    This will come in handy, in CE3 they had a funcion like that in the vegetation shader, which faced branch planes at
    high angles, making it less obvious that the trees were so low poly.

Sign In or Register to comment.