File:Main sequence star of type m 1.png

Original file(1,280 × 1,024 pixels, file size: 631 KB, MIME type: image/png)

Captions

Captions

Red Dwarf

Summary edit

Description
English: Red Dwarf , type M main sequence star
Date
Source Own work
Author Merikanto

This image is generrated with Persistence of Vision ray tracer and nkflare.inc by Nathan Kopp.

Povray 3.7 code

global_settings { max_trace_level 30 }

  1. include "colors.inc"
  2. include "functions.inc"
  1. declare sky_vect = z;
  2. declare cam_loc = <0,0,-55>;
  3. declare lookat = <0,0,0>;

camera {

 location  cam_loc
 direction <0.0,     0.0,  1.04>
 sky       sky_vect   // rihght hand
 up        <0.0,     0.0,  1.0>  // z up
 right     <1.33333, 0.0,  0.0>
 look_at   lookat

}

  1. declare surfa1= sphere{
   <0,0,0>, 1
//   pigment{color rgbt <1,1,0,0> }
// finish {ambient 1}   
   pigment{
   //color rgbt <1,1,0.9,0> 
   //  bozo
     //bumps
    granite 
     scale 7   
     /*
       color_map 
       {
       	[0 rgb <0.0,0.0,0.0>]//border

[0.08 rgb <0.0,0.0,0.0>]// [0.16 rgb <0.1,0.0,0.0>]// [0.3 rgb <0.9,0.0005,0.0>]// [1 rgb <1,0,0>]//center } // end color_map

   */
         
       color_map 
       {
       	[0 rgb <0.0,0.0,0.0>]//border

[0.12 rgb <0.0,0.0,0.0>]// [0.25 rgb <0.1,0.0,0.0>]// [0.5 rgb <0.9,0.0005,0.0>]// [1 rgb <1,0,0>]//center } // end color_map

   }
 finish {ambient 30}   
 
 rotate x*110
 //rotate y*-40

} ;

  1. declare kromos1=difference

{ sphere {0,1.0005} sphere {0,1.0001}


 pigment { color rgbf 1.0 }
 hollow
 interior {
 
// fade_distance 1
 
//  fade_power 2
   media {
   // emission 1
emission <0,0,1>*0.5
     method 3
     intervals 1
     samples 5, 5
     
   }
   media {
     absorption <0.3,0.3,0.1>*320
     method 3
     intervals 1
     samples 5, 5
   }
 }
 
 

};

  1. declare kor1=sphere{
   <0,0,0>, 1


   pigment{rgbt 1}

   hollow

interior

{ media{

emission 0.05


density{ spherical ramp_wave

  //  onion

// turbulence 0.05

color_map { [0.0 rgbf <0.001,0.0,0,1.0>]//border [0.07 rgbf <0.02,0.0,0.0,0.95>]// [0.15 rgbf <0.05,0.0,0.0,0.9>]// [0.2 rgbf <0.12,0,0,0.8>]// [0.3 rgbf <0.35,0,0,0.6>]//center [0.5 rgbf <0.5,0,0,0.4>]//center [0.5 rgbf <0.8,0,0,0.2>]//center } // end color_map } // end of density } // end of media --- } // end of interior

 //scale 1.85 
  scale 1.7
 

} ;

  1. declare white_flares = object

{

 difference {
  
  sphere {0, 1.05}
   sphere {0, 1.001}
  }
  
  hollow no_shadow
  
    pigment { 
    rgbt 1 }
 
 
    interior

{

media { emission 1.25

density { marble phase (.55) turbulence 0.8 frequency 1.3 density_map {

               [0 rgb <.01,0,0>]
               [.75 rgb <.02,0,0>]
               [.85 rgb <.33,0,0>*0.25]
               [.925 rgb <.5,0,0>*0.4]
               [1 rgb <0.5,0,0>*0.6]
               }
        triangle_wave scale 0.67 rotate <60,45,100>
        }


         samples 1,1 intervals 1 confidence .1 // quite fast settings
        method 3
      } //MEDIA 1
       
    } // INTERIOR
      
 

}; // ... halo 1

  1. declare whitesun1= union {

object {surfa1} object {kromos1} object {white_flares} object {kor1}

scale 11 }

object {whitesun1}

  1. declare light_loc = <0,0,100>;
  1. include "lux1.flr"

//#include "lux2.flr"


  1. include "nkflare.inc"

nkflare.inc flare settings

// nkflare.inc lens flare, sun rays, red

  1. declare lf_glows = array[1]
  2. declare lf_glow_sca = array[1]
  3. declare lf_glow_rot = array[1]
  4. declare lf_glow_dst = array[1]

// primary glow

  1. declare lf_glows[0] = pigment {

function {

0.1*( f_bozo( atan2(x,y) ,0,0 )*0.02/(x*x+y*y) + f_bozo( atan2(x,y)*8 ,0,0 )*0.005/(x*x+y*y)+ f_bozo( atan2(x,y)*32 ,0,0 )*0.01/(x*x+y*y)+ f_bozo( atan2(x,y)*720 ,0,0 )*0.01/(x*x+y*y) )


}

color_map {

   [0 color <0,0,0>  transmit 0.5 ]
   [0.5 color <0.3,0,0> transmit 0.5 ]
   [1 color <1,0,0> transmit 0.5 ]
  
 }


}

  1. declare lf_glow_sca[0] = <1.8,1.8,1.8> ;
  1. declare lf_glow_rot[0] = 500;
  2. declare lf_glow_dst[0] = 0;


// *************************************** // sparkles

  1. declare lf_spk_info = array[2][10] {
 {0,0,0,0.0,0,0.0,0,0.00, 0, 0}
  {0,0,0,0.0,0,0.0,0,0.00, 0, 0}

}

  1. declare lf_spk_vect = array[2][3] {
 {<0.0,0.0,0.0> ,<0,0,0> ,<0,0,0> }
   {<0.0,0.0,0.0> ,<0,0,0> ,<0,0,0> }

}



/*

// *************************************** // sparkles

  1. declare lf_spk_info = array[2][10] {
 {0,0,1,0.1,1,0.05,0,0.05, 1, 1}
 {0,0,1,0.050,2,0.04,0,0.1, 2, 1}

}

  1. declare lf_spk_vect = array[2][3] {
 {<0.1,0.1,0.1> ,<0,0,0> ,<1,1,1> }
 {<0.1,0.1,0.1> ,<0,0,0> ,<1,1,1> }

}

  • /


/*

  1. declare lf_spot_types = array[2] {
 "spot","dot"}
  1. declare lf_spot_info = array[2][10] {
 {1,1,1.0,0.0122449,1,0,0.00134944,0.05,0.0125, 1}
 {1,1,1.0,0.0666667,1,0.5,0.2,0.04,0.02,1}

}

  1. declare lf_spot_vect = array[2][2] {
 {<0.15,0.15,0.105> ,<0.06,0.06,0.06> }
 {<0.1,0.25,0.125> ,<0.03,0.03,0.03> }

}

*/

original nkflare.inc by Nathan Kopp

// // N K F l a r e . I N C // ------------------------------------------ // // Lens Flare "plug-in" for POV-RAY 3.1 // // Copyright (C) 1997-1998 Nathan Kopp // // Version 5.0 October, 1998 // // ------------------------------------------ // // THIS SOFTWARE IS CURRENTLY IN BETA-TESTING STAGES. // // Documentation for NKFlare is in the file // NKFlare.TXT. NKFlare.TXT must accompany // NKFlare.INC in all distributions. // // NKFlare is a very flexible lens flare include file for POV-Ray 3.1. // // Adding lens flare to your POV scene is now a simple as adding the // following few lines to your scene description file: // // #declare cam_loc = <x,y,z> // use the x, y, and z of your camera // #declare light_loc = <x,y,z> // use the x, y, and z of the light // // you wish to flare // #declare lookat = <x,y,z> // the look_at vector of your camera // #declare sky_vect = <x,y,z> // the sky vector of your camera // #include "35mm.flr" // or whatever pre-defined flare you like // #include "NKFlare.inc" // create the lens flare // // ------------------------------------------

  1. local crisps = 0;
  2. local sspread = 1;
  3. local smirror = 2;
  4. local ssize = 3;
  5. local sarms = 4;
  6. local swidth = 5;
  7. local srand = 6;
  8. local ssrand = 7;
  9. local sseed = 8;
  10. local srot = 9;
  1. local dnum = 0;
  2. local dskip = 1;
  3. local dopp = 2;
  4. local ddist = 3;
  5. local ddistpwr = 4;
  6. local doffset = 5;
  7. local drnd = 6;
  8. local dsize = 7;
  9. local dsizernd = 8;
  10. local dseed = 9;

//#version -1.0;

  1. declare lf_Clear = rgbt<0,0,0,.5>;

//#macro NKFlare (light_loc, cam_loc, lookat, sky_vect)

// if they defined "flare_type" and it is not blank, then // use it for the include filename //

  1. ifdef (flare_type)
 #if (strlen(flare_type)>0)
   #if (strcmp(flare_type, "camcorder")=0)
     #include "camcordr.flr"
   #else #if (strcmp(flare_type, "smallstar")=0)
     #include "smlstar.flr"
   #else #if (strcmp(flare_type, "warpflare")=0)
     #include "warp.flr"
   #else
     #declare filename = concat(flare_type,".flr")
     #if (file_exists(filename))
       #include filename
     #else
       #debug concat("Could not find the file: ",filename)
       #debug "\n"
     #end
   #end #end #end
 #end
  1. end

// ***************************************************************** // ** Additional rotation degrees. //

  1. ifndef (flare_rotate) #declare flare_rotate = 0; #end
  2. ifndef (flare_auto_rotate) #declare flare_auto_rotate = false; #end
  3. ifndef (spots_auto_rotate) #declare spots_auto_rotate = false; #end
  4. ifndef (disc_size) #declare disc_size = .001; #end
  5. ifndef (flare_size) #declare flare_size = <1,1,1>; #end
  6. ifndef (AmbientLight) #declare AmbientLight = <1,1,1>; #end

// ***************************************************************** // ************ DECLARE TRANSFORM VARIABLES ******************** // *****************************************************************

// ***************************************************************** // ** compute relative location of camera to light source // ** compute relative location of camera to center // *****************************************************************

  1. local lf_2light = cam_loc - light_loc;
  2. local lf_2ctr = cam_loc - lookat;

// Now project lf_2light onto lf_2ctr to find new lf_2ctr vector. This gives us // a vector from cam_loc to lf_2ctr that is perpendecular to the relative // lookat vector. The newctr vector is used in for multiple flare // spot calculation.

  1. local lf_newctr = lf_2ctr * vdot(lf_2light,lf_2ctr) / (vlength(lf_2ctr)*vlength(lf_2ctr));

// ***************************************************************** // ** compute rotation values for x and z axes // *****************************************************************

// matrix concept by John VanSickle <vansickl@erols.kosher.com>

  1. local CamD = vnormalize(lookat-cam_loc);
  2. local CamR = vnormalize(vcross(sky_vect,CamD));
  3. local CamU = vnormalize(vcross(CamD,CamR));
  1. local CamRc = vnormalize(vcross(lf_2light,CamD));
  2. local CamUc = vnormalize(vcross(CamD,CamRc));

/* cylinder { // <0,0,0>, CamU, .1

 <0,0,0>,<0,1,0> .1
     matrix < CamRc.x,CamRc.y,CamRc.z,
              CamUc.x,CamUc.y,CamUc.z,
              CamD.x,CamD.y,CamD.z,   // maybe 0,0,0 (but then no inverse)
              0,0,0 >  // no translate
 
 scale .1
 translate cam_loc+.5*CamD
 pigment{rgb<1,0,0>}
 finish{ambient 1}

}

  • /

// ***************************************************************** // ** set up lf_StarTex for the sparkle textures // *****************************************************************

  1. local lf_StarTex=array[dimension_size(lf_spk_info,1)]
  1. local i=0;
  2. ifdef (lf_spk_info)
  3. while(i<dimension_size(lf_spk_info,1))
 #local star_seed = seed(lf_spk_info[i][sseed]);
 #local lf_temp_tr = 0.0;
 #if (lf_spk_info[i][crisps] = true) #local lf_temp_tr = 1.0; #end
 #if (lf_spk_info[i][sarms] > 0)
   #local lf_StarTex[i] = pigment {
   radial
   #if (lf_spk_info[i][smirror] = true)
     frequency 2
     #local lf_tmp_width = lf_spk_info[i][swidth] / lf_spk_info[i][sarms] * 2;
     #local lf_ave_dist  = 1 / lf_spk_info[i][sarms] * 2;
   #else
     frequency 1
     #local lf_tmp_width = lf_spk_info[i][swidth] / lf_spk_info[i][sarms];
     #local lf_ave_dist  = 1 / lf_spk_info[i][sarms];
   #end
 
   #local lf_loc = 0;
   color_map{
     [0.0          color lf_spk_vect[i][0] transmit .5]
     [lf_tmp_width color lf_spk_vect[i][0]*lf_temp_tr transmit .5]
     [lf_tmp_width color lf_Clear              ]
     #local lf_loc = lf_loc +  lf_ave_dist + (rand(star_seed)*2 - 1)*lf_spk_info[i][srand]*(lf_ave_dist-2*lf_tmp_width);
     #while (lf_loc <(1-2*lf_tmp_width))
       #local lf_s_color = lf_spk_vect[i][0] + lf_spk_vect[i][1] * <(rand(star_seed) * 2 - 1),(rand(star_seed) * 2 - 1),(rand(star_seed) * 2 - 1)>;
     
       [lf_loc - lf_tmp_width  color lf_Clear ]
       [lf_loc - lf_tmp_width  color lf_s_color*lf_temp_tr transmit .5]
       [lf_loc                 color lf_s_color            transmit .5]
       [lf_loc + lf_tmp_width  color lf_s_color*lf_temp_tr transmit .5]
       [lf_loc + lf_tmp_width  color lf_Clear ]
     
       #declare lf_loc = lf_loc +  lf_ave_dist + (rand(star_seed)*2 - 1)*lf_spk_info[i][srand]*(lf_ave_dist-2*lf_tmp_width);
     #end
     [1-lf_tmp_width color lf_Clear ]
     [1-lf_tmp_width color lf_spk_vect[i][0]*lf_temp_tr transmit .5]
     [1.0            color lf_spk_vect[i][0]            transmit .5]
   }
  rotate <90,0,-90>
 }
 #end
 #local i = i+1;
  1. end
  2. end
  1. local lf_Finish = finish {
 //#version -3.1;
 refraction 2.0
 //#version 3.1;
 specular 0
 phong 0
 diffuse 0.0
 reflection 0.0
 #declare lf_bright = <1,1,1>;
 #ifdef (AmbientLight)
     #declare lf_bright = lf_bright /  AmbientLight;
 #end
 #ifdef (flare_brightness)
   #declare lf_bright = lf_bright * flare_brightness;
 #end
 #ifdef (bright_background) #if (bright_background)
   #declare lf_bright = lf_bright * 0.3;
 #end #end
 ambient lf_bright*2

}

// ***************************************************************** // ** First, make sure the camera is in front of the camera by // checking the plane with normal from cam_loc to lookat. // // Plane equation: a(x-x0) + b(y-y0) + c(z-z0) = 0 // // *****************************************************************

  1. local cam_plane = 1 * vdot(lf_2ctr, lf_2light);
  1. if (cam_plane < 0)
 #warning "Light is behind camera or behind the planet.  Lens flare not created."
 // *****************************************************************
 // Skip lens flare completely... can have an impact on
 // render speed.
 // *****************************************************************
  1. else

// ***************************************************************** // ********** THE ACTUAL DISCS FOR LENS FLARE ********************** // *****************************************************************

  1. ifndef (lf_flares_drawn) #declare lf_flares_drawn = 0; #end

// ***************************************************************** // ********** glows **********************

  1. local i = 0;
  2. while(i<dimension_size(lf_glows,1))
 #declare lf_new_disc_size = disc_size + .001 * lf_flares_drawn;
 
 disc {
   <0,0,0>, z, 1/2
   texture {
     // ***************** Primary flare ********************
     pigment { lf_glows[i] }
     finish { lf_Finish }
   }
   scale lf_glow_sca[i] * lf_new_disc_size * flare_size
   #local lf_2spot = lf_2light + (lf_newctr - lf_2light) * lf_glow_dst[i];
   #if (lf_glow_rot[i] >= 1000)
     rotate (lf_glow_rot[i] - 1000)*z
     matrix < CamRc.x,CamRc.y,CamRc.z,
              CamUc.x,CamUc.y,CamUc.z,
              CamD.x,CamD.y,CamD.z,   // maybe 0,0,0 (but then no inverse)
              0,0,0 >  // no translate
   #else
     rotate lf_glow_rot[i]*z
     matrix < CamR.x,CamR.y,CamR.z,
              CamU.x,CamU.y,CamU.z,
              CamD.x,CamD.y,CamD.z,   // maybe 0,0,0 (but then no inverse)
              0,0,0 >  // no translate
   #end
   #local lf_dist = 1/( vdot(lf_2spot,lf_2ctr)/(vlength(lf_2ctr)*vlength(lf_2spot)) );
   translate cam_loc + lf_new_disc_size * vnormalize(-lf_2spot)*lf_dist
   no_shadow hollow
 }
 #declare lf_flares_drawn = lf_flares_drawn + 1;
 #local i = i+1;
  1. end

// ***************************************************************** // ********** sparkles **********************

  1. ifdef (lf_spk_info)
  1. local i = 0;
  2. while (i<dimension_size(lf_spk_info, 1))
  1. if (lf_spk_info[i][sspread])
   #local lf_new_disc_size = disc_size + .001 * lf_flares_drawn;
   disc {
     <0,0,0>, z, lf_spk_info[i][ssize]*3/2
     texture {
     // ************** Star-type flare *********************
     pigment {
       wood scallop_wave
       pigment_map {
         [ 0.0                        lf_StarTex[i]]
         [ lf_spk_info[i][ssize]      lf_StarTex[i]]
         [ lf_spk_info[i][ssize] * 3  lf_Clear  ]
         [ 1                          lf_Clear  ]
       }
     }
     finish { lf_Finish }
     }
     
     scale lf_spk_vect[i][2] * lf_new_disc_size * flare_size
   #if (lf_spk_info[i][srot] >= 1000)
     rotate (lf_spk_info[i][srot] - 1000)*z
     matrix < CamRc.x,CamRc.y,CamRc.z,
              CamUc.x,CamUc.y,CamUc.z,
              CamD.x,CamD.y,CamD.z,   // maybe 0,0,0 (but then no inverse)
              0,0,0 >  // no translate
   #else
     rotate lf_spk_info[i][srot]*z
     matrix < CamR.x,CamR.y,CamR.z,
              CamU.x,CamU.y,CamU.z,
              CamD.x,CamD.y,CamD.z,   // maybe 0,0,0 (but then no inverse)
              0,0,0 >  // no translate
   #end
   
     #local lf_dist = 1/( vdot(lf_2light,lf_2ctr)/(vlength(lf_2ctr)*vlength(lf_2light)) );
     translate cam_loc + lf_new_disc_size * vnormalize(-lf_2light)*lf_dist
     no_shadow hollow
   }
   #declare lf_flares_drawn = lf_flares_drawn + 1;
  1. else // star_spread
 // **************************************
 // Create a bunch of streaks to simulate
 // the sparkle pattern
 //
 #ifdef(lf_clock)
   #local star_seed1 = seed(lf_spk_info[i][sseed]+floor(lf_clock));
   #local star_seed2 = seed(lf_spk_info[i][sseed]+floor(lf_clock)+1);
 #end
   
 #local star_seed = seed(lf_spk_info[i][sseed]);
 #if (lf_spk_info[i][smirror])
   #local lf_num = lf_spk_info[i][sarms] / 2;
 #else
   #local lf_num = lf_spk_info[i][sarms];
 #end
 
 #declare lf_tmp_width = lf_spk_info[i][swidth] / lf_spk_info[i][sarms] * .25;
 #declare lf_ave_ang  = 360 / lf_spk_info[i][sarms];
 #while (lf_num > 0)
   #ifdef(lf_clock)
     #local lf_tmp_size1 = lf_spk_info[i][ssize] + (rand(star_seed1) * 2 - 1) * lf_spk_info[i][ssrand]*lf_spk_info[i][ssize];
     #local lf_tmp_size2 = lf_spk_info[i][ssize] + (rand(star_seed2) * 2 - 1) * lf_spk_info[i][ssrand]*lf_spk_info[i][ssize];
     #local lf_tmp_size = lf_tmp_size2*(lf_clock-floor(lf_clock))+lf_tmp_size1*(1-(lf_clock-floor(lf_clock)));
   #else
     #local lf_tmp_size = lf_spk_info[i][ssize] + (rand(star_seed) * 2 - 1) * lf_spk_info[i][ssrand]*lf_spk_info[i][ssize];
   #end
   #declare lf_tmp_ang  = lf_num * lf_ave_ang + (rand(star_seed) * 2 - 1) * lf_spk_info[i][srand] * lf_ave_ang;
   #declare lf_s_color = lf_spk_vect[i][0] + lf_spk_vect[i][1] * <(rand(star_seed) * 2 - 1),(rand(star_seed) * 2 - 1),(rand(star_seed) * 2 - 1)>;
   #declare lf_new_disc_size = disc_size + .001 * lf_flares_drawn;
   disc {
     <0,0,0>, z, 1
     texture {
       pigment {
         wood
         ramp_wave
         color_map{
           [0.0 color lf_s_color transmit .5]
           #if (lf_spk_info[i][crisps]=true)
             [1.0 color lf_s_color transmit .5]
           #else
             [1.0 color lf_Clear]
           #end
         }
       }
       finish { lf_Finish }
     }
     
     scale <lf_tmp_size,lf_tmp_width,1> * lf_new_disc_size*.9
       scale <.5,1,1>
       translate <.5,0,0>*lf_tmp_size* lf_new_disc_size.x// * flare_size.x
   rotate (lf_tmp_ang)*z
   scale lf_spk_vect[i][2] * flare_size
   #if (lf_spk_info[i][srot] >= 1000)
     rotate (lf_spk_info[i][srot] - 1000)*z
     matrix < CamRc.x,CamRc.y,CamRc.z,
              CamUc.x,CamUc.y,CamUc.z,
              CamD.x,CamD.y,CamD.z,   // maybe 0,0,0 (but then no inverse)
              0,0,0 >  // no translate
   #else
     rotate lf_spk_info[i][srot]*z
     matrix < CamR.x,CamR.y,CamR.z,
              CamU.x,CamU.y,CamU.z,
              CamD.x,CamD.y,CamD.z,   // maybe 0,0,0 (but then no inverse)
              0,0,0 >  // no translate
   #end
     #local lf_dist = 1/( vdot(lf_2light,lf_2ctr)/(vlength(lf_2ctr)*vlength(lf_2light)) );
     translate cam_loc + lf_new_disc_size * vnormalize(-lf_2light)*lf_dist
     no_shadow hollow
   }
   #declare lf_flares_drawn = lf_flares_drawn + 1;
       
   // make another copy if mirror is turned on.
   #if (lf_spk_info[i][smirror]=true)
   #declare lf_new_disc_size = disc_size + .001 * lf_flares_drawn;
   disc {
     <0,0,0>, z, 1
     texture {
       pigment {
         wood
         ramp_wave
         color_map{
           [0.0 color lf_s_color transmit .5]
           #if (lf_spk_info[i][crisps]=true)
             [1.0 color lf_s_color transmit .5]
           #else
             [1.0 color lf_Clear]
           #end
         }
       }
       finish { lf_Finish }
     }
     
     scale <lf_tmp_size,lf_tmp_width,1> * lf_new_disc_size*.9
     scale <.5,1,1>
     translate <-.5,0,0>*lf_tmp_size* lf_new_disc_size.x //* flare_size.x
   rotate (lf_tmp_ang)*z
   scale lf_spk_vect[i][2] * flare_size
   #if (lf_spk_info[i][srot] >= 1000)
     rotate (lf_spk_info[i][srot] - 1000)*z
     matrix < CamRc.x,CamRc.y,CamRc.z,
              CamUc.x,CamUc.y,CamUc.z,
              CamD.x,CamD.y,CamD.z,   // maybe 0,0,0 (but then no inverse)
              0,0,0 >  // no translate
   #else
     rotate lf_spk_info[i][srot]*z
     matrix < CamR.x,CamR.y,CamR.z,
              CamU.x,CamU.y,CamU.z,
              CamD.x,CamD.y,CamD.z,   // maybe 0,0,0 (but then no inverse)
              0,0,0 >  // no translate
   #end
     #local lf_dist = 1/( vdot(lf_2light,lf_2ctr)/(vlength(lf_2ctr)*vlength(lf_2light)) );
     translate cam_loc + lf_new_disc_size * vnormalize(-lf_2light)*lf_dist
     no_shadow hollow
   }
   #declare lf_flares_drawn = lf_flares_drawn + 1;
   #end
   #local lf_num = lf_num - 1;
 #end
  1. end // star_spread
  1. local i = i+1;
  1. end // while
  2. end

// ********************************************************************* // ********************* Multiple lens flare spots ******************** // *********************************************************************

  1. ifdef (lf_spot_types)
  1. local i = 0;
  2. while(i<dimension_size(lf_spot_types,1))
  3. local spot_seed = seed(lf_spot_info[i][dseed]);

// ***************************************************************** // ** randoms are relative to their respective variables // *****************************************************************

  1. local s_dist_rand = lf_spot_info[i][drnd]; //* lf_spot_info[i][ddist]*10;
  2. local s_size_rand = lf_spot_info[i][dsizernd]; //* lf_spot_info[i][dsize]*10;
  1. local lf_cur_spot = lf_spot_info[i][dskip]+1;
  2. while ((lf_cur_spot <= lf_spot_info[i][dnum]+lf_spot_info[i][dskip]) | (lf_cur_spot <= lf_spot_info[i][dopp]+lf_spot_info[i][dskip]))
 #local lf_side = 0;
 #while (lf_side <= 1)
   #switch(lf_side)
     #case (0) #local lf_xspot = lf_spot_info[i][dnum]+lf_spot_info[i][dskip]; #break
     #case (1) #local lf_xspot = lf_spot_info[i][dopp]+lf_spot_info[i][dskip]; #break
   #end
 
   #if (lf_cur_spot <= lf_xspot)
   // *****************************************************************
   // ** randomly shift various attributes
   // *****************************************************************
   #local lf_s_size  = lf_spot_info[i][dsize] + (rand(spot_seed) * 2 - 1) * s_size_rand;
   #local lf_s_dist  = (rand(spot_seed) * 2 - 1); // * s_dist_rand;
   #local lf_s_color = lf_spot_vect[i][0] + lf_spot_vect[i][1] * <(rand(spot_seed) * 2 - 1),(rand(spot_seed) * 2 - 1),(rand(spot_seed) * 2 - 1)>;
   #local lf_d_size  = lf_s_size;
   #local lf_d_color = lf_s_color;
   #local lf_pentagon = false;
   #if(strcmp(lf_spot_types[i],"dot")=0)
     #local lf_SpotPigment = pigment {
       wood
       #local tmp_tr = 1.0; //-spot_fade_amount*(lf_spot_info[i][dnum] - lf_spot_info[i][dskip]);
       color_map {
          [ 0.0              color lf_d_color*tmp_tr*1.2     transmit .5 ]
          [ lf_d_size / 1.2  color lf_d_color*tmp_tr*.53 transmit .5 ]
          [ lf_d_size        color lf_Clear  ]
          [ 1                color lf_Clear  ]
       }
     }
     #local lf_bound_y = lf_d_size/2;
   #end
   #if(strcmp(lf_spot_types[i],"hex")=0)
     #local tmp_tr = 1.0; //-spot_fade_amount*(lf_spot_info[i][dnum] - lf_spot_info[i][dskip]);
     #local lf_hex_pig = pigment {hexagon lf_s_color*tmp_tr transmit .5,lf_Clear,lf_Clear rotate 90*x scale .45}
     #local lf_SpotPigment = pigment{ wood scallop_wave pigment_map {
          [0.0  lf_hex_pig]
          [0.95 lf_hex_pig]
          [1.0  lf_Clear  ] }
          scale lf_s_size*1.2
          }
     #local lf_bound_y = lf_s_size/2;
   #end
   #if(strcmp(lf_spot_types[i],"pent")=0)
     #local lf_pentagon = true;
     #local tmp_tr = 1.0; //-spot_fade_amount*(lf_spot_info[i][dnum] - lf_spot_info[i][dskip]);
     #declare lf_SpotPigment = pigment{ wood scallop_wave color_map{
        [0.0  color lf_s_color*tmp_tr transmit .5]
        [0.95 color lf_s_color*tmp_tr transmit .5]
        [1.0  color lf_s_color*tmp_tr*.5 transmit .5] }
        scale 1.05*lf_s_size
        }
     #local lf_bound_y = lf_s_size/2;
   #end
   #if(strcmp(lf_spot_types[i],"spot")=0)
     #declare lf_SpotPigment = pigment {
       wood
       #local tmp_tr = 1.0; //-spot_fade_amount*(lf_spot_info[i][dnum] - lf_spot_info[i][dskip]);
       color_map {
          [ 0.0                       lf_Clear ]
          [ lf_s_size / 1.8           color lf_s_color*tmp_tr*.53 transmit .5 ]
          [ lf_s_size                 color lf_s_color*tmp_tr     transmit .5 ]
          [ lf_s_size +.1 * lf_s_size lf_Clear ]
          [ 1                         lf_Clear ]
       }
     }
     #local lf_bound_y = lf_s_size*1.1/2;
   #end
   #local lf_new_disc_size = disc_size + .001 * lf_flares_drawn;
   #if (lf_pentagon=false)
   disc {
     <0,0,0>, z, lf_bound_y
   #else
   polygon {
     6,
     <0,-1>
     < cos(radians(18)),-sin(radians(18))>, < cos(radians(54)), sin(radians(54))>,
     <-cos(radians(54)), sin(radians(54))>, <-cos(radians(18)),-sin(radians(18))>,
     <0,-1>
     scale lf_s_size*.5
   #end            
     texture { pigment { lf_SpotPigment } finish { lf_Finish } }
     // *****************************************************************
     // ** calculate the apparant position of the flare spot
     // *****************************************************************
     #switch(lf_side)
     #case(0)
       #local lf_2spot = lf_2light + (lf_newctr - lf_2light) * ((lf_spot_info[i][ddist]) * pow(lf_cur_spot+lf_spot_info[i][doffset]+lf_s_dist, lf_spot_info[i][ddistpwr]));
     #break #case (1)
       #local lf_2spot = lf_2light - (lf_newctr - lf_2light) * ((lf_spot_info[i][ddist]) * pow(lf_cur_spot+lf_spot_info[i][doffset]+lf_s_dist, lf_spot_info[i][ddistpwr]));
                                   //(lf_newctr - lf_2light) * (lf_spot_info[i][ddist] * pow(lf_cur_spot, lf_spot_info[i][ddistpwr]) + lf_s_dist);
     #end
     scale lf_new_disc_size * flare_size
     matrix < CamRc.x,CamRc.y,CamRc.z,
              CamUc.x,CamUc.y,CamUc.z,
              CamD.x,CamD.y,CamD.z,   // maybe 0,0,0 (but then no inverse)
              0,0,0 >  // no translate
     #local lf_dist = 1/( vdot(lf_2spot,lf_2ctr)/(vlength(lf_2ctr)*vlength(lf_2spot)) );
     translate cam_loc + lf_new_disc_size * vnormalize(-lf_2spot)*lf_dist
     no_shadow hollow
   }
   #declare lf_flares_drawn = lf_flares_drawn + 1;
   #end // if
   #local lf_side=lf_side+1;
 #end  // while side
 #local lf_cur_spot = lf_cur_spot + 1;
  1. end // while lf_cur_spot
  1. local i = i+1;
  1. end // while loop for different spots
  1. end // ifdef(lf_spot_types)
  1. end // if light was behind camera, lens flare was skipped.

//#end // of macro

Info about nkflare.inc

        N K F l a r e . I N C
 Lens Flare "plug-in" for POV-RAY 3.1

Copyright (C) 1997-1998 Nathan Kopp

Version 5.0 October, 1998

THIS SOFTWARE IS CURRENTLY IN BETA-TESTING STAGES.

           *** Installation Instructions for NKFlare ***

Unzip NKFlare.zip to any directory you want.

Next, you need to do one of the following:

1)  Copy NKFlare.inc and all of the FLR file(s) to your povray "include"
    directory (folder).
2)  Copy NKFlare.inc and all of the FLR file(s) to the same directory
    as the POV file that includes them.
3)  Add the directory that contains NKFlare.inc and all of the FLR
    files to your library path.  (See "Library Paths" in the POV-Ray
    documentation for more information on the library path.)
              *** INTRODUCTION AND GENERAL USE ***

NKFlare is a very flexible lens flare include file for POV-Ray 3.1. Adding lens flare to your POV scene is now a simple as adding the following few lines to your scene description file:

  1. declare cam_loc = <x,y,z> // use the x, y, and z of your camera
  2. declare light_loc = <x,y,z> // use the x, y, and z of the light
                            // you wish to flare
  1. declare lookat = <x,y,z> // the look_at vector of your camera
  2. declare sky_vect = <x,y,z> // the sky vector of your camera
  3. include "35mm.flr" // or whatever pre-defined flare you like
  4. include "nkflare.inc" // create the lens flare
                 *** Modifying the Lens Flare ***

There are also a few special variables that can be used to easily modify the lens flare. These are:

flare_size

This can be a vector or a number.  All elements of the lens flare
are scaled by this factor. (default=1)

flare_brightness

This can be a number or a color.  Use a color if you want to colorize
the lens flare.  For scenes with bright background, you will want to
use a less-bright flare.  (default=1)

flare_type

This determines what type of flare is created.  See below for a list
of the types of flares that come with NKFlare.
Alternatively, you can specify a flare type by un-defining flare_type
(using #undef) and including a *.flr file (this sets variables that
are used by NKFlare.inc).
                    *** PRE-DEFINED FLARES ***

NKFlare now includes 21 preset lens flares. To use a preset flare, include the file that goes with the flare.(e.g. #include "35mm.flr"). Available presets are as follows:

- Space1 SPACE1.FLR

   The Space1 flare is very similar to the default flare.  It four
   pronounced sparkle arms.  It also has smaller and more random
   flare spots.

- Space2 SPACE2.FLR

   This flare looks good for some space animations,
   like exploding stars.  This flare has a horizontal streak and a
   orangish tint to it.

- Space3 SPACE3.FLR

   This flare also looks good for some space
   animations.  It has a horizontal streak and a bluish tint to it.

- SmallStar SMLSTAR.FLR

   This flare looks good for adding sparkle to a small distant star.
   It is a very faint flare.

- BigStar BIGSTAR.FLR

   This flare looks good for adding sparkle to a star that is closer
   to the camera.  It has a yellowish "glow" to it but retains the four
   faint arms of SmallStar.

- Sparkle1 SPARKLE1.FLR

   This small flare is great for adding sparkle to a glare or to a small
   light such as a Christmas tree light or a taillight on a car.  It has
   a faint glow and four thin sparkle arms.

- Sparkle2 SPARKLE2.FLR

   This small flare is similar to Sparkle1, but has 6 arms instead of 4.
   This flare is also bigger and has more of a glow to the light source.

- Sparkle3 SPARKLE3.FLR

   This small flare is similar to Sparkle2, but has 8 arms instead of 6 and
   also has 16 smaller sparkle arms.

- Sparkle4 SPARKLE4.FLR

   This small flare produces a more random sparkle effect than the other
   three sparkle flares.  As with the other sparkles, this flare should
   be colored by specifying "#declare source_color = <r,g,b>".

- WarpFlare WARP.FLR

   Looks like a Starship going into Warp.

- 35mm 35MM.FLR

   This flare mimics actual 35mm flare.

- 50mm 50MM.FLR

   This flare mimics actual 50mm flare.

- 85mm 85MM.FLR

   This flare mimics actual 85mm flare.

- 105mm 105MM.FLR

   This flare mimics actual 105mm flare.  This bluish flare is
   quite soft and lacks a primary flare ring.

- Camcorder CAMCORDR.FLR

   This flare mimics the flare created by a camcorder lens.

- TV-Day TV-DAY.FLR

   Sunflare.

- TV-Day2 TV-DAY2.FLR

   Ok... this one looks good in the daylight.

- Concert CONCERT.FLR

   Looks like the flare from a spotlight at a rock concert.

- Sports SPORTS.FLR

   This is the lens flare you see at all of the sports events on TV.  Use
   it for bright lights and camera-flashes.  Also good for adding sparkle
   to gems.  Shaped like an "X".

- Sunset1 SUNSET1.FLR

   This doesn't look good, IMHO.  It is included just because.  ;)
   For sunsets, use 35/50/85/105mm and use a small flare_brightness value.
   This flare can be used to create a sunset where you wish the flare to
   cover up the light source.  This mimics a previous set of #declares that
   was included in version 1.0.

- Sunset2 SUNSET2.FLR

   This doesn't look good, IMHO.  It is included just because.  ;)
   For sunsets, use 35/50/85/105mm and use a small flare_brightness value.
   This flare can be used to model a sunset where the light source is 
   already created and should not be covered up.  This mimics a previous
   set of #declares that was included in version 1.0.
                  *** HIDING YOUR FLARE ***

You can hide your lens flare behind a plane or a sphere (more objects coming) by using the following files: hid_pln.inc hid_sph.inc hid_tri.inc

Declare the appropriate variables and include the file to calculate a new "flare_amount" value. Then include NKFlare to create the lens flare. A flare amount of 0.0 (0%) will cause the lens flare to be ignored.

See the above mentioned files for more information.

           *** HINTS, TIPS, AND TROUBLESHOOTING (FAQ) ***

Q: Sometimes I see black spots in the flares.

A: Increase the #max_trace_level. The higher you set it, the better.

  This can really slow down scenes that have a lot of glass, though.
  Too bad.

Q: My scene is very bright and the flare looks ugly.

A: You can:

  1) Add this line before including NKFlare
      #declare bright_background = true
   or
  2) Adjust the flare yourself by turning down the flare_brightness

Q: I am using fog and it causes the lens flares to look strange. This

  problem is most obvious when colored fog is used.

A: You may be able to correct the problem by using a color for

  flare_brightness.  (See hint below about tinting the flare.)

Q: I am using focal blur in my image, and the lens flare disappears.

A: Change the "disc_size" variable. This variable affects the size

  of the discs that are used to create the lens flare.  It also
  changes their location.  The value of "disc_size" represents the
  distance from the camera to the discs.  In order for thoes discs
  to be in focus when focal blur is used, they must be at the
  focal point.  If, for example, the focal point was at "f_point",
  you would use the following declaration before including NKFlare.
  #declare disc_size = vlength(f_point - cam_loc)

Q: When I rotate my camera or the light source, the flare doesn't follow.

A: You need to give NKFlare the exact location of the light and camera.

You may need to use POV-Ray's vector functions such as VROTATE to find the position of the point. This is also true for the location of things like the planet (if used).

Example:

camera {
  location  < 0,  0,  0>
  direction < 0,  0,  1>
  up        < 0,  1,  0>
  right     < 1,  0,  0>
  rotate    <30, 60, 30>
  translate < 5,  3,  4>
}
#declare cam_loc = <0, 0, 0>
#declare cam_loc = vrotate(cam_loc, <30, 60, 30> )
#declare cam_loc = cam_loc + <5, 3, 4>

Q: Can I use multiple lens flares?

A: Yes.

Q: What if I want to hide the flare behind a space-ship instead of

  a sphere.

A: This can usually be done by creating an imaginary "sphere" of an

  appropriate size.  Then tell the lens flare to hide behind a sphere
  of that size centered on the ship.  (Or, hide the flare behind a
  bunch of triangles that make up a shape like the ship.)

Q: The flare is really dark (or really bright).

A: If your scene adjusts the ambient_light under global_settings, you

  should set the AmbientLight variable to match.
  Otherwise, just play around with the flare_brightness variable.

Q: Will NKFlare be turned into a macro?

A: No. Well, maybe, but probably not.

Hint:

You can give any flare a "tint" by changing the flare_brightness variable. Use a color vector instead of a scalar number.

For example, if you want your flare to look purplish, use the following:

   declare flare_brightness = <1.25, 0.5, 1.25>

Hint:

Don't forget to keep something visible at the spot of the light_source. This will still be needed for certain reflections (ex: sunset on water).

Hint:

When creating flare for a lens that may or may not be centered on the camera's look_at point (such as the windshield of a car), simply point the "lookat" vector towards the center of the lens. This will correctly orient both the sparkle arms and the multiple flare spots.

                       *** LEGAL STUFF ***

This software is provided AS-IS. There is no warranty... You know the drill. Basically, I disclaim all responsibility for anything bad happening to you for any reason. Enough said.

NKFlare is provided free of charge. You may freely distribute it provided that this file is included. You may make changes if you like to. However, if you wish to distribute a modified version you must:

1) Do not try to conceal the fact that it originally was written
   by Nathan Kopp.
2) Do not try to conceal the fact that it is a modified version.
3) Include this TXT file (with nothing removed - you can add your
   notes in an appropriate location)
   * Do include contact information so that users can ask you about
     the changes that you have made.
4) Do not charge any money for it.

If you would like to distribute NKFlare on a CD-ROM or another form of media other than the internet, please get permission first. My desire is for this plug-in to be freely and readily available to everyone, so I will be reasonable with your requests.

If you find this useful, drop a note to me (or you could snail-mail a postcard).  :)

I (Nathan Kopp, the author) can be contacted at:

nk80300@ltu.edu

If none of these work, you can probably contact me via POV's news server:

news.povray.org  (group povray.general)

Also check out my web pages:

This lens flare generator was _inspired_ by Chris Colefax's "Dome City" image. The code was originally created by Nathan Kopp on November 3rd, 1996. Thanks to God for giving me the time and ability to finish this project.

Licensing edit

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current14:56, 29 August 2021Thumbnail for version as of 14:56, 29 August 20211,280 × 1,024 (631 KB)Merikanto (talk | contribs)Uploaded own work with UploadWizard

There are no pages that use this file.

Metadata