dipityPix app

Friday, July 31, 2015

Is copy and paste a net time saver?

Many programmers have advocated disabling copy and paste because the resulting errors can be so painful.   That indeed was the source of this lack of total internal reflection in the little cube from an earlier post:

The photo on the left has a strong internal reflection at the bottom of the cube
I tracked a bunch of rays and it turned out the total internal reflection was occurring, but the polarization transformed wrong.   This code:

            r_s = 1-r_s;
            r_p = 1-r_s;

Should have been

            r_s = 1-r_s;
            r_p = 1-r_p;

Such typos are often so deadly because they take things in range (0-1 in this case) and keep them in range.  Fixing this at least has hit that most glaring problem (the sphere looks a bit better too):

Thursday, July 30, 2015

Yet another renderer validation experiment

Now that I have polarization orientation on the iPad right I did another crude experiment.

Left: photo, Right:rendering
There is one glaring difference: the reflection at the bottom of the cube the ball is sitting on.   It looks like total internal reflection in the photo and definitely not in the rendering.   Could be uncareful position calibration and could be refractive index error in the input.   Or of course bug in the renderer.   Looks like to go further I will need to do a very careful scene setup, and use a camera that has raw output (sadly the iPhone doesn't as far as I know).

Question: what is the best BRDF model for materials such as glossy paint?  My first impulse is to go use the Disney model, but I bet there is something specific for architectural materials that is used in practice these days?

Wednesday, July 29, 2015

Testing near Brewster's angle

Yesterday's picture had specular reflections that were way off.  I tried a bunch of tests on my Fresnel equations and they seemed ok.   I tried Brewster's Angle for the glass and this found one big problem: my model!   Note that with LCD screens, no polarizers are needed to see Brewster's angle in action!  Here's two photographs of the iPad at Brewster's Angle:

The ipad produces almost perfectly polarized light, and at Brewster's Angle only one of the polarizations is reflected.   By rotating the iPad you can change the polarization of the incident light 90 degrees.
It occurred to me that maybe I just had the polarization 90 degrees wrong in my input model.   That definitely is one of my problems!   So more complete testing tomorrow.
Rendered images.   Left: my incorrect input with polarization exactly wrong.   Right: fixed model.   Not exactly at Brewster's angle so some reflection is visible.

Tuesday, July 28, 2015

First validation with polarization

As can be seen on the left (photo), LCD screens like on this iPad 1 are fully linearly polarized.  The big black disk is a linear polarizer rotated 90 degrees from the screen.   My first attempt at a serious polarized rendering has some obvious problems!   Could be the polarization infrastructure is wrong.   Or the Fresnel Equations.   Or both :)    I'll start by trying Brewster's angle tests tomorrow.

Left: photo.   Right rendering.   Lots of problems!

Monday, July 27, 2015

Measuring refractive index of a sphere

I wasn't sure my sphere was simple glass and from what I see on the web it could be anywhere from refractive index 1.5 to 1.7.   I did a reasonably measured scene to just match it visually (the lighting doesn't matter just the ray bending) and got:

Index is around 1.55.   I don't think more resolution is likely with this method
Nick P suggested I use a laser pointer and that would have been easier and more accurate.   Wish I read that first :)   I'll try it on the glass sheet.

Another step toward validation

My progression toward a sufficiently accurate renderer continues.

There are some known problems with my renderer/scene/camera before we even start:
  • The scene is too dim for the iPhone camera (so ironically the renderer is not noisy enough)
  • Sensitivity of the camera not modeled
  • The spectral curves of the iPad are just a poor guess
  • No polarization (the iPad emits polarized light)
  • The iPad is being modeled as a diffuse source but its brightness should vary with angle.
  • I just guess the refractive index of the glass plate and ball (1.5)
  • Camera fov and position just in the ballpark.   View direction way off.
Left: rendered image.   Right: photograph.

Saturday, July 25, 2015

A first step toward validating a renderer

I just set up a small environment, bought a macbeth color checker, and a glass ball (amazon).   No light source setup (just a white background), no camera calibration, no refractive index estimation.  

Real scene, photographed with iPhone 6+, random room illumination
First rendering