Skip to main content
gamedev.net
🔒 Locked

A basic ray tracing question

Started by Journey Jan 5, 2007 at 3:52 AM 3 replies 600+ views
Original Post
Journey
Journey
I've been developing this ray tracer for oil exploration research for more than a year now. It works fine. But I just wanted to clear something up. Basically the ray tracing algortihm works by "sweeping" the underground layers of terrain with rays of shock waves from an explosive (equivalent to light waves from a light source) 180 by 180 degrees, essentially making it a half sphere. The rays get refracted through each layer and reflect from the lowest layer finally back to the surface according to Snell's law, to be detected by a set number of receptors on the surface. The problem is that the further away the layers are from the explosive, the further apart each ray is from each other. And so the lower layers will receive a lower density of rays than the upper layers closer to the surface and the explosive. To minimize this the best I can do is to make the "sweep step" as small as possible, but the problem remains as the layers below still receive less rays than the upper ones. Is there a way to somehow calculate the reverse of this algorithm so I can part directly from each point at each layer at set U,V intervals (tracing the ray backwards) to the explosive, discarding any rays that don't arrive back at the source? ray tracer Bear in mind that this is my first ray tracer, and all the algorithms, including the surface instersection for bezier surfaces, were developed from sratch by myself, with little to no previous research on ray tracing due to time constraints.
JuNC
JuNC
Its quite normal to get what you're getting, what sampling strategy are you using? A cosine distribution around the 'down' direction might work better (so the lowest layer directly under the explosion gets a correspondingly higher number of rays. Upper layers will always get a higher density of rays though :)

What you could perhaps do is use a more probabilistic approach and rather than have every intersection of the ray, instead decide at each intersection whether the ray is refracted or not.

Is the shock wave transport reversible like light transport? If so then you *can* then trace backwards from the receptors (indeed, this might actually be a very good use for bidirectional path tracing or metropolis transport).

Sorry to answer with more questions, but the solution is going to depend very much on the properties which you're trying to model and the more sophisticated light transport algorithms might not be appropriate.

[edit]
I must say though that this is a really interesting application area!

A little digging turned up Rayleigh's "reciprocity principle of sound", so I guess you could use BPT :)
[/edit]

Bidirectional path tracing basic idea: Trace a set of paths, both from the emitters and receivers. Then form complete paths by joining subpaths to each of the others. It's not quite that simple because you have to do it probabilistically to avoid a massive explosion of compute power (and to avoid low-contribution paths). What exactly are you measuring at each receiver? I'm guessing its the average power of the shock wave, which gets attenuated as it passes through each layer and at each refraction/reflection point?

[Edited by - JuNC on January 5, 2007 5:34:05 AM]
Journey
Journey
Original post by JuNC

Is the shock wave transport reversible like light transport? If so then you *can* then trace backwards from the receptors (indeed, this might actually be a very good use for bidirectional ray tracing or metropolis transport).
quote]

Well I'm not a physicist, but as far as I was told by the gophysicists at the company I work for there's no mayor difference in the way shockwaves behave in comparison to light waves (apparently there is some non linear behavior in shock waves when reflection angles exceed 40 degrees when underground, and I'm not sure if light waves are composed of P and S waves too), so it'd be interesting to know more about those methods you mention. If you could explain a little more about them or point me to an article I would greatly appreciate it :)


Original post by JuNC

Its quite normal to get what you're getting, what sampling strategy are you using?
quote]


I'm not quite sure what you mean by "sampling strategy" so I'm not sure if I'll answer correctly :S. What do exactly are you refering to?

Basically what I do is take a vector and rotate it in small steps in a span of 180 degrees in "2D" and then do the same but rotating that "sweep plane" again in small steps in a span of 180 degrees in "3D". Each vector is intersected with the surface (a minuscule plane sampled procedurally through subdivision by the intersection algorithm), refracted according to the refraction index of the medium of the layer, and done so again recursively until I get back at the surface (the condition only changes at the lowest layer, where the ray is reflected instead of refracted in order to get back up)



Original post by JuNC

What you could perhaps do is use a more probabilistic approach and rather than have every intersection of the ray, instead decide at each intersection whether the ray is refracted or not.

quote]

Not sure what you mean by probabilistic. There is a test though to decide whether the ray gets refracted or reflected at each intersection, but not both (which is what happens in real life), as unlocking this would let loose the algorithm and rays would shoot off infinetly (the refraction of the reflection of the refraction ad infinitum...). The test says all rays are refracted but in the lowest layer, when it is reflected, and then it's refraction all the way to the top.



Original post by JuNC

A cosine distribution around the 'down' direction might work better (so the lowest layer directly under the explosion gets a correspondingly higher number of rays. Upper layers will always get a higher density of rays though :)

quote]

"cosine distribution around the 'down' direction" Don't entirely undestand what you mean there either, sorry :S



Original post by JuNC

I must say though that this is a really interesting application area!

quote]

Yep, apparently it's a hot new application of ray tracing. A similar project at another university in my country (Venezuela) received a donation of over $200,000 from Sun Microsystems (so of course, that version runs on a 32 processor beast, but has to run in Java, what a surprise)

Apparently I was told I would receive a similar annual amount to manage in research for my proposed projects, but until that money comes, it's only going to be dual processor for me :(

Well anyway, at least I got my main doubts cleared, so thanks :) Hope also you can give me some more info on those other methods :)



Journey
Journey
"Bidirectional path tracing basic idea: Trace a set of paths, both from the emitters and receivers. Then form complete paths by joining subpaths to each of the others. It's not quite that simple because you have to do it probabilistically to avoid a massive explosion of compute power (and to avoid low-contribution paths). What exactly are you measuring at each receiver? I'm guessing its the average power of the shock wave, which gets attenuated as it passes through each layer and at each refraction/reflection point?"



What I measure is the time it took the ray to get to the receptor, by summing up the length of all the vectors forming the trajectory of the ray. The attenuation of the wave aplitude as it passes layers is still not implemented, but its planned. As is the handling of other phenomenons such as terrain folding and such.


Well yeah, I think I see what you're getting at by probabilistic there, which means a lot of surplus ray trajectories? Yeah even with that restriction it's a lot of added computing time, but looks promising. I'll look it up :)
JuNC
JuNC
How are the receptors getting readings? Do you just trace a huge number of rays hoping to hit one? Or do you trace rays until they hit the surface and then do something like distribute the power to nearby receptors? Do you just take the next layer down intersections and trace a further ray to each receptor?


The idea behind the cosine distribution as opposed to the uniform one you're currently using is to concentrate samples where they are more likely to do good (I presume rays generated near the equator of the hemisphere generally don't contribute much to the receptors?). The math is quite simple but you do need to start doing a monte-carlo integration of the problem. Without knowing how you're modelling things like the sensors (see above), it's hard to visualise what you're after.

[edit]
You posted while I was :) Ignore the bit above about power, but the question still stands :)

Since you're measuring time the problem is slightly different to techniques used for ray tracing light transport, I imagine somewhat similar methods could work though. I'll think about it some more after work. It's also similar to acoustic tracing.
[/edit]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.