User:IMBJR/povray script examples

From Wikipedia, the free encyclopedia

[edit] Examples of the Scene Description Language

The following is an example of the scene description lanaguage used by POV-Ray to describe a scene to render. It demonstrates use of the camera, lights, a simple box shape and the transforming effects of scaling, rotation and translation.

POV-Ray image output based on the script to the left
POV-Ray image output based on the script to the left
#version 3.6;
#include "colors.inc"
global_settings {
        assumed_gamma 1.0
}

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

camera {
        location        <0.0, 0.5, -4.0>
        direction       1.5*z
        right           x*image_width/image_height
        look_at         <0.0, 0.0,  0.0>
}

light_source {
        <0, 0, 0>        
        color rgb <1, 1, 1>
        translate <-5, 5, -5>
}
light_source {
        <0, 0, 0>        
        color rgb <0.25, 0.25, 0.25>
        translate <6, -6, -6>
}

box {
        <-0.5, -0.5, -0.5>
        <0.5, 0.5, 0.5>
        texture {
                pigment {
                        color Red
                }
                finish{
                        specular 0.6
                }
                normal {
                        agate 0.25
                        scale 1/2
                }               
        }       
        rotate <45,46,47>
}

The following script fragment shows the use of variable declaration, assignment, comparison and the while loop construct:

POV-Ray image output based on the script to the left
POV-Ray image output based on the script to the left
#declare the_angle = 0;

#while (the_angle <= 360)

        box {
                <-0.5, -0.5, -0.5>
                <0.5, 0.5, 0.5>
  
                texture {
  
                        pigment {
                                color Red
                        }
   
                        finish{
                                specular 0.6
                        }
   
                        normal {
                                agate 0.25
                                scale 1/2
                        }
        
                }

                rotate the_angle
        
        }

        #declare the_angle = the_angle + 45;
        
#end