POV-Ray : Newsgroups : povray.general : how (if at all) can i change the wavelength of light in pov? Server Time
13 Aug 2024 19:22:15 EDT (-0400)
  how (if at all) can i change the wavelength of light in pov? (Message 4 to 13 of 13)  
<<< Previous 3 Messages Goto Initial 10 Messages
From: Thomas Willhalm
Subject: Re: how (if at all) can i change the wavelength of light in pov?
Date: 18 Aug 1998 05:20:53
Message: <qqmyasmn1jv.fsf@goldach.fmi.uni-konstanz.de>
"Philippe Debar" <phi### [at] hotmailcom> writes:


> >um... subject kinda says it all.  i remember way back when, there being
> >the whole question of modelling a sparkling diamond.  the proposed
> >answers hinted at rendering the scene 3 times.  once with a red light,
> >once a green, and once a blue.  then composite them.  of course, each
> >render would see the light's wavelength altered such that the images
> >would be different.  unfortunately, i don't remember how this could (or
> >IF it could) be accomplished
> >
> 
> You could try rendering the scene three times, each with a differently
> colored
> light (rgb <1,0,0> ; <0,1,0> and <0,0,1> would be favorite) and a different
> IOR
> for the diamond - and the composite the images.
> 
> A finer approach would be, with the animation clock variable:
> (1) vary the color of lighting according to the light spectrum
>      to simulate different wavelengths;
> (2) at the same time, vary the ior value, according to the real
>      ior(wavelength law);
> (3) composite the resulting images (as many as you want)
> 
> Don't ask me about how to get a monochromatic wavelenght
> in rgb color space, 

But you can ask me:

// --- frequency.inc ----
// Tho### [at] uni-konstanzde
// usage:
//  #declare wavelength= ...
//  #include "frequency.inc"
//
pigment { color rgb
#if (wavelength<440)
  <(440-wavelength)/60,0,1>
#end
#if ((wavelength>=440)&(wavelength<490)) 
  <0,(wavelength-440)/50,1>
#end
#if ((wavelength>=490)&(wavelength<510))  
  <0,1,(510-wavelength)/20>
#end
#if ((wavelength>=510)&(wavelength<580))  
  <(wavelength-510)/70,1,0>
#end
#if ((wavelength>=580)&(wavelength<645)) 
  <1,(645-wavelength)/65,0>
#end
#if (wavelength>=645)
  <1,0,0>
#end

#if (wavelength>700)
    *(0.3+0.00875*(780-wavelength))
#else 
  #if (wavelength<420)
    *(0.3+0.0175*(wavelength-380))
  #end
#end
}
// --- end of frequency.inc ---

It is only a linear interpolation, but I hope it helps.

Thomas

-- 
http://www.fmi.uni-konstanz.de/~willhalm


Post a reply to this message

From: Fabien Mosen
Subject: Re: how (if at all) can i change the wavelength of light in pov?
Date: 18 Aug 1998 13:24:44
Message: <35d9aacc.0@news.povray.org>
Sorry, but none of the proposals will achieved the desired result.
Changing IOR only change the way you see trough an object, but
doesn't (in Pov) affect the path of the light passing trough.

I know an example of "diffractive" raytracing :
http://math1.uibk.ac.at/%28de%29/~werner/light/spectrum/

But current Pov implementation doesn't allow that.

What I would suggest is : render your scene with 3 or more
lights, each having a color from the spectrum, and make them
slightly shifted from each other.
This would, at least, make interesting shadows...

Cheers,
Fabien.


Post a reply to this message

From: Philippe Debar
Subject: Re: how (if at all) can i change the wavelength of light in pov?
Date: 18 Aug 1998 18:17:07
Message: <35d9ef53.0@news.povray.org>
Uho...

...You're right, Fabien...

...I guess that'll teach me to play Mr Clever...

...I should have turned my mouse seven times around its pad before posting
my reply...

...maybe next time ...


Post a reply to this message

From: K  Tyler
Subject: Re: how (if at all) can i change the wavelength of light in pov?
Date: 18 Aug 1998 18:28:52
Message: <35D9E3AA.DC6BF064@pacbell.net>
Fabien Mosen wrote:

> Sorry, but none of the proposals will achieved the desired result.
> Changing IOR only change the way you see trough an object, but
> doesn't (in Pov) affect the path of the light passing trough.
>
> I know an example of "diffractive" raytracing :
> http://math1.uibk.ac.at/%28de%29/~werner/light/spectrum/
>
> But current Pov implementation doesn't allow that.
>
> What I would suggest is : render your scene with 3 or more
> lights, each having a color from the spectrum, and make them
> slightly shifted from each other.
> This would, at least, make interesting shadows...
>
> Cheers,
> Fabien.

There is an old porgram that yeilds some interesting though perhaps
not the desired results your seeking. Here is the entirety of the programs
docs.

------------------

Prisms - Chromatic Dispersion Simulation Program

  (c) Jeff Bowermaster
      Splat! Graphics
      5/23/92

     Adds together three separate Targa images one color from each.
     When refractive objects are given slighty different ior's in each image,
     the effect simulates chromatic dispersion (i.e., prisms 'n rainbows).

        Usage: Prisms [infiles prefix]

     Each file has a prefix name with numeric suffix's 1, 2 and 3.


     Example:

        PICTURE1.TGA, PICTURE2.TGA, PICTURE3.TGA are three images created
        with refractive elements whose ior values differ slightly.  These
        three images would be combined by typing

             Prisms PICTURE

        The summed image will be written to PICTURES.TGA

     This only works with uncompressed type 2 TGA's.  It's easier.

     Some suggested ior values would be 1.4, 1.45 and 1.5 for glass,
     2.4, 2.5 and 2.6 for diamond.  These changes in ior greatly exceed
     reality (a tenth this change is more like it) but when real values
     are used the effects are too subtle to notice.

     Please experiment.

     I experimented with using 6 images instead of three, but the colors
     started washing out.  I did try a variety of range combinations and
     certain refractive objects looked better using certain ranges, but
     the only way to find out is to try 'em.

     No provisions are made for garbage in/garbage out.
------------------------

If anyone is interested I have the program and will foreward it those who ask.

K.Tyler


Post a reply to this message

From: Dan Connelly
Subject: Re: how (if at all) can i change the wavelength of light in pov?
Date: 18 Aug 1998 19:43:47
Message: <35DA03A5.F3ACAC5@flash.net>
As is mentioned in 
http://math1.uibk.ac.at/%28de%29/~werner/light/spectrum/

even 6 colors is inadequate.

Consider a vertical slit white light souce (we are neglecting
the wave nature of light, of course) which enters a prism.

What comes out isn't 3 slits of light, one red, one green,
and one blue, but a rectangular band of light encompassing 
the entire spectrum.

To properly model prisms, one must either use a large number
of color samples (whose rgb components sum to 1) or to apply
some sort of spatial broadening algorithm based on
d ior / d k_light to each of the r, g, and b beams.

Dan

K. Tyler cited:
> 
>   (c) Jeff Bowermaster
>       Splat! Graphics
>       5/23/92
>      I experimented with using 6 images instead of three, but the colors
>      started washing out.


-- 
http://www.flash.net/~djconnel/


Post a reply to this message

From: Peter Popov
Subject: Re: how (if at all) can i change the wavelength of light in pov?
Date: 19 Aug 1998 00:36:32
Message: <35da4840.0@news.povray.org>
>> cut
>But you can ask me:
>
> (frequency.inc) code cut
>
>It is only a linear interpolation, but I hope it helps.

It helps me for one. I have a (much more difficult to answer) question: how
about Fourier analysis of a rgb coded color? Will it be easier if
light_sources are (optionally) specified as wavelengths? What if there is a
filter_map and reflecton_map to specify the absorbtion and reflection
spectra of a bofy? Won't these give more realistic light dispersion than the
current dispersion patch gives? I once wanted to develop (only the math
stuff of) a dispersion patch but gave up at the above questions. I came up
with the same sampling algorithm used in the dispersion patch (back then I
was thinking of more user control to it but it turned  out it looks fine as
is)


>
>Thomas
>
>--
>http://www.fmi.uni-konstanz.de/~willhalm

Regards,

--Peter

pet### [at] usanet


Post a reply to this message

From: Chris Maryan
Subject: Re: how (if at all) can i change the wavelength of light in pov?
Date: 19 Aug 1998 02:19:21
Message: <35DA5E0C.B5F1EF25@geocities.com>

<some stuff if snipped, and then he said>
> IF it could) be accomplished

I played around with rendering three times with different IORs and then
compositing the resulting images and have come to the conclusion that
most of the time this does not work, although occasionally a good effect
can be achieved. In most of my attempts, a slight change in the IOR (I
played with +- 0.05 and 0.02, from a base IOR of 2.7) made a large
difference in how large surfaces reflected internally (i.e. the larger
facets on a diamond), that is after compositing (I replaced the R, G and
B channels with the corresponding channels from the images with the
appropriate IOR) whole facets would be brightly tinted with either R,G
or B. On large facets the effect was unacceptable because there was no
blending between colours and the effect did not look realistic.
HOWEVER, I accidentally rendered my diamond with the equivalent of very
small facets, I used smoothed triangles for the facets instead of
unsmoothed accidentally, this resulted in very fine lines of rainbow
colours that looked very realistic.

So there is my contribution to this disscussion.
-- 
Chris Maryan
mailto:cma### [at] geocitiescom
***
My ideas are free,
Work is at least minimum wage.
***
Email me if you are interested in donating
to the Chris Maryan needs money fund.


Post a reply to this message

From: Dan Connelly
Subject: Re: how (if at all) can i change the wavelength of light in pov?
Date: 19 Aug 1998 07:16:05
Message: <35DAA5EB.BD9BA1FE@flash.net>
> It helps me for one. I have a (much more difficult to answer) question: how
> about Fourier analysis of a rgb coded color?

I think there is a problem with this statement, or in my
interpretation of it.

Fourier analysis is based on the principle that for linear
systems, functions continuous to all derivatives can be expressed
as a superposition of sinusoids.  However, for functions
of unconstrained periodicity, it takes a superposition over all
possible wavelengths to do so optimally.

The fourier representation of a color of frequency f1 is a
color of frequency f1 -- this means that one cannot express
all colors in terms of RGB components : if sinusoids are
chosen as a basis function, you still need all of them to
do the job correctly.

However, the human eye happens to be sensitive to R, G, and B 
due to its limited capacity to perceive color.  If, like some
species, we had 4 color receptors, RGB displays would appear
as distorted as an RG display does to us.

So Physics can't be represented as a superposition of red, green,
and blue -- it requires a much finer sampling across the optical
spectrum to yield credible results in many cases.  Otherwise
rainbows would be red, green, and blue bands instead of a continuous
spread.

Dan
-- 
http://www.flash.net/~djconnel/


Post a reply to this message

From: Peter Popov
Subject: Re: how (if at all) can i change the wavelength of light in pov?
Date: 20 Aug 1998 00:45:03
Message: <35db9bbf.0@news.povray.org>
Dan Connelly wrote in message <35DAA5EB.BD9BA1FE@flash.net>...
>> It helps me for one. I have a (much more difficult to answer) question:
how
>> about Fourier analysis of a rgb coded color?
>
>I think there is a problem with this statement, or in my
>interpretation of it.
>


Must be my fault, I'm not a math person

>Fourier analysis is based on the principle that for linear
>systems, functions continuous to all derivatives can be expressed
>as a superposition of sinusoids.

Well, there's discrete FFT... maybe another means of finding out what
wavelengths *might* be responsible for a rgb colors

However, for functions
>of unconstrained periodicity, it takes a superposition over all
>possible wavelengths to do so optimally.
>


Well, some degree of accuracy can be a threshold, right?

>The fourier representation of a color of frequency f1 is a
>color of frequency f1 -- this means that one cannot express
>all colors in terms of RGB components : if sinusoids are
>chosen as a basis function, you still need all of them to
>do the job correctly.
>

You are right. I think the problem is that the physical representation of a
rgb color (almost certainly) is not unique. Foe example, rgb <0,1,0> is
550nm, but can also be a sum of several wavelengths, wide bands and thin
lines in the spectrum etc. This is due to the imperfections of the eye

>However, the human eye happens to be sensitive to R, G, and B
>due to its limited capacity to perceive color.  If, like some
>species, we had 4 color receptors, RGB displays would appear
>as distorted as an RG display does to us.

Agreed on that.

>So Physics can't be represented as a superposition of red, green,
>and blue -- it requires a much finer sampling across the optical
>spectrum to yield credible results in many cases.  Otherwise
>rainbows would be red, green, and blue bands instead of a continuous
>spread.

Yes, but still a nice approximation may be possible. POV approximated
inter-diffuse reflection in two ways, one cheap 'n' cheesy, the other slow
but more realistic, both being imperfect, but satisfying as a final result.
My question arose several years ago (back on POV 2.2) when I saw the books
behind my aquarium and how light was dispersed, nd how hard it was to model
in pov. Now, this problem solved, the problem with nice coloured refractive
custics remains. I've been willing to model a spectrograph for years now,
but that will have to wait. Maybe some day...

>
>Dan
>--
>http://www.flash.net/~djconnel/

Thanks for your input.

--Peter

pet### [at] usanet


Post a reply to this message

From: Daren Scot Wilson
Subject: Re: how (if at all) can i change the wavelength of light in pov?
Date: 25 Aug 1998 20:42:48
Message: <35E3142F.2432C419@pipeline.com>
Color dispersion is old stuff to me - I altered POVRay's source code to
do dispersion and described my results on the web page.  If you're a
programmer, or want to see samples, 

http://www.newcolor/darenw/dswpov/dswpov.html

I will be rewriting my web pages soon, so if this is gone just go to
www.newcolor.com and click your way from there.  

Not only do I describe what I did to do dispersion, but I describe a bad
way of doing dispersion - like what others have been suggesting to try.

Dispersion was actually fairly easy to implement, except for three
things:

1) converting RGB to a 9-component color was easy, but I had to convert
back to RGB for display on the screen.  My way wasn't based on known
color science, but chosen for artistic reasons, as I had a project to
finish.  This took a lot of trial and error.

2) The RGB Colour data structure is used in a zillion places, and it
took several days to update all the source files.  But it's just grunt
work.

3) To prevent catastrophic slowdown of execution time I had to create
what I call the "k-only" mechanism.   Bottom line:  raytracing with
dispersion is maybe 1 to 10% slower than normal.  Heck, I use the
dispersion version just to trace ordinary scenes all the time.

I do not have an executable to pass out - I can't support all the
operating systems, etc.   But I could e-mail a source code tarball if
you like.    If you're not a programmer though, you'll have to ask some
of the other regulars in this newsgroup if they've incorporated my
changes in their versions. I don't know of any, but then, I live under a
rock <g>.

Someday, someday... I'll have a custom POV-Ray that I can offer, or at
least a decent patch file....

-- 

Daren Scot Wilson
Member, ACM
dar### [at] pipelinecom
www.newcolor.com
---
   "If you saw the poisons we put on them you wouldn't ask that
    question. You'd never eat another ..."
What is this farmer talking about?
Find out at http://www.ratical.com/LifeWeb/Erthdnce/chapter21.html


Post a reply to this message

<<< Previous 3 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.