tags:

views:

165

answers:

1
+3  A: 

Just a guess based on doing a image diff (and without reading the rest of your question). The problem looks to me to be the refraction on the back side of the sphere. You might be:

  • doing it backwards: e.g. reversing (or not reversing) the indexes of refraction.
  • missing it entirely?

One way to check for this would be to look at the mount through a cube that is almost facing the camera. If the refraction is correct, the picture should be offset slightly but otherwise un-altered. If it's not right, then the picture will seem slightly tilted.

BCS
I tested, and I'm not missing the back of the sphere. I have code for handling back faces and inserting a print there issues scores of lines of output.I'm also sure that I'm computing eta correctly, the code I use is in my question. I've updated this code somewhat to use a stack of IOR values since posting it.I'll try looking at the mountain using a polygon, unfortunately I didn't implement cubes. Perhaps I could try two parallel planes?
fluffels
@fluffels I think BCS has a good point... looking at the first image and the correct image, the correct image shows the mountains bulging out as the effect of refraction, whereas your first image shows them puckering in. I'm sure you can see this but your comment "there are only a couple of errors, mostly around the poles" seems to miss this difference. It sure looks like something is reversed, but I have no clue what. (Also I don't understand the 4th sphere ... is it supposed to be in front of the others or behind?)
LarsH
@fluffels, two parallel plains would work: render with them an without them and check that the image just shifts slightly. Also be sure you have them pointing away from each other and not in the same direction. I've looked at the eta computation you posted and it seems to asymmetric. I would expect the code for entry and exit to be almost identical, maybe with just two terms swapped from one to the other.
BCS
@LarsH I added some more images that hopefully explain the nature of the scene.
fluffels
@LarsH I get what you mean about that distortion. But I don't know what to do about it. I've tried flipping normals, eta values, everything.
fluffels
@BCS Eta's calculation will be symmetric only if the ray is entering an object and then leaving it again. When objects start being included in each other and intersecting (as the 'extra' sphere in this scene does) then things get more complicated. AFAIK eta = eta1 / eta2 where eta1 is the IOR of the "from" substance and eta2 is the IOR of the "to" substance.
fluffels
@BCS The problem with the parallel planes is that NFF only supports one-sided polygons, so I can't make it point away from me - the way the algorithm works in this program will not see that as an intersection. I'll try with two polygons looking at me and see if that's in any way illuminating.
fluffels
@fluffels: re eta: Your comment leads me to believe that it *should* be symmetric: compute `eta1` for the object you are at the surface of, compute `eta2` for the surrounding object: `eta = !Entering ? (eta1/eta2) : (eta2/eta1)` (this gives a corner case for non-point coincident surfaces).
BCS
As far as I understand refraction, eta1 and eta2 should be swapped around in your formula. Why do you believe it should be symmetric? If a ray is travelling through a sphere with an IOR of 1.3 and enters one with an IOR of 1.5 then eta = 1.3 / 1.5 where it was 1.0 / 1.3 previously when the ray entered the first sphere. Or is this not correct?
fluffels
@Fluffels: The symmetric bit is in the general equations, not the specific values. For a ray travailing from a sphere with 1.3 and exiting into a sphere with 1.5, eta is 1.3/1.5 i.e. `A/B` for `A` = the IOR of the object who's surface we are intersecting and `B` = the IOR of the "other" object. For the other case, entering the same sphere, from air: eta is `1/1.3`, i.e. `B/A` with A and B similarly defined (B in the 1st case is another sphere and in the 2nd air). Keep in mind that this will give very strange results if you have two or more intersecting surfaces of solids with `IOR_a!=IOR_b`.
BCS