## Soft Shadows and Glossy Surfaces

I spent a lot of time to get the glossiness working and finally I got the glossiness correctly as in the below image. I used random sampling for the soft shadows - using which I am getting a better soft shadows. Earlier, for glossy reflection, I was not getting convincing results - seems there was something wrong with my sphere sampling technique. I tried various ways to do the sampling but all are giving, more or less, same results but it didn't work out. Later on I finally figured out why it wasn't working.

Sampling used for above Image*:

r1 = RandomNumber(0, 1);

r2 = 1 - r1;

phi = 2 * M_PI * r1;

theta = acos(1 - (2 * r2));

x = 2 * radius * cos(2 * M_PI * r1) * sqrt(r2*(1 - r2));

y = 2 * radius * sin(2 * M_PI * r1) * sqrt(r2*(1 - r2));

z = radius*(1 - (2 * r2));

Sampling used for above Image^:

r1 = RandomNumber(0, 1)

r2 = 1 - r1

z = 1 - 2 * r1;

radius = radius * sqrt(1 - (offset.z * offset.z));

theta = 2 * M_PI * r2;

x = radius*cosf(theta);

y = radius*sinf(theta);

No. of Samples per pixel - min = 8, max = 64

Threads = 10

Reference

System Information

CPU : Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz

Memory: 32 GB DDR3 @ 1600 MHz

GPU: NVIDIA GeForce GTX 970M