POV-Ray : Newsgroups : povray.general : Rendering an electromagnetic field and photon rays Server Time
19 Apr 2024 00:44:04 EDT (-0400)
  Rendering an electromagnetic field and photon rays (Message 1 to 10 of 25)  
Goto Latest 10 Messages Next 10 Messages >>>
From: cbpypov
Subject: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 11:50:01
Message: <web.59f0b24056f94df5667cbe5f0@news.povray.org>
Hi,

I'm trying to render a high quality "cover art" for a physics thesis
(nanophotonics). I have basically two questions:

  1. What is the best way to generate a "glowing field distribution"?
  2. What is the best way to illustrate a light ray or "photon path" coming from
an emitter, say a small glowing sphere

For 1): Say I have field values in 3D that I could assign to desired colors and
brightness values. So that that I have e.g. a list of (x, y, z, R, G, B,
brightness). I thought of using a light source source at each point, maybe also
using a semitransparent looks_like attribute; together with a medium, like:

box{
   <-10,0,0>, <20, 5, 10>
   pigment { rgbt 1 } // clear
   hollow
   interior{
     media{
       scattering{ 1., 0.17 extinction 0.01}
       samples 5*Media_Quality, 10*Media_Quality  // min, max
     } // end media
   } // end interior
 } // end box
#end

But it does not have the desired effect. So how can I achieve something like
this?

for 2): They should moreover be small particles emitting focussed beams or maybe
glowing wiggly rays. Does anyone have an example of how to implement this?

Thanks in advance


Post a reply to this message

From: Bald Eagle
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 12:35:00
Message: <web.59f0bc539b56bbddc437ac910@news.povray.org>
"cbpypov" <nomail@nomail> wrote:
> Hi,
>
> I'm trying to render a high quality "cover art" for a physics thesis
> (nanophotonics). I have basically two questions:
>
>   1. What is the best way to generate a "glowing field distribution"?
>   2. What is the best way to illustrate a light ray or "photon path" coming from
> an emitter, say a small glowing sphere

I would say that you should look at Paul Nylander's work
http://www.bugman123.com/index.html
as he's and engineer, and has done an awful lot of very professional quality
scientific visualization with POV-Ray.

> For 1): Say I have field values in 3D that I could assign to desired colors and
> brightness values. So that that I have e.g. a list of (x, y, z, R, G, B,
> brightness).
.....
> So how can I achieve something like
> this?

You use an EMISSIVE media.
I'd also consider generating your field as a df3 file, and then you can "sculpt"
the media density with that df3 information.

Also see the owrk of Paul Bourke:

http://paulbourke.net/miscellaneous/povexamples/

I presently do not enjoy media, and almost never use it, so others may have
other / better ideas, and they will assuredly have more details on HOW to use
media to do what you want.

> for 2): They should moreover be small particles emitting focussed beams or maybe
> glowing wiggly rays. Does anyone have an example of how to implement this?

I'd say that you'd need to define a vector field, and then use that to place and
orient your line/ray/wiggle shapes.

Serendipitously, I recently tried to implement a "Perlin noise flow field" from
Dan Shiffman's Coding Challenge (he uses Processing):
https://www.youtube.com/watch?v=BjoM9oKOAKY
in POV-Ray, but I couldn't work out the last bits and get it to function
properly.
Perhaps I can supply my code in its present state and you could use that as a
good starting point (and perhaps debug it in the process  :D  )

> Thanks in advance

Certainly:   good luck!


Post a reply to this message

From: cbpypov
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 13:55:00
Message: <web.59f0cf3a9b56bbdd667cbe5f0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "cbpypov" <nomail@nomail> wrote:
> > Hi,
> >
> > I'm trying to render a high quality "cover art" for a physics thesis
> > (nanophotonics). I have basically two questions:
> >
> >   1. What is the best way to generate a "glowing field distribution"?
> >   2. What is the best way to illustrate a light ray or "photon path" coming from
> > an emitter, say a small glowing sphere
>
> I would say that you should look at Paul Nylander's work
> http://www.bugman123.com/index.html
> as he's and engineer, and has done an awful lot of very professional quality
> scientific visualization with POV-Ray.
>
> > For 1): Say I have field values in 3D that I could assign to desired colors and
> > brightness values. So that that I have e.g. a list of (x, y, z, R, G, B,
> > brightness).
> .....
> > So how can I achieve something like
> > this?
>
> You use an EMISSIVE media.
> I'd also consider generating your field as a df3 file, and then you can "sculpt"
> the media density with that df3 information.
>
> Also see the owrk of Paul Bourke:
>
> http://paulbourke.net/miscellaneous/povexamples/
>
> I presently do not enjoy media, and almost never use it, so others may have
> other / better ideas, and they will assuredly have more details on HOW to use
> media to do what you want.
>
> > for 2): They should moreover be small particles emitting focussed beams or maybe
> > glowing wiggly rays. Does anyone have an example of how to implement this?
>
> I'd say that you'd need to define a vector field, and then use that to place and
> orient your line/ray/wiggle shapes.
>
> Serendipitously, I recently tried to implement a "Perlin noise flow field" from
> Dan Shiffman's Coding Challenge (he uses Processing):
> https://www.youtube.com/watch?v=BjoM9oKOAKY
> in POV-Ray, but I couldn't work out the last bits and get it to function
> properly.
> Perhaps I can supply my code in its present state and you could use that as a
> good starting point (and perhaps debug it in the process  :D  )
>
> > Thanks in advance
>
> Certainly:   good luck!

Thank you very much for your quick reply! It really guides me into the right
direction. However, I would really appreciate if someone could elaborate on HOW
to actually do it... Maybe it is me, but I cannot find a single line of POV-ray
code on Paul Nylander's page!? There are very similar things to what I am trying
to do, but where is the code?

The df3 format sounds nice, but right now I could not find out how to generate
it except for dealing with the specifics manually (the data is in available in
python right now).

Moreover, I'd really enjoy getting your code and to see what can do with it :)


Post a reply to this message

From: jr
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 14:04:47
Message: <59f0d23f$1@news.povray.org>
hi,

On 25/10/2017 18:51, cbpypov wrote:
> Thank you very much for your quick reply! It really guides me into the right
> direction. However, I would really appreciate if someone could elaborate on HOW
> to actually do it... Maybe it is me, but I cannot find a single line of POV-ray
> code on Paul Nylander's page!? There are very similar things to what I am trying
> to do, but where is the code?

Cousin Ricky did a "pared beam" scene which I cannot find now, but hope
this helps:

http://lib.povray.org/searchcollection/index2.php?objectName=BeamTest&contributorTag=Cousin%20Ricky

regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 14:20:01
Message: <web.59f0d5c59b56bbddc437ac910@news.povray.org>
"cbpypov" <nomail@nomail> wrote:

> Thank you very much for your quick reply! It really guides me into the right
> direction. However, I would really appreciate if someone could elaborate on HOW
> to actually do it...


> Maybe it is me, but I cannot find a single line of POV-ray
> code on Paul Nylander's page!? There are very similar things to what I am trying
> to do, but where is the code?

You probably just read right past it.
There are plenty of links like: "Click here to download some POV-Ray code"
Just [CTRL][F] and search for POV - they'll pop up.

No code, but about 3/4 of the way down on
http://www.bugman123.com/Physics/index.html
is an atomic orbital df3.
Maybe you could email Paul and ask him for [partial] source code, but I think
plenty of people here ought to be able to show you how to write a DF3, and
implement it in a scene.
Also, check the drop-down insert menu, and example scene file directories
supplied with your POV-Ray distribution.

I'm at work now and have to deal with a [brand new] flat tire tonight, but maybe
I can didg something up for you at home if people don't chime in before then.

> The df3 format sounds nice, but right now I could not find out how to generate
> it except for dealing with the specifics manually (the data is in available in
> python right now).

There's a way - I've just never used it.   Search for POV-Ray df3 and maybe you
can find something on the web or a forum post.  Or clipka will jump in soon....

> Moreover, I'd really enjoy getting your code and to see what can do with it :)


I'll try to get it posted for you tonight.


Post a reply to this message

From: Stephen
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 14:57:32
Message: <59f0de9c$1@news.povray.org>
On 25/10/2017 17:31, Bald Eagle wrote:
> "cbpypov" <nomail@nomail> wrote:
>> Hi,
>>
>> I'm trying to render a high quality "cover art" for a physics thesis
>> (nanophotonics). I have basically two questions:
>>
>>    1. What is the best way to generate a "glowing field distribution"?
>>    2. What is the best way to illustrate a light ray or "photon path" coming from
>> an emitter, say a small glowing sphere
> 
> I would say that you should look at Paul Nylander's work
> http://www.bugman123.com/index.html
> as he's and engineer, and has done an awful lot of very professional quality
> scientific visualization with POV-Ray.
> 
>> For 1): Say I have field values in 3D that I could assign to desired colors and
>> brightness values. So that that I have e.g. a list of (x, y, z, R, G, B,
>> brightness).
> .....
>> So how can I achieve something like
>> this?
> 
> You use an EMISSIVE media.
> I'd also consider generating your field as a df3 file, and then you can "sculpt"
> the media density with that df3 information.
> 

DF3s are probably the way to do it. One drawback is that PovRay uses 
df3s as a monochrome input. So you would need three of them to R G & B 
images. jr might be able to help you with the df3 format as he is 
working on a set of df3 utilities.

The code I use for rendering in colour with df3s is:

         #declare PF = 64  ; // multiplication factor

     #declare Df3_Material0 =
     material{
       texture {
         pigment {
           colour rgbft <1.000,1.000,1.00,0.000,1.000>
         }

       }

       interior{
         ior                 1.000
         caustics            0.000
         dispersion          1.000
         dispersion_samples  7.000
         fade_power          0.000
         fade_distance       0.000
         fade_color          rgb <0.000,0.000,0.000>
         media {
           method     3
           intervals  10
           samples    1, 1
           confidence 0.900
           variance   0.008
           ratio      0.900
           absorption rgb <0.000,0.000,0.000>
           emission   rgb <1.000,0.000,0.000>     * PF
           aa_threshold 0.050
           aa_level    4
           density {
             density_file df3 "Your_red.df3"
             interpolate 2
           }

         }

         media {
           method     3
           intervals  10
           samples    1, 1
           confidence 0.900
           variance   0.008
           ratio      0.900
           absorption rgb <0.000,0.000,0.000>
           emission   rgb <0.000,1.000,0.000>   * PF
           aa_threshold 0.050
           aa_level    4
           density {
             density_file df3 "Your_green.df3"
             interpolate 2
           }

         }

         media {
           method     3
           intervals  10
           samples    1, 1
           confidence 0.900
           variance   0.008
           ratio      0.900
           absorption rgb <0.000,0.000,0.000>
           emission   rgb <0.000,0.000,1.000>      * PF
           aa_threshold 0.050
           aa_level    4
           density {
             density_file df3 "Your_blue.df3"
             interpolate 2
           }

         }

       }

       translate <-0.500,-0.500,-0.500>
     }


> 
>> for 2): They should moreover be small particles emitting focussed beams or maybe
>> glowing wiggly rays. Does anyone have an example of how to implement this?
> 

You might be able to adapt Rune's Electricity Include File to get what 
you need. It does say that it uses MegaPov 1.0. But that is only for the 
glow, I think.

http://runevision.com/3d/include/



> 
>> Thanks in advance
> 
> Certainly:   good luck!
> 
> 

Seconded. :-)

-- 

Regards
     Stephen


Post a reply to this message

From: cbpypov
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 15:10:01
Message: <web.59f0e10d9b56bbdd667cbe5f0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> You probably just read right past it.
> There are plenty of links like: "Click here to download some POV-Ray code"
> Just [CTRL][F] and search for POV - they'll pop up.
>
> No code, but about 3/4 of the way down on
> http://www.bugman123.com/Physics/index.html
> is an atomic orbital df3.
> Maybe you could email Paul and ask him for [partial] source code, but I think
> plenty of people here ought to be able to show you how to write a DF3, and
> implement it in a scene.
> Also, check the drop-down insert menu, and example scene file directories
> supplied with your POV-Ray distribution.
>
> I'm at work now and have to deal with a [brand new] flat tire tonight, but maybe
> I can didg something up for you at home if people don't chime in before then.
>
> > The df3 format sounds nice, but right now I could not find out how to generate
> > it except for dealing with the specifics manually (the data is in available in
> > python right now).
>
> There's a way - I've just never used it.   Search for POV-Ray df3 and maybe you
> can find something on the web or a forum post.  Or clipka will jump in soon....
>
> > Moreover, I'd really enjoy getting your code and to see what can do with it :)
>
>
> I'll try to get it posted for you tonight.

I am really fascinated about the active and dedicated help, thanks to both of
you!

Somehow I really missed the in-text links to the POV-ray code. I will need to
carefully search if I can derive a solution for my objective from these...

But please do not neglect your tire (are you talking of a car tire?), this would
seriously disturb my peace of conscience :)

It's sad that I cannot attach an image, so I'll try to explain a bit more: The
field data is in a volume composed of a hexahedron and a cylinder (so it is more
complicated than in a box). It is computed for a unit cell with with hexagonal
base area, which I'd like to tile for some periods in x- and y-direction. So I
thought the easiest way would be to have basically two loops: one over the
points (x,y,z,color,brightness) inside the unit cell; and another one over the
lattice, which basically repeats the first stepp over and over with translated
coordinates.

Wouldn't it be possible to generate the field profile in the first loop using
"boxes" of emissive media (properties set according to x,y,z,color, ...), i.e.
3d pixels that in total fill up the mentioned volume?

For the emitters mentioned at the beginning, I could image that a more simple
"glowing" effect (i.e. a small sphere with a halo) would be sufficient. In the
ideal case the glowing would be adjusted depending on the location in the field
above.

I hope this was somehow more clear than the short paragraph given above. I am
deeply grateful for any further suggestions and code samples!


Post a reply to this message

From: Bald Eagle
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 15:20:01
Message: <web.59f0e32e9b56bbddc437ac910@news.povray.org>
From the documentation:
"See the sample scenes for data file include\spiral.df3,and the scenes which use
it: scenes\textures\patterns\densfile.pov, scenes\interior\media\galaxy.pov for
examples."


http://news.povray.org/povray.text.scene-files/thread/%3Cweb.53013dce87b4247ff093e06c0%40news.povray.org%3E/


Python code to write df3's
http://povray.tashcorp.net/tutorials/script_df3/

Check out Blender to export DF3's for POV-Ray.
https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Render/POV-Ray
(Check out the _hair_ - maybe you could use that for your rays/squiggles)

Java (ImageJ):
http://fly.mpi-cbg.de/~saalfeld/Projects/df3.html
https://imagej.nih.gov/ij/


Sample code to write out a df3  -- looks like it's FORTRAN 90

http://web.utah.edu/thorne/computing/sphere.f90

An OLD editor (no idea if this still works)
http://www.2writers.com/Eddie/Df3Edit.htm

"Bald Eagle" <cre### [at] netscapenet> wrote:
> Also see the owrk of Paul Bourke:
>
> http://paulbourke.net/miscellaneous/povexamples/

There's lots of info on that page (2nd topic), a link to a sample scene file,
and a (C++?) code to write df3.


Post a reply to this message

From: Stephen
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 15:35:41
Message: <59f0e78d$1@news.povray.org>
On 25/10/2017 20:07, cbpypov wrote:
> It's sad that I cannot attach an image

But you can, use the newsgroup called povray.binaries.images.

If you are using the web view.
http://news.povray.org/povray.binaries.images/


-- 

Regards
     Stephen


Post a reply to this message

From: cbpypov
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 15:40:00
Message: <web.59f0e75d9b56bbdd667cbe5f0@news.povray.org>
Thanks again to Bald Eagle and as well to Stephen for the fragment. Together
with the python df3 class getting the df3 to work should be easy. But the doc
says it is limited to a box from 0,0,0 to 1,1,1. Is this a problem regarding my
relatively complex volume?

Just to show what I have so far, I'll post the code below. It does not feature
any approach for the field iclusion. A single yellow emitter is presented but
does not yet produce a beam. The electricity stuff looks interesting, although
the photon passes should be straight ;) I'll look into this again tomorrow, it
is already night time in Germany :)

// Imports
//--------------------------------------------------------------------------
#include "colors.inc"
#include "textures.inc"
#include "glass.inc"
#include "metals.inc"
//--------------------------------------------------------------------------


// Global Settings
//--------------------------------------------------------------------------
#version 3.7;
global_settings{
    assumed_gamma 1.0
}

// Global parameters
//--------------------------------------------------------------------------
// 0=off, 1=fast; 2=medium quality; 3=high qual.;
// 4= medium qual.+ recursion_limit 2
#declare Radiosity_On  = 0;
#declare HDRlighting = false;
#declare Media_On = true;
#declare Media_Quality = 10;

#declare a_real = 600.; // lattice constant
#declare d_real = 367.; // hole diameter
#declare h_real = 116.; // phc height
#declare sqrt3 = 0.5*sqrt(3.);

// derived parameters
#declare a = a_real/a_real;
#declare d = d_real/a_real; // hole diameter
#declare h = h_real/a_real; // phc height
#declare cx = a/sqrt3/4; // standard x coordinate of hexagon
#declare cy = 0.5*a; // standard y coordinate of hexagon


//--------------------------------------------------------------------------
background{White}

//--------------------------------------------------------------------------
camera {
    angle 30
    location <0, 2, -3>
    look_at <0, 0, 0>
}

//--------------------------------------------------------------------------
//light_source { <20, 20, -20> color White }

// Textures
//--------------------------------------------------------------------------
#declare f_reflective_metal = finish {
    emission 0.
    diffuse albedo 0.075
    brilliance 5.
    reflection { .9 metallic 1 } metallic
    irid {
        0.25
        thickness 0.2 //Schichtdicke
        turbulence 0.1
    }
}
#declare f_metal_shiny = f_reflective_metal

// basic shiny metal
#declare t_shiny_metal =
texture {
 pigment { rgb <.45, .42, .41> }
 finish { f_metal_shiny }
}

// Object geometries
//--------------------------------------------------------------------------
#declare geo_si = prism {
    linear_sweep
    linear_spline
    0., // sweep the following shape from here ...
    h, // ... up through here
    7, // the number of points making up the shape ...
    <-2*cx,0>, <-cx,cy>, <cx,cy>, <2*cx,0>, <cx,-cy>, <-cx,-cy>, <-2*cx,0>
}

#declare geo_hole = cylinder {
    <0., -0.1, 0.>, <0., h+0.1, 0.>, d/2.
}

#declare phc = difference {
    object{ geo_si }
    object{ geo_hole }
}

plane
{ y, 0.
    material{
        texture {
            pigment{ rgb<.1,.1,.1>}
            finish {
                reflection .1
            }
        }
    }
}

object{
    phc
    texture{ t_shiny_metal }
}

/*
sphere{
    <0,0,0>, 0.05
    translate<0.1,h+0.1,0>
    texture{
      pigment{ color rgbt<0.9,0.55,0,0.6>}
      finish { phong 1 }
    } // end of texture
} // end of sphere
*/


light_source{
    <0.,0.,0> color White*.5
    looks_like{
       sphere{ <0.1,h+0.1,0>, 0.01
               texture{
                pigment{color rgbt<0.98,0.9,0,0.2>}
                finish {ambient 0.9
                        diffuse 0.1
                        phong 1}
               } // end texture
            } // end of sphere
     } //end of looks_like
} //end of light_source



// Media box
//--------------------------------------------------------------------------
#if (Media_On)
box{
   <-10,0,0>, <20, 5, 10>
   pigment { rgbt 1 } // clear
   hollow
   interior{
     media{
       scattering{ 1  0.17 extinction 0.}
       samples 1*Media_Quality, 10*Media_Quality  // min, max
     } // end media
   } // end interior
 } // end box
#end

// Radiosity settings
//------------------------------------------------------------- settings start
#if (Radiosity_On > 0)

global_settings {
    #ifndef ( Rad_Quality )
        #declare Rad_Quality = Radiosity_On;
    #end

    //--------- radiosity settings -------------------------------- ///
    // from POV-Ray samples "scene templates/patio-radio.pov

    #switch (Rad_Quality)
    #case (1)
    radiosity {             // --- Settings 1 (fast) ---
        pretrace_start 0.08
        pretrace_end   0.02
        count 50
        error_bound 0.5
        recursion_limit 1
    }
    #break
    #case (2)
    radiosity {             // --- Settings 2 (medium quality) ---
        pretrace_start 0.08
        pretrace_end   0.01
        count 120
        error_bound 0.25
        recursion_limit 1
    }
    #break
    #case (3)
    radiosity {             // --- Settings 3 (high quality) ---
        pretrace_start 0.08
        pretrace_end   0.005
        count 400
        error_bound 0.1
        recursion_limit 1
    }
    #break
    #case (4)
    radiosity {             // --- Settings 4 (medium quality, recursion_limit
2) ---
        pretrace_start 0.08
        pretrace_end   0.005
        count 350
        error_bound 0.15
        recursion_limit 2
    }
    #break
    #case (4)
    radiosity {             // --- Settings 5 (high quality, recursion_limit 2)
---
        pretrace_start 0.08
        pretrace_end   0.005
        count 350
        error_bound 0.1
        recursion_limit 2
    }
    #break
    #end  // end of switch
    } // end of global settings !!!!

    #default{ finish {emission 0.4 diffuse 0. ambient 0.}}

//--------------------------------------------------------------------------
#else

    #default{ finish{ ambient 0.1 diffuse 0.9 }
    } // for intel computers

#end // Radiosity_On > 0
//--------------------------------------------------------------------------


// HDRI environment
//--------------------------------------------------------------------------

#if (HDRlighting)

    sky_sphere{
        pigment{
            image_map{
                hdr "hdr/Mt-Washington-Hotel-Lookout_Gauss15.hdr"
                gamma 1.
                map_type 1
                interpolate 2
            }
        }
        rotate < 0,20,0> //rotate < 0,-60,0>  // adapt it to your direction
    } // end sky_sphere

    //light_source{ <0, 500, 0> color White*25 }

#else
    light_source
    { <10, 200, 0>/10, 1
    fade_distance 1 fade_power 20
    area_light x*3, y*3, 12, 12 circular orient adaptive 0
    }
#end


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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