POV-Ray : Newsgroups : povray.newusers : <no subject> Server Time
29 Mar 2024 04:40:15 EDT (-0400)
  <no subject> (Message 1 to 7 of 7)  
From: j13r
Subject: <no subject>
Date: 24 Nov 2018 22:10:01
Message: <web.5bfa1209c23a6d9d197b7bb0@news.povray.org>
Hi all,

I would like to make a image of magnetic field loops (similar to these:
https://ichef.bbci.co.uk/news/304/media/images/58947000/jpg/_58947314_162169main_trace_solar_flare_lg-1.jpg
https://martianchronicles.files.wordpress.com/2010/05/loops.gif
http://www.space.com/images/i/000/015/747/original/sun-as-art-swirls.jpg
more information here: https://en.wikipedia.org/wiki/Coronal_loop
)
The only difference is that I want them on a disk.

So far I tried to make the loops with multiple "torus" elements,
which are light sources at the same time.
I added more of these in larger sizes to give it a glow/halo effect.
This is all very similar to the lightsabre object example.

However, already with a few of these (8, see code below), the rendering is
getting slow. I think the reason is that the ~130 torus objects are overlapping
each other. This leads to a lot of root tests (742109138, see output below).
I was wondering if you could suggest a smarter technique?

It would also be good to be more flexible than with the torus.
I attached my code below.

Cheers,
       Johannes

$ povray +W400 +H400 -V +Olightarc.png +WT4 -d lightarc.pov
.....
----------------------------------------------------------------------------
Render Statistics
Image Resolution 400 x 400
----------------------------------------------------------------------------
Pixels:           160000   Samples:               0   Smpls/Pxl: 0.00
Rays:             301581   Saved:                 0   Max Level: 1/5
----------------------------------------------------------------------------
Ray->Shape Intersection          Tests       Succeeded  Percentage
----------------------------------------------------------------------------
Box                          401896791          652287      0.16
Cone/Cylinder                    89831           70491     78.47
CSG Intersection             401896791       120763539     30.05
Torus                        401896791       129236959     32.16
Torus Bound                  401896791       141316940     35.16
Bounding Box                 742109138       532510992     71.76
----------------------------------------------------------------------------
Roots tested:             141316940   eliminated:             16711239
Media Intervals:             125201   Media Samples:           1627613 (13.00)
Shadow Ray Tests:          17116032   Succeeded:              16027193
Shadow Cache Hits:              363
Transmitted Rays:            141581
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Render Time:
  Photon Time:      No photons
  Radiosity Time:   No radiosity
  Trace Time:       0 hours  3 minutes 56 seconds (236.095 seconds)
              using 4 thread(s) with 781.471 CPU-seconds total



Code:

// Magnetic field on a disk
//
#include "colors.inc"
#include "rand.inc"

// options of this script
#declare number_of_subarcs=8;
#declare number_of_arcs=8;
#declare disk_radius=4;

camera {
 location <4,1,4>
 look_at <0,0,0>
}
background {color Black}

// set up disk
cylinder {
 <0,0,0>
 <0,-0.04,0>
 disk_radius
 pigment { color White }
 finish { phong 0 diffuse 0.2 ambient 0 }
}

// a single arc is a thin half-torus
#declare arc=
difference {
 torus {
  5, 0.04           // major and minor radius
  rotate -90*x      // make vertical
 }
 box {<-6,-6,-1>, <6,0,1>}
}
// this thicker torus is used to make a halo glow around the thing arcs
#declare thickarc=
difference {
 torus {
  5, 0.5
  rotate -90*x
 }
 box {<-6,-6,-1>, <6,0,1>}
}

#declare r1=seed(5); // defines the shape
// now comes the combination of objects
#declare glowarc= union {
light_source { <0, 5, 0> color rgb <0,0,.5> }
// bright white arc
object {arc pigment{Clear} hollow
 interior { media{ emission <1,1,1>*100 } }
}
/*object {
 thickarc pigment{Clear} hollow
 interior { media{emission <.01,.01,1>*2 density { spherical scale <5,100,100> }
} }
 translate <0,0.01,0>
}*/
// fainter blue arcs
#declare i=0;
#while (i<number_of_subarcs)
 #declare i = i + 1;
 // we jitter them slightly
 #declare myscale = 1/Rand_Normal(1,0.05,r1);
 #declare xrot = Rand_Normal(0, 7, r1);
 #declare yrot = Rand_Normal(0, 3, r1);
 #declare zrot = 0;
 object {
  arc pigment{Clear} hollow
  scale myscale
  rotate <xrot,yrot,zrot>
  interior { media{
   emission <0,0,1>*pow(10,1+1*rand(r1))
  } }
 }
 // make fuzzy, weak halos with thickarc objects
 object {
  thickarc pigment{Clear} hollow
  scale myscale
  rotate <xrot,yrot,zrot>
  interior { media{emission <.01,.01,1>*(0.4/number_of_subarcs)} }
 }
#end
}

#declare r2=seed(2); // defines the locations

// now we can create a couple of these
#declare i=0;
#while (i<number_of_arcs)
 // find a uniform location on the disk to put it
 #declare myx = (rand(r2)-0.5)*3*2;
 #declare myy = (rand(r2)-0.5)*3*2;
 #declare d = sqrt(pow(myx,2)+pow(myy,2));
 #declare phi = atan2(myy,myx);
 // make sure the radius is not outside the disk
 #if (d < disk_radius-1)

 // orient the arc so it tends to point to the disk center
 #declare phi2 = phi + 45*(rand(r2)-0.5)/180*3.14;
 object{ glowarc
  scale 0.05+0.1*rand(r2)
  rotate y*(phi2/3.14*180+90)
  translate <d*sin(phi),0,d*cos(phi)>
 }
 #declare i = i + 1;
 #end
#end


Post a reply to this message

From: Bald Eagle
Subject: Re: <no subject>
Date: 25 Nov 2018 09:20:01
Message: <web.5bfaaf0f6f92e856765e06870@news.povray.org>
Perhaps you can consider doing something like:

http://bugman123.com/Physics/index.html
https://nylander.wordpress.com/category/physics/magnetism/


I don't immediately see any POV-Ray code, but perhaps you can decipher the
Mathematica code to get an idea of what he's doing.

Maybe what you're running into with your scene is similar to
http://www.econym.demon.co.uk/holetut/

where there are an astronomical number of ray intersection tests that need to be
done.

See one of Mike's solutions - defining a single object as an isosurface.
http://www.econym.demon.co.uk/holetut/holes2.htm

Perhaps you can use a similar solution by taking advantage of variable
substitution in the isosurface to create "copies" of your torus while having the
isosurface still be a single object:
http://www.econym.demon.co.uk/isotut/substitute.htm
(see near the bottom where he uses the mod() operator.

I hope maybe this helps some.


Post a reply to this message

From: green
Subject: Re: <no subject>
Date: 25 Nov 2018 10:25:01
Message: <web.5bfabe296f92e85688dbe9e30@news.povray.org>
"j13r" <buc### [at] gmxat> wrote:
> Hi all,
>
> I would like to make a image of magnetic field loops (similar to these:
>
https://ichef.bbci.co.uk/news/304/media/images/58947000/jpg/_58947314_162169main_trace_solar_flare_lg-1.jpg
> https://martianchronicles.files.wordpress.com/2010/05/loops.gif
> http://www.space.com/images/i/000/015/747/original/sun-as-art-swirls.jpg
> more information here: https://en.wikipedia.org/wiki/Coronal_loop
> )
> The only difference is that I want them on a disk.
>
> So far I tried to make the loops with multiple "torus" elements,
> which are light sources at the same time.
> I added more of these in larger sizes to give it a glow/halo effect.
> This is all very similar to the lightsabre object example.
>
> However, already with a few of these (8, see code below), the rendering is
> getting slow. I think the reason is that the ~130 torus objects are overlapping
> each other. This leads to a lot of root tests (742109138, see output below).
> I was wondering if you could suggest a smarter technique?
>
> It would also be good to be more flexible than with the torus.
> I attached my code below.
>
> Cheers,
>        Johannes
>
> $ povray +W400 +H400 -V +Olightarc.png +WT4 -d lightarc.pov
> .....
> ----------------------------------------------------------------------------
> Render Statistics
> Image Resolution 400 x 400
> ----------------------------------------------------------------------------
> Pixels:           160000   Samples:               0   Smpls/Pxl: 0.00
> Rays:             301581   Saved:                 0   Max Level: 1/5
> ----------------------------------------------------------------------------
> Ray->Shape Intersection          Tests       Succeeded  Percentage
> ----------------------------------------------------------------------------
> Box                          401896791          652287      0.16
> Cone/Cylinder                    89831           70491     78.47
> CSG Intersection             401896791       120763539     30.05
> Torus                        401896791       129236959     32.16
> Torus Bound                  401896791       141316940     35.16
> Bounding Box                 742109138       532510992     71.76
> ----------------------------------------------------------------------------
> Roots tested:             141316940   eliminated:             16711239
> Media Intervals:             125201   Media Samples:           1627613 (13.00)
> Shadow Ray Tests:          17116032   Succeeded:              16027193
> Shadow Cache Hits:              363
> Transmitted Rays:            141581
> ----------------------------------------------------------------------------
> ----------------------------------------------------------------------------
> Render Time:
>   Photon Time:      No photons
>   Radiosity Time:   No radiosity
>   Trace Time:       0 hours  3 minutes 56 seconds (236.095 seconds)
>               using 4 thread(s) with 781.471 CPU-seconds total
>
>
>
> Code:
>
> // Magnetic field on a disk
> //
> #include "colors.inc"
> #include "rand.inc"
>
> // options of this script
> #declare number_of_subarcs=8;
> #declare number_of_arcs=8;
> #declare disk_radius=4;
>
> camera {
>  location <4,1,4>
>  look_at <0,0,0>
> }
> background {color Black}
>
> // set up disk
> cylinder {
>  <0,0,0>
>  <0,-0.04,0>
>  disk_radius
>  pigment { color White }
>  finish { phong 0 diffuse 0.2 ambient 0 }
> }
>
> // a single arc is a thin half-torus
> #declare arc=
> difference {
>  torus {
>   5, 0.04           // major and minor radius
>   rotate -90*x      // make vertical
>  }
>  box {<-6,-6,-1>, <6,0,1>}
> }
> // this thicker torus is used to make a halo glow around the thing arcs
> #declare thickarc=
> difference {
>  torus {
>   5, 0.5
>   rotate -90*x
>  }
>  box {<-6,-6,-1>, <6,0,1>}
> }
>
> #declare r1=seed(5); // defines the shape
> // now comes the combination of objects
> #declare glowarc= union {
> light_source { <0, 5, 0> color rgb <0,0,.5> }
> // bright white arc
> object {arc pigment{Clear} hollow
>  interior { media{ emission <1,1,1>*100 } }
> }
> /*object {
>  thickarc pigment{Clear} hollow
>  interior { media{emission <.01,.01,1>*2 density { spherical scale <5,100,100> }
> } }
>  translate <0,0.01,0>
> }*/
> // fainter blue arcs
> #declare i=0;
> #while (i<number_of_subarcs)
>  #declare i = i + 1;
>  // we jitter them slightly
>  #declare myscale = 1/Rand_Normal(1,0.05,r1);
>  #declare xrot = Rand_Normal(0, 7, r1);
>  #declare yrot = Rand_Normal(0, 3, r1);
>  #declare zrot = 0;
>  object {
>   arc pigment{Clear} hollow
>   scale myscale
>   rotate <xrot,yrot,zrot>
>   interior { media{
>    emission <0,0,1>*pow(10,1+1*rand(r1))
>   } }
>  }
>  // make fuzzy, weak halos with thickarc objects
>  object {
>   thickarc pigment{Clear} hollow
>   scale myscale
>   rotate <xrot,yrot,zrot>
>   interior { media{emission <.01,.01,1>*(0.4/number_of_subarcs)} }
>  }
> #end
> }
>
> #declare r2=seed(2); // defines the locations
>
> // now we can create a couple of these
> #declare i=0;
> #while (i<number_of_arcs)
>  // find a uniform location on the disk to put it
>  #declare myx = (rand(r2)-0.5)*3*2;
>  #declare myy = (rand(r2)-0.5)*3*2;
>  #declare d = sqrt(pow(myx,2)+pow(myy,2));
>  #declare phi = atan2(myy,myx);
>  // make sure the radius is not outside the disk
>  #if (d < disk_radius-1)
>
>  // orient the arc so it tends to point to the disk center
>  #declare phi2 = phi + 45*(rand(r2)-0.5)/180*3.14;
>  object{ glowarc
>   scale 0.05+0.1*rand(r2)
>   rotate y*(phi2/3.14*180+90)
>   translate <d*sin(phi),0,d*cos(phi)>
>  }
>  #declare i = i + 1;
>  #end
> #end

the slow-down is the light_source in the union.  comment it out and there is an
approximately fifty-fold speedup (with my first guess, using whole tori, same as
b.eagle's 'difference' suspicion, which was a ~25% speed-up.)


Post a reply to this message

From: William F Pokorny
Subject: Re: <no subject>
Date: 25 Nov 2018 11:00:53
Message: <5bfac735$1@news.povray.org>
On 11/24/18 10:09 PM, j13r wrote:
> Hi all,
> 
> I would like to make a image of magnetic field loops (similar to these:
>
https://ichef.bbci.co.uk/news/304/media/images/58947000/jpg/_58947314_162169main_trace_solar_flare_lg-1.jpg
> https://martianchronicles.files.wordpress.com/2010/05/loops.gif
> http://www.space.com/images/i/000/015/747/original/sun-as-art-swirls.jpg
> more information here: https://en.wikipedia.org/wiki/Coronal_loop
> )
> The only difference is that I want them on a disk.
> 
...
> I was wondering if you could suggest a smarter technique?
> 
> It would also be good to be more flexible than with the torus.
> I attached my code below.
> 
> Cheers,
>         Johannes
> 

Hello.

With respect to performance and the current approach you can speed 
things up some by not having a light source in each of your glowarc 
shapes. At 130 of them I think you might be near the limit for light 
sources - but I don't immediately remember that limit. In any case some 
method to use fewer lights would help. These are only to light the disk.

You can also speed things up by not doing the differences to create half 
torus shapes(1). Instead of:

#declare arc=
difference {
  torus {
   5, 0.04           // major and minor radius
   rotate -90*x      // make vertical
   }
  box {<-6,-6,-1>, <6,0,1>}
}

use:

#declare arc=
   torus {
    5, 0.04           // major and minor radius
    rotate -90*x      // make vertical
   }

(1) - Your approach 'would' avoid a potential shadow calculation issue 
with POV-Ray where surfaces intersect, but you have clear textures so it 
shouldn't matter to use the torus shapes straight up.

With respect to better approaches, I cannot think of any at the moment 
which are easier.

Rather than many lights using radiosity with your emitting media will at 
some point be the better way to go. Further, using df3 files to create 
complex media would give you the flexibility in density control - even 
color with some set ups - but you have to figure you how to create the 
df3 files. There have been several threads related to df3's used in such 
a fashion in the last year or two.

As another idea. Given you have started with torus shapes there was a 
macro posted by Bruno Cabasson back in March of 2006 which can create a 
blob based torus shape. If you are running a pre-release of v3.8, blobs 
now support a potential pattern which can be used to create glowing 
media. I posted an image to povray.binaries.images (p.b.i) under the 
subject "Example of potential pattern use with emitting media" in 
October of 2016 which makes use of this newer technique. Combining the 
macro and potential pattern might be a way to handle the media as one 
large blob contained and blob-potential for the media density.

That rambling done, the bad news is your scene is a pretty good example 
showing current POV-Ray solver/solver set up issues with secondary rays.
In all approaches where the media density is not at 0.0 near surface 
tangents(2) we today too often get media artifacts due the media 
intervals being wrongly determined and mostly that gets to how the 
solvers are working. I've been working most of this year with the 
solvers and related code trying to clean up some of these long standing 
issues. I'll post comparison of the existing master branch to my 
'better' working branch to p.b.i. and add your scene as one of my test 
scenes. Today, you can 'sometimes' clean up many of the artifacts by 
scaling the entire scene up (or down) by 100 or 1000x.

(2) - The full story is much more complicated.

Bill P.


Post a reply to this message

From: Alain
Subject: Re: <no subject>
Date: 25 Nov 2018 12:49:36
Message: <5bfae0b0$1@news.povray.org>
Le 18-11-24 à 22:09, j13r a écrit :
> Hi all,
> 
> I would like to make a image of magnetic field loops (similar to these:
>
https://ichef.bbci.co.uk/news/304/media/images/58947000/jpg/_58947314_162169main_trace_solar_flare_lg-1.jpg
> https://martianchronicles.files.wordpress.com/2010/05/loops.gif
> http://www.space.com/images/i/000/015/747/original/sun-as-art-swirls.jpg
> more information here: https://en.wikipedia.org/wiki/Coronal_loop
> )
> The only difference is that I want them on a disk.
> 
> So far I tried to make the loops with multiple "torus" elements,
> which are light sources at the same time.
> I added more of these in larger sizes to give it a glow/halo effect.
> This is all very similar to the lightsabre object example.
> 
> However, already with a few of these (8, see code below), the rendering is
> getting slow. I think the reason is that the ~130 torus objects are overlapping
> each other. This leads to a lot of root tests (742109138, see output below).
> I was wondering if you could suggest a smarter technique?
> 
> It would also be good to be more flexible than with the torus.
> I attached my code below.
> 
> Cheers,
>         Johannes
> 

You use a lot of lights and it does cause a big slowdown.

Proposition :
1) Remove all those lights.
2) Use only full torus, not segments.
3) Enable radiosity.
4) In the radiosity block, add media on to allow your emissive media to 
participate.

Suggested radiosity block :
global_settings{
  radiosity{
   pretrace_end 0.01
   count 15000 33333
   nearest_count 4 20
   error_bound 0.7
   low_error_factor 0.3
   media on
   }
  }
Add to your scene :
#default radiosity{importance 0.01}
// get an average of 150 samples for most of the elements of the scene

Add to your emissive torus :
importance 1
// Use the full amount of samples for the very bright emissive objects

Finally, adjust the emission value to get reasonable illumination.

#declare glowarc= object{
//light_source { <0, 5, 0> color rgb <0,0,.5> }
// bright white arc
object {arc pigment{Clear} hollow
  interior { media{ emission <1,1,1>*100 } }// reduce emission as needed
  importance 1
}


#while (i<number_of_subarcs)
  #declare i = i + 1;
  // we jitter them slightly
  #declare myscale = 1/Rand_Normal(1,0.05,r1);
  #declare xrot = Rand_Normal(0, 7, r1);
  #declare yrot = Rand_Normal(0, 3, r1);
  #declare zrot = 0;
  object {
   arc pigment{Clear} hollow
   scale myscale
   rotate <xrot,yrot,zrot>
   interior { media{
    emission <0,0,1>*pow(10,1+1*rand(r1))
   } }
   importance 0.7
// less bright, but narrower
  }
  // make fuzzy, weak halos with thickarc objects
  object {
   thickarc pigment{Clear} hollow
   scale myscale
   rotate <xrot,yrot,zrot>
   interior { media{emission <.01,.01,1>*(0.4/number_of_subarcs)} }
   importance 0.5
// not as bright, can do away with slightly less samples
  }
#end
}


Post a reply to this message

From: j13r
Subject: Re: <no subject>
Date: 26 Nov 2018 18:45:00
Message: <web.5bfc851f6f92e856aec641b0@news.povray.org>
Thank you all for your suggestions. I hope to implement them soon.
(And sorry for forgetting to set a subject)

Cheers!


Post a reply to this message

From: clipka
Subject: Re: <no subject>
Date: 28 Nov 2018 08:53:39
Message: <5bfe9de3@news.povray.org>
Am 25.11.2018 um 17:00 schrieb William F Pokorny:

> With respect to performance and the current approach you can speed 
> things up some by not having a light source in each of your glowarc 
> shapes. At 130 of them I think you might be near the limit for light 
> sources - but I don't immediately remember that limit. In any case some 
> method to use fewer lights would help. These are only to light the disk.

I don't think we have any such limit. Not in current 3.8.0-alpha 
versions at any rate.


Post a reply to this message

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