Hot answers tagged

51

Short answer: Importance sampling is a method to reduce variance in Monte Carlo Integration by choosing an estimator close to the shape of the actual function. PDF is an abbreviation for Probability Density Function. A $pdf(x)$ gives the probability of a random sample generated being $x$. Long Answer: To start, let's review what Monte Carlo Integration ...


30

To start, I highly suggest reading Naty Hoffman's Siggraph presentation covering the physics of rendering. That said, I will try to answer your specific questions, borrowing images from his presentation. Looking at a single light particle hitting a point on the surface of a material, it can do 2 things: reflect, or refract. Reflected light will bounce away ...


23

I was actually wondering about exactly this a few days ago. Not finding any resources within the graphics community, I actually walked over to the Physics department at my university and asked. It turns out that there are a lot of lies we graphics people believe. First, when light hits a surface, the Fresnel equations apply. The proportions of reflected/...


16

I'm sadly not able to add a comment to the answer above (not enough reputation), so I will do it like this. I'd like to point out that what Dragonseel describes is simply an integral equation (specifically a Fredholm equation of the second kind). There are many such equations which do have an analytic solution; even some forms of the rendering equation have ...


14

There are a couple of ways to answer this question: an algebraic way and a geometric way. Algebraically, we can identify the units that the BRDF must have by looking at its place in the rendering equation. The classic rendering equation is: $$L_\text{outgoing}(\omega) = L_\text{emitted}(\omega) + \int_\Omega L_\text{incoming}(\omega') \, f_\text{BRDF}(\...


14

The rendering equation is as follows: Now, the integral is over the sphere around the point $x$. You integrate over some attenuated light, incoming from every direction. But how much light comes in? This is the light $L(x',\omega_i)$ that some other point $x'$ reflects in the direction $\omega_i$ of point $x$. Now you have to calculate how much light that ...


14

Using two Fresnel terms is correct in the sense that any given diffuse path will pass through the surface twice. If you're solving diffusion by tracing a path through the medium until it bounces out again then that you will get two (or more) Fresnel terms for that path as it interacts with the surface. However, that's not what you're doing with a diffuse ...


13

I am posting this for anyone wondering about the confusion between the terms $\frac{1}{\pi}$ and $\frac{1}{4}$. The term $\frac{1}{\pi}$ is an error from the original Cook-Torrance reference. In fact, the whole term $\frac{1}{4(n \cdot \omega_i)}$ comes from the Jacobian of the transformation from reflected solid angle to normal solid angle. According to ...


12

According to this paper, the $\frac{1}{\pi}$ in your $f_r$ should be $\frac{1}{4}$: $$ f_r = \frac{DFG}{4(n\cdot w_i)(n \cdot w_o)}, $$ so you would end up with $$ \frac{\pi}{2}L_i(p,w_k)\left(\frac{DFG}{n\cdot w_o}\right). $$


11

If you have a 1D function $f(x)$ and you want to integrate this function from say 0 to 1, one way to perform this integration is by taking N random samples in range [0, 1], evaluate $f(x)$ for each sample and calculate the average of the samples. However, this "naive" Monte Carlo integration is said to "converge slowly", i.e. you need a large number of ...


10

Here's a chromaticity diagram that includes a projection of the sRGB color space: a triangle whose vertices are red (1,0,0), green (0,1,0), and blue (0,0,1). Encoding the reflectance of a surface as the color at F0 and getting a value that is outside of the (somewhat arbitrary chosen) sRGB gamut is totally reasonable. It just means that gold is "more red" ...


10

It's a geometric assumption like the other two. Consider a flat macrosurface. Its projected area in any direction $v$ is just $v\dot\ \hat N$ times its area (where $\hat N$ is the surface normal). In particular, the case where you're looking at it along the normal is simplest: the projected area is equal to the area of the surface. Now split the ...


9

First off, this is probably not the best way of testing energy conservation, because not all incident inclinations are visible in the image. Most of the environment is also black, so a less "peaky" BRDF such as Lambert would come out very dark with no way of telling whether it's energy conserving or not. What is more commonly used is a so-called "furnace ...


9

The polar coordinate system commonly used in BRDF definitions is set up relative to the surface being shaded, i.e. in tangent space. The $\theta$ angle measures how far you are from the surface normal while $\phi$ is the azimuth around the plane of the surface relative to some reference direction (which doesn't matter unless the BRDF is anisotropic). So if ...


9

RGB color is a bit more complicated a subject than readily seems apparent. The reflectance wavelength diagram shows the reason quite well actually. RGB color model has several central problems: What the colors represent: They represent 3 spikes in a continuous spectrum. The R, G and B aren't energetically equivalent let alone evenly spaced. What their ...


9

As you already note, there is no clear cut interpretation/conversion for these values. I think it is even much worse: Depending on your BRDF and internal limitations (like having defined exponents ranging from 2-2048) the interpretation is completely different. Like suggested in the comments, it might be the best to render a series with different values and ...


9

In general the two directions in BxDF are incoming $\omega_i$ and outgoing $\omega_o$ radiance directions, often defined in spherical coordinates $[\theta, \phi]$ or as a 3D unit vector in Cartesian coordinates $[x, y, z]$. The BxDF $f(\omega_i, \omega_o)$ defines how much of the incident radiance $L_i$ from direction $\omega_i$ hitting the surface is ...


8

While browsing to properly write my question, I actually found the answer, which happens to be very simple. Another Fresnel term is also going to weight in as the photons make their way out of the material (so being refracted into the air) and become the diffuse term. Thus the correct factor for the diffuse term would be: $$(1 - F_{in}) * (1 - F_{out})$$


8

To my knowledge, there is no easy and analytic way of recovering the energy lost in single-scattering models. The previous techniques precompute the energy loss and reinject it in the BRDF as a diffuse-like component: http://sirkan.iit.bme.hu/~szirmay/scook.pdf http://www.cs.cornell.edu/projects/layered-sg14/layered.pdf What they propose is energy ...


8

The concept of a point source is an approximation. Physically, light sources are extended objects and emit light from every point on their surface; but when you're far enough away (i.e. the distance to the source is large compared to its size) it's useful to approximate it as a point source. You can get the $1/r^2$ law out of it as follows. Imagine a ...


8

Using physically based BRDFs only makes sense if your entire pipeline is built for physical units - the extreme range of values can't be displayed properly without some form of tone mapping. You didn't include that part of the code but from the looks of it I'd say you're doing a simple clamp() followed by linear->sRGB conversion, which causes the bad ...


7

The Fresnel coefficient should be evaluated using $H$, not $N$. You wrote, I have trouble seeing why we can still use that formula in a BRDF, which is supposed to approximate the integral over all the hemisphere. It's not. The BRDF in itself does not approximate the integral over all the hemisphere. The rendering equation does that: you integrate over ...


7

In Schlick's 1994 paper, "An Inexpensive Model for Physically-Based Rendering", where they derive the approximation, the formula is: $$F_{\lambda}(u) = f_{\lambda} + (1 - f_{\lambda})(1 - u)^{5}$$ Where So, to answer your first question, $\theta$ refers to the angle between the view vector and the half vector. Consider for a minute that the surface is a ...


7

this is an interesting question (and I am actually an author on Scratchapixel so I can maybe help on that one)). Things go as follows: you cast the primary ray into the scene the ray hits the glass which is a refractive-reflective/transparent material you compute and cast two rays from the point of intersection: a reflective ray and a refractive ray if ...


7

Yes, because refractive index can vary with wavelength. This is the origin of colored specular reflection in metals such as gold and copper; most other materials have essentially uncolored specular. At each wavelength, the specular reflectance at normal incidence is related to the refractive index at that wavelength according to the formula you mentioned. ...


6

TL;DR Yes, you can do it like that, you just have to divide the result by the probability of choosing the direction. Full Answer The topic of sampling in path tracers allowing materials with both reflection and refraction is actually a little bit more complex. Let's start with some background first. If you allow BSDFs - not just BRDFs - in your path ...


6

The goal of Heitz et al.'s model is pretty much the opposite of subsurface scattering: They only consider surface scattering, i.e. the ray can never enter the material. Because microfacets are statistical in nature, they can recast their problem in such a way that it can be solved by microflakes, which allows them to compute properties such as the mean free ...


6

When you perform regular Monte Carlo integration over a hemisphere using $N$ samples, each sample represents $\frac{2\pi}{N}$ steradians. So the Monte Carlo integration for Lambertian BRDF is: $$\frac{2\pi}{N}\sum_{i=1}^N\frac{\rho}{\pi}L_i*Cos\theta_i$$ For path tracing, you only take one sample per path segment, so because $N$=1, the above sum becomes: $...


6

I think I got it! Because $cos(\theta)$ integrates to $\pi$ over the hemisphere (and not $2\pi$). And the incoming light is multiplied by $cos(\theta)$ (and the BRDF).


6

You can combine Oren-Nayar with GGX, if your normalize the result. A BRDF is defined by two properties: Helmholtz reciprocity and energy conservation. $f(l_i, l,_o) = f(l_o, l_i)$ $f(l_i, l_o) \leq 1$ Your Oren-Nayar is the diffuse part $f_d(l_i, l_o)$ and your GGX is your specular part $f_s(l_i, l_o)$. If both are energy conserving, then both are at most ...


Only top voted, non community-wiki answers of a minimum length are eligible