POVRay Skyboxes        

Just thought i'd share my povray scripts for some basic skyboxes (see also http://ghoulsblade.schattenkind.net/wiki/index.php/Povray).

Uncleaned and ugly code and few explanations, but time is short, sorry.

To render under linux run something like the following command (adjust $i)

  • povray -Imyinfile.pov -H256 -W256 +FT -D32 -Omyoutfile_rt.tga -K$i
  • myinfile.pov would contain the snippets listed below
  • myoutfile_rt.tga would be a texture to generate for one side of the skybox
  • +FT means something like "F": output to file, "T" : TGA format... see manpage for details
  • -D32 would be the color depth if i remember correctly
  • -K sets the "clock" used in the camera block to determine which side of the skybox to render
  • replace $i with values ranging from 0-5 to render all sides, and adjust the outfile accordingly
  • to follow the default ogre naming sheme, it think the following will help, but i'm not quite sure if its correct
  • 0 = "_fr"; // front
  • 1 = "_rt"; // right
  • 2 = "_bk"; // back
  • 3 = "_lf"; // left
  • 4 = "_up"; // up
  • 5 = "_dn"; // down


The skyboxes in the examples are best suited for space-scenes.

I suggest rendereing stars on them during runtime using RenderOp OT_POINT_LIST or with little billboards, to avoid compression artifacts, and to enable animation (e.g. blinking stars).

Skybox1 (bright red colours, maybe inside a nebulae):

Ghoulskybox1_fr.jpg

#include "colors.inc"

camera {
  location <0,0,0>
  angle 90
  right <1,0,0> up <0,1,0>
  // turn the cam based on the current frame=clock : [0-5]
  #switch (clock)
    #range (0,3)
      // first 4 frames : turn from left to right
      rotate (90*clock)*y
    #break
    #case (4)
      // look at the sky
      rotate -90*x
    #break
    #case (5)
      // look at the ground
      rotate 90*x
    #break
  #end // End of conditional part
}

background { color rgb <0,0,0> }

// light_source { <100, 100, -200> color White }

sphere { < 0, 0, 0>, 2
    pigment { rgbt 1 } // surface of sphere is transparent
    interior {
        media {
            emission 0.02
            intervals 1
            samples 25
            method 3
            density {
                spherical
                ramp_wave
        translate 1.0*y  // replace 1.0 = t   by time for animation
        warp { turbulence 1.5 }
        translate -1.0*y // replace -1.0 = -t  by time for animation
                color_map {
                    [0.0 color rgb <0, 0, 0>]
                    [0.1 color rgb <1, 0, 0>]
                    [0.5 color rgb <1, 1, 0>]
                    [1.0 color rgb <1, 1, 0>]
                }
            }
        }
    }
    scale 25
    hollow
}


Skybox2 (vast darkness and a few green nebulae):

Ghoulskybox2_fr.jpg

(see this screen shot also with runtime stars

#include "colors.inc"

camera {
  location <0,0,0>
  angle 90
  right <1,0,0> up <0,1,0>
  // turn the cam based on the current frame=clock : [0-5]
  #switch (clock)
    #range (0,3)
      // first 4 frames : turn from left to right
      rotate (90*clock)*y
    #break
    #case (4)
      // look at the sky
      rotate -90*x
    #break
    #case (5)
      // look at the ground
      rotate 90*x
    #break
  #end // End of conditional part
}

background { color rgb <0,0,0> }

// light_source { <100, 100, -200> color White }
/*
/usr/share/povray-3.5/include/stars.inc

  sky_sphere {
    pigment {
        granite
        color_map {
            [ 0.000  0.270 color rgb < 0, 0, 0> color rgb < 0, 0, 0> ]
            [ 0.270  0.280 color rgb <.5,.5,.4> color rgb <.8,.8,.4> ]
            [ 0.280  0.470 color rgb < 0, 0, 0> color rgb < 0, 0, 0> ]
            [ 0.470  0.480 color rgb <.4,.4,.5> color rgb <.4,.4,.8> ]
            [ 0.480  0.680 color rgb < 0, 0, 0> color rgb < 0, 0, 0> ]
            [ 0.680  0.690 color rgb <.5,.4,.4> color rgb <.8,.4,.4> ]
            [ 0.690  0.880 color rgb < 0, 0, 0> color rgb < 0, 0, 0> ]
            [ 0.880  0.890 color rgb <.5,.5,.5> color rgb < 1, 1, 1> ]
            [ 0.890  1.000 color rgb < 0, 0, 0> color rgb < 0, 0, 0> ]
        }
    turbulence 1
    sine_wave
    scale .5
    }
    
  }
  */
  
sphere { < 0, 0, 0>, 2
    pigment { rgbt 1 } // surface of sphere is transparent
    interior {
        media {
            emission 0.02
            intervals 1
            samples 25
            method 3
            density {
                spherical
                ramp_wave
        translate 1.0*y  // replace 1.0 = t   by time for animation
        warp { turbulence 2.5 }
        translate -1.0*y // replace -1.0 = -t  by time for animation
                color_map {
                    [0.0 color rgb <0, 0, 0> * 0.5]
                    [0.1 color rgb <0, 1, 0> * 0.5]
                    [0.5 color rgb <1, 1, 0> * 0.5]
                    [1.0 color rgb <1, 0, 0> * 0.5]
                }
            }
            density {
                spherical
                ramp_wave
                color_map {
                    [0.0 color rgb 1]
                    [0.2 color rgb 1]
                    [0.3 color rgb 0]
                    [1.0 color rgb 0]
                }
            }
        }
    }
    scale 25
    hollow
}