Fresnel reflective shading with Away3D

fresnel-awayFinally, something new! But no, it’s not any of the bigger things I’ve been hinting at before. However, I’ve been hard at work at those (and other) projects for months, and ended up with tunnel vision and an annoying rut. I really needed to do something smaller again for some immediate visual fun. When Bartek showed me something on Twitter, I decided to take a step back from all the work, dig up some half-year old code and finish it asap. And so I did: that is a Fresnel Pixel Bender shader for Away3D, presented in the FresnelPBMaterial!

I’ve explained it before, but I’ll give a more general explanation this time around. Fresnel shading mimics the way light reflects off of (often translucent) surfaces such as water or glass. Looking head-on, you can see its proper surface (or see through it with refraction). However, if seen from a shallow angle, it reflects light (just imagine looking over a large body of water, or the mirage effect on the road on hot summer days).

Demos

I’ve thrown together some rather random demos to illustrate the point. There’s source for both. (A word of warning: apparently, on some FP10.1 betas, Pixel Bender causes it to throw an invalid input exception, which seems to be bogus.)

  • Glass and marble head: Yes, the head appears to be floating in the middle of a cathedral of some blurry sort. Click to cycle through different property settings: glass, alien marble (I’m sure that’s a thing), and plain marble.
  • Water surface: Using an animated normal map to illustrate how water could be rendered while using the fake refraction. It also shows the WaterMap util.

Another word of warning: slight implementation details might change in the next few days/weeks, but it should be nothing too dramatic!

I’ll probably be doing something more with this when I have the time, but nothing that would likely make it to the repository :-)

9 thoughts on “Fresnel reflective shading with Away3D

  1. Beautiful! If this is what you get up to when you take a break, I can hardly imagine what awesomeness you are cooking up when you’re actually *working* on the future Away3D :)

    I always find a 200g bag of peanut MM’s (or even better Aldi’s cheap copy) can generally propel me out of the deepest, darkest coding psychosis. Great brain food.

    We await with bated breath for all the fruits of your labour.

  2. hey thx for the tip David!. I finally did my own model and normal map, now the problem is, the object works just fine including it as an AS3, but when Im trying to load a Collada exported Object, the material is set correctly, and UVMapped Correctly, but the fresnel effect is not aplied to all te object, only to specific part. any suggestion? :$

  3. sorry for posting that, I already figured out, in case anyone is interested, te key was checking the “invert x” on the prefab normal map generator. in my case a DAE didn’t need it. while the AS3 class did.
    regards!

  4. Pingback: More Fresnel fun in Away3D: through the looking glass | Der Schmale - David Lenaerts's blog

Leave a Reply

Your email address will not be published. Required fields are marked *