Monday, July 12, 2010

LO-SL BRDF Explained...

...sort of. As the screenshot persists, I'm still tinkering on BRDF. I turned off other effects including shadows so I have a better feel on what I'm doing. Its better to reduce our parameter control points, otherwise we'll end up alchemisticly mixing one variables or attributes to another (which I often do), the outcome is we less understand the result and we'll ultimately waste time. In my approach on BRDF, I use the same concept in breaking down this function into true realtime game application. Before I expound on this, I must explain first what BRDF is (as I understood it).

Bidirectional Reflectance Distribution Function or BRDF means, in its literal meaning, 2 direction composing how light reflection is distributed on the surface of a material. These 2 direction are light direction towards the surface, which is the 'IN' hence they call this 'incident light', and eye-to-surface direction or view direction, which is the 'OUT' or they this called 'reflectance'. Each type of material surface reacts differently with light. This reaction is more of a distortion of the light. Because of this distortion, we perceive textures and colors reflecting directly or indirectly from objects. If its a reflection of light, this means if the surface is perfect flat, the reflection can be off when it hits our eyes. Of course this perception is based from the characteristics of the light we use. You lit a red light, we see red light blending on the surfaces. A very good example is shooting a billiard ball on table sides, the direction of the force will determine how it will react on the side wall texture and will ultimately bounce after some energy distortion or absorption. And also by its result will show how far will the ball be off from the hole.


This diagram is based from Oren-Nayar reflection model. Here is a very informative link of a series of lectures regarding reflectance and other photometric phenomenon.


Now here comes the technical part. In order for a BRDF to be used in graphics rendering, typically, one would need the following, light direction, view direction, normals and tangents. Addition to that, we need to have the Theta and Phi of both Incident and Reflectance light as we are dealing with 3D angles called Solid Angles.

My implementation is composed of 2 ideas/theories in reducing the Function's complexities.

The first part is 'LO' or Light Oriented,  to reduce the required data, everything will be oriented to Phi Incident direction. With this, we do not need the tangents and (considering we do not care about subsurface scattering) we just add the Phi Incident to the Phi Reflectance. By doing so, we reduce 1D of the BRDF dimension requirements. We then assume that the Incident light on the Phi angle is perfectly aligned to the Oren-Nayar model. With the sum of Phi Incident and Phi Reflectance angles we still have almost to perfect similarity of light distortion/absorption as compare to the complete function.

The second part is 'SL' or Spike and Lobe theory. The standard illustration of 'light lobes' of this function is always against the light direction. In my theory, I use the functions lobe and spike but this time, not only against the light but also towards it. This lobe represents how much energy/light was absorbed and bounced by the surface before it reflects light.

This data is then stored somewhere, it can  be a N.L/N.H lookup table like in STALKER in GPU Gems or for Lafortune lighting model (using a matrix to mimic distortion of light). In my implementation I used the flattening of Phi Incident/Phi Reflectance, which I hope to explain on later posts.

So there you have it, Light Oriented - Spike and Lobe BRDF implementation.... (batteries sold separately). Kinda' neat-o-burrito aye?

Btw. regarding the screenshot. I just guessed the BRDF parameters hence the '?' on the labels. hehehhe

Friday, July 2, 2010

Fast Diet "LO-SL" BRDF


After a long absent from my blogging, I'm finally back for some graphics goodies! As you may notice in the screenshot, I'm doing some BRDF or Bidirectional Reflectance Distribution Function magic. This past few days I was in deep photometry(optics) waters... dived and almost drowned. Anyway back to the topic at hand, BRDF in a nut shell is a formula or process in understanding how light reacts differently to different material. Example is when a light beam hits a matte material such as leather, the light is diffused along the material, thus spreading the light into the surface. Compare this when you do that to a mirror, the light instead of being diffused it reflects the beam and you see a contrasting(not spread) lit in the mirror. Another example is when a white light hits a prism, it splits into visible chroma colors.

Now the tricky part here is implementing this to games. Considering so much computations are involved in BRDF, its likely impossible with our current technology to perform a full BRDF applied on a real-time game. Several games and game engines came up with tricks and simplifications to try to mimic this function.

So put it simply, this is my humble attempt in implementing BRDF into a real-time application. As of now, this screenshot is fresh from the oven. And right now, I cannot disclosed how I implemented this. (Need some permission from the big 'squirrel' guy, lolz). Anyway, I hope to follow up on this when the coast is clear.