Thursday, April 16, 2009

Hatch marks

What's up with those hatch marks? Is my sphere just too dark? Should I pick light grey instead of almost black? I dunno.

I've picked three variables to change and see when the hatch marks show up:
  1. Are the refracted rays rendered?
  2. Is the diffuse component rendered?
  3. Are the reflected rays rendered?


Image Refract Diffuse Reflection Hatching
no no no no
yes no no yes
no yes no no
yes yes no yes
no no yes no
yes no yes yes
no yes yes no
yes yes yes yes


Only when refraction is enabled do we see the hatch marks. This narrows it down to the following:

  1. Specular highlights
  2. Direction of refracted ray
  3. Fresnel term
  4. Tone mapping
  5. And probably about 10 other things


Things that did not remove the hatch marks:
Removing tone mapping
Removing specular highlights

Removing the specular highlight does not remove the hatch marks. I'm not going to bother posting a pic. It looks like the sphere with everything enabled, just no specular highlight.

Tuesday, April 14, 2009

Changing from floats to doubles

In an attempt to remove some of the banding I'm seeing, I've changed from floats to doubles:

Index of refraction 1.33, double precision floating point:


Index of refraction 1.33, single precision floating point:


Difference image of the two:


The banding is gone, but now I'm seeing some ellipse shaped dark spots that I didn't expect to see.

The next three images use an index of refraction of 2.69.

Double precision:


Single precision:


Difference:

Friday, April 10, 2009

Fixed Phong shading

Here are the results with the fixed Phong shading:
Index of refraction 1.33, camera farther:

Index of refraction 1.33, camera closer:

Index of refraction 2.69, camera farther:

Index of refraction 2.69, camera closer:

I don't like the amount of noise in these images. There are 512 samples per pixel. A relatively lame sample selection process is being used: lay them all out on a regular grid and use a random number generator to jitter the samples within their grid boundaries. This doesn't seem to be any better than simply choosing 512 pixels laid out on a regular grid.

Thursday, April 9, 2009

Carefully checking math

Turns out that I was a bit sloppy with my Snell's law implementation. Here are some new images that look a bit more correct:

Index of refraction: 1.33, camera farther

Index of refraction: 1.33, camera closer

Index of refraction: 2.69, camera farther

Index of refraction: 2.69, camera closer


That blue square is a messed up specular reflection. Looks like I might be a bit sloppy with my Blinn-Phong model, too.

Clamping reflection power

Here are images using the same code as before, but with the reflection power clamped to 1.0:

Index of refraction 1.0 to 1.0:

Index of refraction 1.0 to 1.33:

Index of refraction transition from 1.33 to 1.00


What's up with that light blue square? Is that a crappily rendered specular highlight?

Ok, back to reflections. These images look much better to me, but I'm not sure if they are correct. I expect a large reflection in the 1.33 image as it is sitting over an infinite plane.

Adding a Fresnel term

I've attempted to add a Fresnel term to the dielectric.

To start, I rendered a sphere with an index of refraction of 1.00, no Fresnel term, no reflections:


Here's another sphere, no reflections, index of refraction 1.33:


Now with a Fresnel term, index of refraction 1.00:



Also with a Fresnel term, index of refraction 1.33:


Those last two images don't look quite right. The reflections are way too strong and are pretty blown out.

I believe that I'm using the equations at http://en.wikipedia.org/wiki/Fresnel_equations to add the Fresnel term.

Tuesday, April 7, 2009

Dielectrics

Here's a couple of images of a pieces of "green glass." In this first image, both mediums have an index of refraction of 1.0:

In this next image, the index of refraction starts as 1.00, but then changes to 1.39:
Reflections are currently not implemented. Notice where total internal reflection begins? Notice how the rays are bent away from the viewpoint? This is what I would expect when the index of refraction becomes greater.

Here's an example where the transition is from 1.39 to 1.00:
Notice how the rays are bent towards the viewpoint?

I suspect that these images may be correct, well, as correct as they can be without implementing reflections and using a Fresnel term to make sure that energy is conserved.

I'm using Snell's law to calculate the direction of the refracted rays