refraction

Started by
12 comments, last by Koen 20 years, 11 months ago
Well, the rays are definetly not going in the right direction, but that''s all I can say for sure.

-~-The Cow of Darkness-~-
-~-The Cow of Darkness-~-
Advertisement
sorry i should read better i suppose.

anyway if you have the refraction value of your sphere, break towards the normal when entering, and away from it when leaving the sphere, accoring to the formula. you knew that much i suppose, but it looks a bit like you inverted breaking towards the normal and breaking away from it.
i doubt the problem is the normal youre using. how hard can it be to calculate the normal on a sphere? maybe show some code so we can have a look at it?
Something was wrong with the scene: the index of refraction was 1.5 for the glass. Oops. I''ve set it to 0.54, and this results in http://www.student.kuleuven.ac.be/~m9817401/snapshot3.png
Still not correct. The code used to compute the refracted direction (inDir points away from the surface):

Vec3 PhotonCasting:erfectRefractedDirection(const Vec3& inDir2,const Vec3& normal2,const complex& indexIn, const complex& indexOut) {	Vec3 inDir=inDir2;	Vec3 normal=normal2;	inDir.normalize();	normal.normalize();	double zi = inDir & normal;	class Vec3 inortho = zi * normal;       // component orthogonal surface	class Vec3 inpar = inDir - inortho;     // component in tangent plane	double n = (zi > 0.) ? indexOut.r / indexIn.r : indexIn.r / indexOut.r;	double zo2 = 1. - (1. - zi * zi) * (n * n);	return (zo2 > 0.)		? ((-n) * inpar + ((zi > 0.) ? -sqrt(zo2) : sqrt(zo2)) * normal)		: (-inpar + inortho);                 // total internal reflection 
well... the refraction of the raytracing looks fine, right? so... if you can get it right for the raytracer, why not for the photons?

This topic is closed to new replies.

Advertisement