Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Of scattering, bessel functions, and the road to suicide

This topic is 5267 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, friends. Recently... wow, actually that wasn''t so recent... an acquaintance of mine asked me if I could possibly code for him a plugin for 3d Studio that would simulate a planetary atmosphere. Understanding basic raytracing/raymarching, I figured what better way to get into graphics programming than a raytracer based solely on a sphere? Well lo and behold, that humble lowly sphere was a deamon in disguise. Sr = 3/4 * (1 + cos^2 theta) Excellent, I thought to myself upon discovery of this remedial equation. Rayleigh scattering, they call it. The coefficient of an EM field that an oscillating dipole radiator emits. A simple implementation into my raymarcher, and BIF-BAM! we have an atmosphere simulator. But such things cannot happen to me, you forget dear friend, God truly hates me... there had to be a catch. Enter sphere #2. I''m not a hateful man... I long to live in the forest, upon nature, working with the soil to produce various plants to sustain myself... I would be at peace, with myself, with my environment. But I will tell you right now, if it were chronologically possible, I would kill Gustav Mie in the worst way, and possibly maim Maxwell and/or Debye. Don''t get me started on what I''d do to the (wo)man that invented the sphere. They have thrust upon me my bane... allow me to explain. Approximately one year ago, aforementioned aquiaintance proposed the aforementioned simulator, and I got to work. Oh it was great at first... the rays marched, the virtual particles did their virtual scattering, optimization was going fine, and I was prepping myself for the 3dsmax plugin sdk... when I came across the website of a proponent of such virtual atmospheres. "Gee," I said to myself, "that doesn''t look like mine at all... I mean, the gradients are alright, and the colors aren''t that dissimilar. But my sunsets aren''t as pretty. It must be this mie thing he speaks of." And I was right. Fastforward a few weeks, 100 dollars poorer, up one book. Scattering and Absorption of Light by Small Particles, by Bohren and Huffman. This book seemed to be all the rave, by its description, it had everything a man could ever want in a book on scattering and absorption of light by small particles. This book must have been written for a God, by a God, to explain to the lesser God what the meaning of life is, mathematically... hypothetically... metaphotically... anything but literally. I cannot understand this jumble of electrodynamics, bessel functions, legendre polynomials, and God knows what else; I don''t even know what a "Cauchy''s theorem" is. The electrodynamics part I can get my head around, the bessel functions I can at least consider, but as soon as everything I know and them some is thrown all together to make this bloated piece of work, I simply don''t have the capacity to understand. Please, someone out there, hear me out! If you thoroughly understand Mie scattering, and even if you don''t, lend a pathetic excuse for a programmer a hand... I''ve spent at least the last 6 months staring at black and white print, brow furrowed, flipping back and forth between the same two pages for hours on end. I have nightmares expressed in vector spherical harmonics. I... need... help. At the moment I''m too out of it to ask any particular questions, but if you''ll be so kind as to being my mentor, even for an instant, I will be eternally grateful. And I might slip you a $20 or something, I don''t know. I''ll try to keep it more concise next time. Thank you for your time. Dave P.S, MSN screen name is sh0ckw4ve@hotmail.com

Share this post

Link to post
Share on other sites
Read this Preetham has published related stuff that does scattering and aerial perspective in real time which comes with source (he works at ATi now) which should be useful to you.

And buy "The nature of light and coloure in the open air" by Minnaert. Not exactly an implementation guide, but an excellent book nonetheless. Cheap too.

Share this post

Link to post
Share on other sites
I''m really not mathematically knowledgeable enough to give any help, but that was quite possibly the single most enjoyable thread I''ve read on this forum - ever.

Share this post

Link to post
Share on other sites
Now, I havent read the book, and its far from my speciality. But if I understand:

Rayleigh scattering is the scattering caused by molecular dispersion, the kind of scattering that cause our lovely sky to be blue, while mie scattering would be scattering caused by larger particules, like polution, humidity and the like...

I recently had an introduction on the subject, so maybe I can give you a few pointers, hopes that will help, sorry if not.

Basically you have two phenomena: One that cause light comming from the object to be bounced off in another direction, thats called attenuation.

A simple model would be:

I(l) = I_{0}(l) * e^(-B(l)d)

l is the wavelenght (usually divided in RGB color bands)
I(l) is the resulting color
I_{0}(l) is the original color comming from the object
e is the natural root
B(l) is the dispersion coefficient
d is the distance between the eye and the object

The second phenomenon would be the one that cause surrounding light to bounce to the eye because of scaterring, thats called airlight.

Simple model:

I(l) = S(l)(1 - e^(-B(l)d))

S(l) is the intensity of the light when looking at infinitum (like the sky)

Combining the two effects:

I(l) = I_{0}(l) * e^(-B(l)d) + S(l)(1 - e^(-B(l)d))

I dont know how practical it would be in a rendering context, im using those equations in a picture analysis context.

Without clouds, I would first simulate the sky color using rayleigh scattering, then apply the above model or a more complex derivate to simulate Mie scattering.

Keep in mind I never tried anything of that...

Good luck!

**Edit: With clouds, rayleigh scattering is less importante, since the color of the sky is mostly dictated by the color of the clouds.

[edited by - Steadtler on June 11, 2004 12:30:59 PM]

Share this post

Link to post
Share on other sites
Hello again,

Steadtler, the simple models I''ve seen I can at least wrap my head around... but I''m actually interested in the wavelength-dependent phenomena, particularly halos, glories and other interference phenomena. For instance, on a hazy night, look towards the moon and you''ll see a slight redenning of the moon''s halo. On a foggy morning or evening if you''re in a clearning, look at your shadow and you may see a glory, and if you''re lucky a fogbow.


Here you can see some photos, and there are even a few applications that simulate such effects; Iris is about droplet scattering. Unfortunately, most of the scattering software I''ve seen are just implementations of Bohren/Huffman''s FORTRAN scattering code, so there are no accompanying texts to help me out.

This appears to be the crux I''m facing; it seem that in all of mathematics, when you review an intermediate level text, you''re expected to know an extensive aggregation of math, physics, laws and theorems. I don''t expect myself to learn what a university professor knows just to create some eye candy. Don''t get me wrong, I''m willing to learn most, if not all of what''s involved in every aspect of scattering, even as far as RADAR backscattering for weather prediction, but not if it means I have to learn, memorize and understand hundreds of thousands of lines of text beforehand.

Grr, I''m doing it again... maybe I should ask a question.

Ok, I think I have one... the scattering from a particle can be considered thusly; you can break up a particle into a number of voxels, consider each voxel a dipole radiator, and add the radiated waves(who''s phases are governed by the incident EM wave, and the position within the particle, as well as IOR). The adding and subtracting of waves because of phase differences is how scattering arises. As the incident wave''s wavelength decreases, or likewise as the size of the particle increases, you get more and more peaks and valleys, until you get an asymptotic angular scattering function that''s equivalent to geometric optics(read raytracing) of a sphere. That was a mouthful, sorry.

It''s easy enough to break up a paticle into discrete voxels and add the phase differences, but that only really works for the first order of scattering/reflection/diffraction. This is where Mie comes in. Mie supplies an angular distribution function(or simply EM field) for scatting from a perfectly homogeneous sphere, if I understand the text correctly. The question is this; where do the bessel and legendre functions fit into this whole wacky system? It hovers around plane-wave expansion, or somesuch, but I don''t get much of a clear explanation from the book. And if any, what are the other applications of these functions?

Gamecat, I''ve read it, and I guess I understand it, but that deals with light distribution, not scattering, really... which is still incredibly important for realistic images, and it was a helpful text, but I''m really looking for the EM optics part of it.

Thanks again... wait, that wasn''t any more concise.

P.S, this might not be -directly- game related, I know... but I have my sights set for releasing this simulator for the public, as a 3dsmax plugin, or maybe even an SDK, that allows it''s use in games (I''ve always wanted to see halos and glories in 3d applications).

Share this post

Link to post
Share on other sites
EDIT: If this doesnt help, nothing will



Sorry, wavelenght-dependent phenomenas are too uncommon to be of use to us, so I really dont know much about it. I had heard Mie scattering was mainly wavelenght-independant.

The only thing I can help you with right now is:

"And if any, what are the other applications of these functions?"

Legendre and Bessel functions are the solutions of somewhat common differential equation forms.
Legendre polynomials are also used in spherical harmonics...

As for Cauchy, he wrote so much stuff you'll never see the end of it.

I cannot really help you without having read the book, but it sounds like fun, so I'll check if we have it in the campus' library.

Good luck in the mean time.

[edited by - Steadtler on June 13, 2004 9:39:57 PM]

Share this post

Link to post
Share on other sites
POV-ray (povray.org) implements various kinds of scattering including Mie and Rayleigh. The manual has helpful diagrams to illustrate how the scattering effects depend on the light direction, and you can look at the source code too. From what I understand, Rayleigh scattering is responsible for the colors of a clear sky and Mie would be used in fog/clouds or Los Angeles.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster

I am also trying to implement a Rayleigh and Mie scattering raytracer. It's going quite ok and I might be able to help you.

I've read all papers on the subject and must say it's a big mess.
No two papers exaplain this the same way and it took some time to get a grip on things.

If you are interested you can contact me on email
and we can discuss further.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!