# PBR : Understanding the right part of Split sum integration of specular IBL

This is the website I am learning from.

In the specular part of IBL this is the split sum approximation Now the left part of the equation I have asked in This post and I have understood everything now this question is about the right part.

On simplifying the right part of the equation with the procedure shown in the website we get this And on translating this to code we get this 1)What is the V vector? How did they compute that

2)Why have they assumed N=(0,0,1)?

3)why is NDotL=max(L.z,0)? How did they simplifying a dot product to an min/max Operation same question I have for NDotH

4)G_Vis=GVDoth/(NDotHNDotL) why the division by (NDOTH*NDOTL)? that was nowhere in the equation.

5)what is vector L? it looks like they have reflected vector V about H to get this but why?

These are just some of the questions I have come up with so far but if there are any other important parts I should not know about A general explanation on how they derived this code would be appreciated

1)What is the V vector? How did they compute that

It's the vector toward the camera (view vector), i.e. direction of the reflected ray. The lookup table they're building is parameterized in terms of NdotV, so they are working backward from NdotV to obtain a corresponding V vector. For purposes of doing this integration it doesn't matter what N and V are exactly, just that they have the correct NdotV. So, just to make things concrete, they assume that $$N = (0,0,1)$$ and V is aligned with the positive x-axis (i.e. in the positive xz half-plane). Then you have $$V = (\sin θ, 0, \cos θ)$$ where θ is the angle from N to V (this is just the equation for a circular arc from z down to x). Now $$N \cdot V = \cos θ$$, so by a standard trig identity $$\sin θ = \sqrt{1 - \cos^2 θ} = \sqrt{1 - (N \cdot V)^2}$$.

2)Why have they assumed N=(0,0,1)?

This whole thing is a pre-integration of the BRDF alone, it doesn't depend on any scene or lighting environment. So it doesn't matter where the BRDF is or how it is oriented in space, only the relative orientation between the N, L, and V vectors is important. So just for the sake of convenience they have chosen to fix N = (0, 0, 1), let V vary only in the xz half-plane as mentioned above, and let L vary over the whole hemisphere. To put it another way, they have chosen to set the coordinate system to be aligned with N and V.

3)why is NDotL=max(L.z,0)? How did they simplifying a dot product to an min/max Operation same question I have for NDotH

Since N = (0, 0, 1), dotting N with any vector just takes the z component of that vector. $$N \cdot L = 0L_x + 0L_y + 1L_z = L_z$$. (This is why it's convenient to assume a coordinate system in which N = (0, 0, 1).) Taking the max with 0 clamps it to the upper hemisphere, otherwise the dot product would go negative if the vector happens to be pointing below the hemisphere. This clamp is a standard thing to do when dealing with opaque BRDFs to avoid accidentally getting unwanted negative values in your calculations— although it is not really necessary here since they check if (NdotL > 0.0) immediately afterward.

4)G_Vis=GVDoth/(NDotHNDotL) why the division by (NDOTH*NDOTL)? that was nowhere in the equation.

It is a standard part of the microfacet BRDF formulation: $$f_r(p, w_i, w_o) = \frac{DFG}{4(\omega_o \cdot n)(\omega_i \cdot n)}$$ Note that $$\omega_o = V$$, and $$\omega_i = L$$, these are just different notations/names for the incoming and outgoing light vectors. However I think there is a typo in the code, the denominator should contain NdotV rather than NdotH. I am also not sure why there is a multiplication by VdotH in the numerator, or where the factor of 4 went, but perhaps they have accounted for it elsewhere. I would probably double-check the BRDF equations here against some other sources as I don't think it's entirely correct.

5)what is vector L? it looks like they have reflected vector V about H to get this but why?

As noted, L is the vector toward the incoming light. H is the "half-angle" vector exactly halfway between L and V, so reflecting V around H will give you L, or vice versa. The significance of H is that in microfacet BRDFs, it is the normal vector of those microfacets that are "active" for a given L and V. So, to importance-sample a BRDF, we sample a random normal vector from the NDF, and use that as H. Since H and V are specified, we then calculate L from those.

I recommend to ignore my post (however I consider papers that I've sent valueable) and read post of Nathan Reed, which is much better in explaining this problem!

I'm still a junior when it comes to computer graphics so you may want to take my opinion with a grain of salt:

To start with - I used to learn/implement stuff using website that you've sent (OpenGL) and I don't recommend that. After few months of learning I knew barely anything. Then I start reading original papers and implementing them on my own to better understand PBR, what N * G * F means in Cook-Torrance shading model and I got much better understanding of basics. I was recommend by many graphics programmers to avoid tutorial pages and straight read and implement papers. In case if you don't understand something in the paper you're reading, you found paper on subject that you don't understand and read about it.

1). As I said - avoid this site or use only to get interesting papers - here are original notes from [Karis2013] UE4 presentation - https://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf ; Please notice comment "/sin" "/cos" in listing at page 7 and usage of Pythagorean trigonometric identity. Maybe it's position on the hemishpere, I don't really want to dig in, I'm sorry. But I would recommend checking Epic Games repository on Github if you want to see how they're using it.

2.) In the same paper [Karis2013] there is listing at the page 4. and function ImportanceSampleGGX. It uses N to determine orientation of the world and returns either float3(0,0,1) or float3(1,0,0) based on N.z value.

3). $$N = (0, 0, 1)$$ $$L = (x, y, z)$$ $$dot(N, L) = (0 * x, 0 * y, 1 * z) = (0, 0, z) = L.z$$

http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html