• Create Account

### #ActualBacterius

Posted 13 December 2012 - 07:37 PM

hitInfo.surfaceNormal = (hitInfo.hitPoint - c) * 2; // is this correct?

That surface normal is incorrect. The correct one is:

hitInfo.surfaceNormal = normalize(hitInfo.hitPoint - c);

Or, alternatively, to potentially trade some accuracy for speed:

hitInfo.surfaceNormal = (hitInfo.hitPoint - c) / radius;

You also need to normalize the vector between the light source and the hitpoint, in your shading code.

Remember the cardinal rule of ray-tracing: if in doubt, normalize. The vectors which need to have a non-unit magnitude are few and far in between and are usually obvious.

### #1Bacterius

Posted 13 December 2012 - 07:35 PM

hitInfo.surfaceNormal = (hitInfo.hitPoint - c) * 2; // is this correct?

That surface normal is incorrect. The correct one is:

hitInfo.surfaceNormal = normalize(hitInfo.hitPoint - c);

Or, alternatively, to potentially trade some accuracy for speed:

hitInfo.surfaceNormal = (hitInfo.hitPoint - c) / radius;

You also need to normalize the vector between the light source and the hitpoint, in your shading code.

PARTNERS