Search This Blog

Tuesday, March 22, 2011

Current plan

After reading through various papers, and talking to Dr. Jaggard, I've realized that I can't tackle everything there is in the world of optics at one time.  I have to pick and choose my fights.  For that reason, I'm going to try to implement the following capabilities in the following order:
  1. Unpolarized light, in a world of perfect insulators and perfect conductors.  This is probably the simplest physical model of light, and is due to the fact that light is just  Electromagnetic radiation that we can see.  Since it has an electric field, that means that as soon as a wave hits a superconducting surface, it is absorbed.  That means that none of the objects in this model will have any transparency what-so-ever, except for the air, which I'm going to model as a perfect vacuum.
  2. Polarized light.  The next simplest thing to work on is polarized light; in this case, the most general model is elliptically polarized light, which can be analyzed using Jones Calculus.  The handy part about this is that if you squint a little, Jones Calculus starts to look like a rotation matrix that a first-year student has messed up somehow (it doesn't have to be skew symmetric).  Now, the reason why I need to get polarized light working quickly is because my primary interest in Fourier optics is for modeling radio propagation, where my antennae are all dipoles.  Two dipoles that both point in the same direction will be able to transmit to one another, but two dipoles that are 'crossed' will not be able to transmit much energy to each other (this is a simplified model, if you are a radio engineer reading this, don't shoot me! :)  OTOH, if you want to improve my model, feel free to comment here, or better yet, enter in an issue at the issues page.)  Note that as long as the world is full of perfect conductors or insulators, the materials in the world will not be able to polarize light; the light is created in a polarized state, and all we need to worry about is if the receiving antennae are in the right orientation to receive the incoming information.
  3. Hybrid raytracing/Fourier Optics model.  The problem with performing the Fourier transform across all of space is that it is expensive to do, with no guarantee that you'll really use all of the calculation that you so expensively performed.  In fact, once you're past about 10 wavelengths from where your photon packet is, you no longer really need to think about the wave nature of light; the ray cleanly missed the object.  One solution to that would be 'fat' rays; project a ray just as you would for ray tracing, but make each ray a solid rectilinear beam.  Do the FFT on the volume that the beam travels through, instead of all of space.  This will need to be optimized so that when the beams overlap in space, you don't waste time recomputing the FFT over that region, but since I know what the viewing frustrum is like, and how big my beams are, I can easily calculate the region of space near the camera where they will overlap (yes, you can develop edge cases where they don't overlap, but my suspicion is that the time wasted in determining if you overlap or not will be greater than just doing the FFT and throwing away anything close-by that you don't use)
  4. Imperfect conductors At long last, we arrive at a more realistic materials model!  The index of refraction can take on any value, because the permittivity and permeability of objects can vary.  Note that at this point, things get interesting (meaning hard), because both the permittivity and the permeability are rank 2 tensors.  This means that the permittivity and permeability of some small volume depends on where it is (a volume within a chunk of glass is different from a volume in air), and on the orientation of the volume (this affects how the material polarizes light that passes through it).  In addition, the permittivity and permeability affect how quickly light is extinguished within the material; if you think about what THAT means, it means that both must be frequency dependent, otherwise we'd never have colors.  Finally, you also have reflection and refraction.  Thus, modeling this is the most complex problem to date. 
The hard part with all of this is determining how to correctly model light, and to correctly model the permittivity and permeability of the material.  In addition, my need to perform ray-tracing directly affects where my code ends up in the OpenGL pipeline.  I can do all of point 1 in CUDA, and then emit the answer straight into a fragment buffer, and let it do all the heavy lifting of displaying the output.  However, the fragments won't have any information on how the rays went through space; I need have intersection information, as well as be able to generate new rays when there is reflection or refraction.  That suggests that I need to tap into the pipeline after the vertices are known, which means after the vertex shader stage (or geometry shader stage, if there is one) is done.  Taking everything together, my current plan is as follows:
  1. Define a world coordinate system from which all orientations are derived.  For the simple reason that I'm most familiar with it, I'm going to define a right-handed coordinate system where 'z' is 'up', 'x' is to the 'right', and 'y' is 'forwards'.  Along with this, I define the angle θ and ϕ, where θ ranges over [0,π] and 0 is parallel to the z-axis, and pointing 'up', and where φ ranges over [0,2π), and 0 is along the x-axis, pointing right.  ϕ = π/2 points along the y-axis, pointing 'forwards'.  
  2. Define every ray of light has 4 vector (intensity, frequency, θ, ϕ).  The downside of this model is that if a ray has multiple colors, then I will have to fire the same ray through the same medium multiple times.  Unfortunately, I can't think of a better method of handling this.  I will initially treat all rays as having an intensity of 1, a single frequency, and linearly polarized in the vertical direction.
  3. Model each cubic volume as having two rank 2 tensors, one for the permittivity, and one for the permeability.  Initially, these will be set to either the permittivity and permeability of free space, or to permittivity and permeability of perfect conductor.
I still have a lot more to think about, especially the ray-tracing part.  Too much work to do!

No comments:

Post a Comment