POV-Ray : Newsgroups : povray.general : Rendering an electromagnetic field and photon rays Server Time
2 May 2024 00:21:01 EDT (-0400)
  Rendering an electromagnetic field and photon rays (Message 16 to 25 of 25)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Alain
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 16:59:19
Message: <59f0fb27$1@news.povray.org>
Le 17-10-25 à 11:48, cbpypov a écrit :
> 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
> 
> 

You should note that the second samples parameter is never used unless 
you use sampling method 1 or 2. By default, method 3 is used.
You correctly don't use intervals, so, it keeps it's proper default 
value of 1. Increasing that will only make your renders take a LOT more 
time.

As said elsewhere, using emissive media seems more appropriate as you 
are modeling an area of emission. It will also render much faster.


Post a reply to this message

From: Alain
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 17:14:07
Message: <59f0fe9f$1@news.povray.org>
Le 17-10-25 à 14:57, Stephen a écrit :
> 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>
Those can, and should, be omited.
>          media {
>            method     3
>            // intervals  10
MUST stay at 1. Don't use intervals is best.

>            //samples    1, 1
// May be omited : Use 10 samples by default
// Second value NOT used.
>            //confidence 0.900
>            //variance   0.008
>            //ratio      0.900
// All 3 NOT used with method 3
>            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
>            }
> 
>          }
> By default, method 3 use only 1 interval and 10 samples.
Using more that a single intervals will dramatically increase the time 
required by your render.
If you need more sampling, simply increase the samples vlue.
As only a single interval is used, only the first samples value is ever 
used. A second valus, if present, is silently ignored.
Also, confidence, variance and ratio, are used to distribute samples 
within various intervals, they are not used, and silently ignored.

intervals 1 samples 500
is much faster than
intervals 10 samples 5
for 10 times as many samples.


Post a reply to this message

From: Stephen
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 17:37:33
Message: <59f1041d$1@news.povray.org>
On 25/10/2017 22:14, Alain wrote:
> Le 17-10-25 à 14:57, Stephen a écrit :
>> 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>
> Those can, and should, be omited.

No chance. I use a modeller and that is what it outputs
But it is good that you mention it.

>>          media {
>>            method     3
>>            // intervals  10
> MUST stay at 1. Don't use intervals is best.
> 

Holes in the brain. I keep getting this the wrong way round. :-(


>>            //samples    1, 1
> // May be omited : Use 10 samples by default
> // Second value NOT used.
>>            //confidence 0.900
>>            //variance   0.008
>>            //ratio      0.900
> // All 3 NOT used with method 3
>>            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
>>            }
>>
>>          }
>> By default, method 3 use only 1 interval and 10 samples.
> Using more that a single intervals will dramatically increase the time 
> required by your render.
> If you need more sampling, simply increase the samples vlue.
> As only a single interval is used, only the first samples value is ever 
> used. A second valus, if present, is silently ignored.
> Also, confidence, variance and ratio, are used to distribute samples 
> within various intervals, they are not used, and silently ignored.
> 
> intervals 1 samples 500
> is much faster than
> intervals 10 samples 5
> for 10 times as many samples.

I wonder how many times I will need to be told. I seem to have a blind 
spot for this. I hope you don't get bored easily. ;-)

But I should not post bad information.



-- 

Regards
     Stephen


Post a reply to this message

From: Bald Eagle
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 25 Oct 2017 17:45:00
Message: <web.59f104fd9b56bbdd5cafe28e0@news.povray.org>
Car tire is all fixed.
25 min of driving time, and already I get a flat.   :|
UN-believable.

"cbpypov" <nomail@nomail> wrote:
> Moreover, I'd really enjoy getting your code and to see what can do with it :)

....and here it is:
(be aware that copying and pasting from a forum post may give you bad formatting
results, and you'll have to fix any CR/NL line errors)
I couldn't figure out to get the original Processing code - supposedly he has
all the code posted for each of his Code Challenge videos.
Perhaps someone else can figure it out.  (I still suck at using GitHub)
============================================================================

#version 3.7;
global_settings { assumed_gamma 1.0 }

//------------------------------------------
// SDL for Perlin Noise flow field
// NOT WORKING - vector array looks fine, it's the "movement" of the points that
the problem
// the points don't follow the flow field.
// The loop at the end just simulates an animation, without having to render all
the frames.
// Bill Walker - 2017
//------------------------------------------

#include "colors.inc"
#include "functions.inc"

#declare Aspect = image_width/image_height;

camera {
 location  <(image_width/2), (image_height/2), -600>
 right x*Aspect
 look_at <(image_width/2), (image_height/2), 0>
}

light_source { <10, 50, 0>  color rgb <1, 1, 1>}

sky_sphere { pigment {White} }

//=====================================================================================================================
==

#declare E = 0.000001;
#declare inc = 0.02;
#declare Scale = 10;

#declare cols = floor (image_width / Scale);
#declare rows = floor (image_height / Scale);
#declare Particles = array [100];
#declare FF = cols*rows;
//#debug concat ( " FF = ", str (FF, 3, 1),  "\n")
#declare FlowField = array [cols * rows];
#declare Mag = 1;
#declare MaxSpeed = 4;

#declare Seed = seed (12345);

#macro Vect (A)
 <cos(A), sin(A), 0>
#end // end macro Vect

#macro Particle ()
 #declare Pos = <rand(Seed)*image_width, rand(Seed)*image_height>;
 #declare Vel = <0, 0>; //<rand(Seed), rand(Seed)>;
 #declare Acc = <0, 0>;
 #declare PrevPos = Pos;
 array [4] {Pos, Vel, Acc, PrevPos}
#end // end macro Particles

#macro Update (P)
 #declare P[1] = P[1] + P[2];
 #declare P[1] = <min (P[1].x, MaxSpeed), min (P[1].y, MaxSpeed)>;  // limits
speed to max speed
 #declare P[0] = P[0] + P[1];
 #declare P[2] = P[2] * 0;
#end // end macro Update

#macro Follow (P, Vectors)
 #declare XX = floor (P[0].x / Scale);
 #declare YY = floor (P[0].y / Scale);
 #declare Index = XX + YY * cols;
 //#debug concat ( " Index = ", str (Index, 3, 1),  "\n")
 #declare F = Vectors [Index];
 Force (P, F)
#end // end macro Follow

#macro Force (P, F)
 #declare P[2] = P[2] + <F.x, F.y>;
#end // end macro Force

#macro Show (P)
 //sphere {<P[0].x, P[0].y, 0> 0.5 texture {pigment {Color} finish {specular
0.4}} }
 cylinder {<P[3].x, P[3].y, 0>, <P[0].x, P[0].y, 0> 1 texture {pigment {Color}
finish {specular 0.4}} }
 UpdatePrev (P)
#end // end macro Show

#macro UpdatePrev (P)
 //#debug concat ( "Prev = ", vstr(3, P[3], ", ", 2, 0), " \n")
 #declare P[3] = P[0]+<E,E>;
 //#debug concat ( "Current = ", vstr(3, P[3], ", ", 2, 0), " \n")
#end // end macro UpdatePrev

#macro Edges (P)
 //#local PX = P[0].x;
 //#local PY = P[0].y;
 #if (P[0].x > image_width)  #declare P[0] = <1, P[0].y>;     UpdatePrev (P)
#end
 #if (P[0].x < 0)    #declare P[0] = <image_width-1, P[0].y>;  UpdatePrev (P)
#end
 #if (P[0].y > image_height)  #declare P[0] = <P[0].x, 0>;     UpdatePrev (P)
#end
 #if (P[0].y < 0)    #declare P[0] = <P[0].x, image_height-1>;  UpdatePrev (P)
#end
#end // end macro Edges


#macro Draw()
 #declare zoff = 0;
 #local yoff = 0;
 #for (Y, 0, rows-1)
  #local xoff = 0;
  #for (X, 0, cols-1)
   #local index = X + Y * cols;

   #local r = f_noise_generator (xoff, yoff, zoff, 3); // 3 = Perlin noise
   #local A = degrees (r*2*pi);
   #local V = Vect (A)*Mag;
   #declare FlowField [index] = V;

   #local xoff = xoff + inc;

   #local Grayscale = 0;
   //#local HSV_Angle = rand (Seed)*360;
   //#local Color = CHSV2RGB (<HSV_Angle, 1, 1>);
   //box {<X*Scale, (Y/Aspect)*Scale, 0>, <X*Scale+Scale,
((Y*Scale)/Aspect)+Scale, 0.1> pigment {rgb Grayscale}}
   cylinder {<0,0,0>, V*(1/Mag)*Scale 0.5 translate <X*Scale, Y*Scale, 0>
pigment {rgb Grayscale}}
  #end // end for X
  #local yoff = yoff + inc;
  //#declare zoff = zoff + 0.0003;
 #end // end for Y
#end // end macro Draw

//Draw()
#for (i, 0, 99)
 #declare Particles [i] = Particle();  // create a particle with position,
velocity, accel
#end

#for (Clock, 0, 500)
Draw() // update vectors

#for (i, 0, 99)
 #declare Color = CHSV2RGB (<i*3.6, 1, 1>);

 Follow (Particles [i], FlowField)   // pair particle at location with vector in
that part of field
 Update (Particles [i])     // update particle position, velocity, acceleration
 Edges  (Particles [i])     // wrap particles around edges
 Show   (Particles [i])     // plot particle positions / paths

#end // end for i

#end // end for Clock


Post a reply to this message

From: Tor Olav
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 26 Oct 2017 10:22:53
Message: <59f1efbd$1@news.povray.org>
Hi

Back in 2003 Jaap Frank made some nice and interesting media images that 
might be relevant to you.

See this thread:
Newsgroup: povray.binaries.scene-files
Subject: Quantum Waves in Media
From: Jaap Frank
Date: 12 Jan 2003 04:45:23

Here's a link to that thread in the web interface:
http://news.povray.org/povray.binaries.scene-files/thread/%3C3e20f2e3%40news.povray.org%3E/

You'll find both images and code in that thread.

-- 
Tor Olav
http://subcube.com


On 10/25/2017 05:48 PM, cbpypov 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
>
> 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: cbpypov
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 26 Oct 2017 14:40:01
Message: <web.59f22b389b56bbddbb23337d0@news.povray.org>
I guess it is best to move the conservation to the images group:

http://news.povray.org/povray.binaries.images/thread/%3Cweb.59f0ee4b3a8b1675667cbe5f0%40news.povray.org%3E/

I hope to be hearing from you there :)


Post a reply to this message

From: cbpypov
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 26 Oct 2017 15:15:01
Message: <web.59f2341f9b56bbddbb23337d0@news.povray.org>
Oh my word, I have to apologize a hundred times! I somehow did not notice the
button "Go to next X messages", so that I overlooked any of your messages after
my coding example... And there are so many of them!

I'll go through them and try to address everthing. Thank you very much...


Post a reply to this message

From: cbpypov
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 26 Oct 2017 15:25:00
Message: <web.59f236649b56bbddbb23337d0@news.povray.org>
Tor Olav <tor### [at] TOBEREMOVEDgmailcom> wrote:
> Hi
>
> Back in 2003 Jaap Frank made some nice and interesting media images that
> might be relevant to you.
>
> See this thread:
> Newsgroup: povray.binaries.scene-files
> Subject: Quantum Waves in Media
> From: Jaap Frank
> Date: 12 Jan 2003 04:45:23
>
> Here's a link to that thread in the web interface:
>
http://news.povray.org/povray.binaries.scene-files/thread/%3C3e20f2e3%40news.povray.org%3E/
>
> You'll find both images and code in that thread.
>
> --
> Tor Olav
> http://subcube.com
>


Hi Tor Olav,

thank you very much for pointing that out! I had a look at the files, but
somehow I cannot figure out how to find anything that helps me :( Maybe I don't
have enough practice in Pov-ray coding, I think you all would call me an
absolute beginner. So I see how far I can go with Bald Eagles suggestions and
maybe it is better to discuss some code of mine (I'll try to post better code
next time :) )


Post a reply to this message

From: Bald Eagle
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 26 Oct 2017 16:05:01
Message: <web.59f23f639b56bbddc437ac910@news.povray.org>
"cbpypov" <nomail@nomail> wrote:

> Hi Tor Olav,
>
> thank you very much for pointing that out! I had a look at the files, but
> somehow I cannot figure out how to find anything that helps me :( Maybe I don't
> have enough practice in Pov-ray coding, I think you all would call me an
> absolute beginner. So I see how far I can go with Bald Eagles suggestions and
> maybe it is better to discuss some code of mine (I'll try to post better code
> next time :) )

TOK, thanks for posting that link - I had forgotten about that scene and how it
was rendered.  As a [former] chemist, it's one I remember well!  :)

Ignore most of the top part of that scene, as it's mostly just setting up the
quantum mechanical spherical harmonics for the different wave functions of the
electron orbital shells.
So, basically there's a lot of stuff, and then that all gets boiled down to a
function. I posted the line from Jaap's code in my last post showing how he uses
that function to shape his media rather than the spherical function.

The spherical function is of course sqrt( pow(x,2)+pow(y,2)+pow(z,2))-Radius = 0

#declare Fade = function {Radius - sqrt( pow(x,2)+pow(y,2)+pow(z,2))}

ought to give you scalar values that start at Radius and fade to zero at the
radius of the sphere.  Use that as your density function [for now] ;)


Post a reply to this message

From: cbpypov
Subject: Re: Rendering an electromagnetic field and photon rays
Date: 26 Oct 2017 16:25:00
Message: <web.59f243919b56bbddbb23337d0@news.povray.org>
> TOK, thanks for posting that link - I had forgotten about that scene and how it
> was rendered.  As a [former] chemist, it's one I remember well!  :)
>
> Ignore most of the top part of that scene, as it's mostly just setting up the
> quantum mechanical spherical harmonics for the different wave functions of the
> electron orbital shells.
> So, basically there's a lot of stuff, and then that all gets boiled down to a
> function. I posted the line from Jaap's code in my last post showing how he uses
> that function to shape his media rather than the spherical function.
>
> The spherical function is of course sqrt( pow(x,2)+pow(y,2)+pow(z,2))-Radius = 0
>
> #declare Fade = function {Radius - sqrt( pow(x,2)+pow(y,2)+pow(z,2))}
>
> ought to give you scalar values that start at Radius and fade to zero at the
> radius of the sphere.  Use that as your density function [for now] ;)


Please see my posts in the image section: I was using exponential decay before I
saw your linear decay example given here. I think exp might be a little smoother
and the glowing is now rather nice :)


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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