Jump to content
Jens

Coatings - Iridescence

Recommended Posts

Having read the great post on glass from Mario I stumbeled across those papers on iridescence. Eventually I had an optics book on my lap, a sheet with a few scribbled notes and I made quick (and messy) test with VOPs. My first result of all this were these little soap bubbles :huh:

post-1415-1164135973_thumb.jpg

This is far from the shader I have in mind, but the basic idea seems right. Once I have a more eloborate version of this I'll post the code along with some explanations. I'll use the paper of Yinlong Sun as a guide line though I won't attempt the multilayer model. The spectral color representation seems quite forward to implement however and from my first reading concerning the physics everything seems fairly simple too. Let's see how it turns out :P

On sidenote:

I suspect having quite a few trigonometric functions in the final version involved. Has anyone ever tried to speed up code using a polynomal approximation of sin, cos etc.? I assume Houdini evaluates the coresponding power series (hence rather slow).

Share this post


Link to post
Share on other sites

That's great Jens! Looking forward to it!.... except of course that now you're making me feel all guilty for not finishing the glass shader.... uhmmm.. yeah, great, thanks a lot pal! :P

P.S: Was your other storage question related to storing the wavelength-chromaticity-angle lookup for Yinlong Sun's spectral representation?

Share this post


Link to post
Share on other sites
P.S: Was your other storage question related to storing the wavelength-chromaticity-angle lookup for Yinlong Sun's spectral representation?

Indeed: I need to access the x(lambda),y(lambda),z(lambda) functions of the CIE standard (Fourrier) and the 'wavelength-chromaticity-angle' thingy for those spectral color transformations. An alternate solution would be having the user enter the values in XYZ space directly for light and surface color, however I doubt this would be intuitive to use. And it would fail once we have multiple lights. But that part worries doesn't worry me really too much (yet). For now I just use spectral colors as input and do no conversion.

Initially when I wrote down the formulas I came up with an ugly looking integral. It had an aweful lot of sin and cos functions and I started getting worried... until I rememberd a few trigonometric identities ;)

Share this post


Link to post
Share on other sites
This is far from the shader I have in mind, but the basic idea seems right. Once I have a more eloborate version of this I'll post the code along with some explanations. I'll use the paper of Yinlong Sun as a guide line though I won't attempt the multilayer model. The spectral color representation seems quite forward to implement however and from my first reading concerning the physics everything seems fairly simple too. Let's see how it turns out :P

Ouch, Jens! This stuff really makes me itch!

Am I right that accessing this link needs some purchased membership? Could you possibly somehow explain or copy'n'paste the relevant information here? I am sure you can finish this great shader yourself but I would really appreciate if you could let me play with the necessary math along with you.

Thanks.

P.S. I am currently with my teeths dug into Mario's glass shader comments and math explanations, anyway some more close to topic data can't harm.

Share this post


Link to post
Share on other sites
Am I right that accessing this link needs some purchased membership?

No need for a membership. A preprint of the paper (along with a whole bunch of other interesting preprints) is available here.

Cheers.

Share this post


Link to post
Share on other sites

Everyone is most welcome to contribute :) I'll start with a quick overview for those intrested:

The pretty colors are caused by light inteference at the coating. Interference is the superposition of two or more (light-)waves. Both waves need the same frequency or at least have whole number relation ship. For simplicity we restrict ourself to equal frequency. They can have a phaseshift and when adding we either have an constructive or destructive addition. The diagram [from mathplanet] below is self-explanatory

post-1415-1164196636_thumb.jpg

For thin films we can explain the phase shift with the following diagram [from Sun].

post-1415-1164196653_thumb.jpg

The intial ray E0 is split and evantually E1 and E2 add up together again. E2 has traveled additionally E0t, E0tr' and this causes the phase shift. The length of E0t, E0tr' depend on the IOR of the involved materials. As well the amount of reflected light (E1) and the transmitted light (E2) depends on the IOR ratio. (Some of E2 will be split again etc. , but let's keep it simple). If the light would have only a single wavelength we'd only get a intensity pattern of the form sin

post-1415-1164196673_thumb.jpg

Iri_fake.hipnc

Share this post


Link to post
Share on other sites
Everyone is most welcome to contribute :) I'll start with a quick overview for those intrested:

...

This is really good food for thought.

A little bit off-topic, though maybe I should better get my hands on some optics manual: Since we can get an increase of the amplitude due to the local prism effect

Share this post


Link to post
Share on other sites
A little bit off-topic, though maybe I should better get my hands on some optics manual: Since we can get an increase of the amplitude due to the local prism effect

Share this post


Link to post
Share on other sites

As forewarned here is the first part on the formulas/math behind it

Here is the diagram with all the labels

post-1415-1164219760_thumb.jpg

We have to calculate the the path traveled within the thin coating to calculate the phaseshift. Here are the formulas involved and with (5) & (6) all we need to implement at this stage.

post-1415-1164220033_thumb.jpg

I bet there is a more elegant way and we could rewrite 5,6 to shorten the resulting formula further (and make it more effecient).

The choice to set n1 to 1 is simply that most of the time we will have on the outside air (and assume the air is around 20

VEC_J_IRI.zip

post-1415-1164225720_thumb.jpg

post-1415-1164550323_thumb.jpg

Share this post


Link to post
Share on other sites
As forewarned here is the first part on the formulas/math behind it

Great stuff Jens!

Thanks for sharing all this -- especially since I'll be able to use some of it in the glass. If I weren't so goddamnedbusy I'd be going through it right now! :)

Cheers!

Share this post


Link to post
Share on other sites

Hey Jens,

All this looks great and the infomation is very welcome:) I love it!

Share this post


Link to post
Share on other sites

very nice , all we need now is some decent lsystem shells to put this in on a doublesided material:)

Share this post


Link to post
Share on other sites
very nice , all we need now is some decent lsystem shells to put this in on a doublesided material:)

Looking forward to any pretty pictures made with it :D But first there is a bit of work ahead yet. And thanks for the positive feedback so far!

____________________________________

Now today sitting in the car I started thinking about the other iridecense effect: the local prism thingy. However this caused me quite a few headaches and maybe someone can give me here a hand. To me it seems the formula derived in this paper Granier is wrong :blink: . However since I suspect he will have thought about everything in detail I suspect I'm wrong :unsure:

Now first I have to explain something of real importance concerning all these interference effects. The light waves in natural light are 'short' and these short pieces have all little offsets to each other. Besides the lightwaves are a two dimensional wave and have an orientation (polarisation filters make this quite obvious). It's all pretty much random and hence we say these lighwave pieces are 'uncorrelated'.

Why am I mentioning this ? Only correlated lightwaves can show the inteference effects. Physicians put hell of an effort into creating lasers. Here we have only a single lightwavefrequency, they are long and really nicely correlated and they can do very accurate measurements with interference effects (e.g. interferrometers allow to measure in nm accuracy) and there are many many other applications. Anyhow we don't have lasers, but only the natural light and in short: The only notable effect from iridecense comes from those small short lightwave pieces that hit the surface split their 'wave ray' and join again. Chances are simply too low that two correlated waves meet over and over again at the same place (otherwise our eye would be too slow to register any of that). If we look again at this diagram

post-1415-1164290740_thumb.jpg

We see that distance between outgoing and incoming ray at the top surface. If our coating has a large thickness (and since the light wave amplitudes are quite small too) this lightwave couldn't interfere with itself anymore (they are simply too far apart) --> No colorshift anymore. Therefore we don't see any of these nice effects if the coatings get too thick (oilfilms on water only show the iridescence at the edges, since here the depth is very small).

Now keeping in mind that light waves have to correlate for any noticable effect and that in natural light the lightwave has to infere with it's splitted part, we look at that proposel (how I understood it) from Garnier.

post-1415-1164291437_thumb.jpg

If we look at the version with parallel lines, the length of t(1,i) and t(1,o) equal each other. Now he suggest to calculate the length of t(1,i) and t(1,o) according to the now non-parallel surfaces. Now we'd simply derive a formula from this to express the phase shift.

At first this seemed plausible and since this would cover as well the case of parallel lines I was about to adjust the code. BUT !!! :ph34r: now my headaches started :bag:

For interference the angle of the directly reflected wave and the one that has passed through the coating have to equal each other. Now the very trouble begins. (ignore wavelength depent effects for now) I made a few drawings and when n2 > n1 (true most of the time, since n1 is usually air) and remembering that angle of incidence is angle of reflection... try to find an angle suitable so that interference of the outgoing rays can occur.

post-1415-1164292920_thumb.jpg

I think the only angle where this is possible is the one shown in the diagramm above. Here t(1,i) and t(1,o) have again the same length. epsilon 2 has to be orthogonal to the normal of the lower surface. So we'd not only have to worry about the phase shift, but as well check if epsilon 2 is equal orthongoal or not since otherwise we'd have no correlated rays --> no interference --> no pretty colors ;)

I guess I made mistake here. If anyone has some insights on that, please let us know.

Share this post


Link to post
Share on other sites

hmm... this is becoming more and more interesting,

What I got from physics classes from school is that refraction happens on the same side (relative to surface normal line) as reflection - on your illustration with the non-parallel prism effect refraction happens on the side of the incidence vector – are you sure this effect happens in nature?

And another thought that may try to explain why wave interference can (and does) happen. The general illustration of parallel thin prism effect is certainly a simplification that mainly explains the phase-shift effect. I strongly doubt that anyone should seriously think that a light ray, unless it’s a laser beam (let’s be more specific and think of a ‘sun beam’ when discussing the diagram) is a straight thin line that can somehow interference itself. A general sun beam is a composition of a bunch of waves of different frequencies + waves of different frequencies get refracted non-uniformly + light is of dualistic nature and maybe it’s corpuscular nature somehow contributes to the effect - in context of our discussion some photons/waves can nevertheless interfere each other.

Certainly I can be wrong all together.

Share this post


Link to post
Share on other sites
I think the only angle where this is possible is the one shown in the diagramm above.

Hey Jens,

Just thinking out loud here while I do some comping... but this reminds me of some of the issues with sampling sss. If the dimensions of your drawings (and the patch of surface that we're thinking about) are assumed to be at visible-wavelength-scales, then it would seem realistic to think that the exiting ray that is a candidate for interference (E2 in the Sun diagram) doesn't necessarily have to have come from I (E0 in Sun) but from a ray to the left of it (again, assuming the distances are so small that the local geometry is the same for all rays in the nighbourhood)...

Anyhoo, this would *seem* to imply that interference is still physically plausible at t(1,d) (E1 in Sun) even if the geometric analysis of I's exiting trajectory puts it too far away to be a candidate for interference with t(1,d) -- that's just true for I but not for all the local rays... meaning that the angular restriction you're thinking about would only be true if you restrict yourself to only consider the subset of cases where exitant rays succeed in interfering with the mirror reflection of the incident rays that spawned them.

Again... just a thought that popped into my head while looking at the pretty diagrams (those are super helpful by the way, thanks!)... so likely missing the point altogether :unsure:

Cheers, and keep it coming please!

Share this post


Link to post
Share on other sites
hmm... this is becoming more and more interesting,

What I got from physics classes from school is that refraction happens on the same side (relative to surface normal line) as reflection - on your illustration with the non-parallel prism effect refraction happens on the side of the incidence vector

Share this post


Link to post
Share on other sites

Update: Version 2

* Model for thin films implemented (parallel planes)

* Changed to 6 color spectral model (same as Mario's glass shader)

A few choices to be made:

- How to split this into possibly multiple VOP's so we could easily use it with other shaders

- Add wavelength dependend IOR's as in Mario's glass shader using Sellmeier approximation or instead add a few parameters that allow to set fictional curves to desribe this relationship

- Optional output for physically accurate shaders: amount of reflected / absorbed light from our coating layer.

TODO:

I want to implement two more physical models that can lead to iridescence effects

- model for diffraction grating (CD effect), diffraction mirrors (Feathers, Butterfly Wings) + Sun's Multilayer model

- Create a few sample shaders using the VOP (shells / pearls / coated glass)

A few notes on the current version:

Currently it's in form of a very simple surface shader.

- For the variable 'd' (thickness) you should use values from 100 to 5k. The higher the thickness the stronger the seperation (antireflex coating have usually values around 140.. soap bubbles ~2000 nm)

- For something such as soap bubbles add a slight noise to 'd'. Careful however.. fairly sensitive to change in 'd' (stay within 10% of the original value)

- There is no light model (yet)

post-1415-1164414746_thumb.jpg

iri_odforce_v2.zip

Feel free to mess around with :huh: Cosider it an unpredictably behaving yet fairly physically accurate model to create phychodelic images :ph34r:

Share this post


Link to post
Share on other sites
I think the only angle where this is possible is the one shown in the diagramm above. Here t(1,i) and t(1,o) have again the same length. epsilon 2 has to be orthogonal to the normal of the lower surface. So we'd not only have to worry about the phase shift, but as well check if epsilon 2 is equal orthongoal or not since otherwise we'd have no correlated rays --> no interference --> no pretty colors ;)

I guess I made mistake here. If anyone has some insights on that, please let us know.

I'm confused why you have a problem here. Surely the incident ray gets bent as it enters the film but the exit ray gets bent by the same amount as it leaves so regardless of the IOR of the film the incident ray and exit ray will stay coherent regardless of the position of the source, and whether or not it is a parallel source.

This link is quite useful for visualising things.

Thin film interference

What you say about thickness is correct so as the film gets thicker the waves move apart and won't interfere but for a thin enough film all incident rays will stay parallel with their exit ray.

Share this post


Link to post
Share on other sites
I'm confused why you have a problem here. Surely the incident ray gets bent as it enters the film but the exit ray gets bent by the same amount as it leaves so regardless of the IOR of the film the incident ray and exit ray will stay coherent regardless of the position of the source, and whether or not it is a parallel source.

Have a look at the following diagram:

post-1415-1164455946_thumb.jpg

You see that once we have a non parallel plane the incident angle is smaller relative to the surface normal compared to the one of the exiting ray. Now the ray that passed the film and the one that was directly reflected are no longer parallel and they diverge --> no interference effects.

Besides on such thinfilms you can usually assume that even if the planes aren't perfectly parallel they are for approximation purposes. If you'd have an angle of even just 1

post-1415-1164499550_thumb.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×