POV-Ray : Newsgroups : povray.text.scene-files : background image INC file Server Time
28 Jul 2024 20:20:02 EDT (-0400)
  background image INC file (Message 1 to 1 of 1)  
From: Nathan Kopp
Subject: background image INC file
Date: 26 Apr 1999 15:35:12
Message: <3724B1F5.462292D4@Kopp.com>
This could be turned into a macro easily, but I don't really see the need (and the
macro would just take far to many parameters).

-Nathan


--------------------- background.inc ----------------------------
//  ***************** BACKGROUND include file ***********************
/*
  usage is is very similar to NKFlare.inc
  
  You must define the following variables:
    cam_loc    - camera location
    lookat     - look_at from camera
   *sky_vect   - camera's sky  This us y by default (z if you use moray)
    
   *aspect_ratio - aspect ratio VECTOR of the camera.  This comes from the
                     camera's up and right vectors.
                   aspect_ratio = <vlength(right_vect), vlength(up_vect), 1>
                   
    bg_pigment   - pigment for the background
                    x = 0..1 and y=0..1 will map to your screen, so you
                    may need to scale & rotate
   *bg_distance  - distance from background to the camera

  * = optional
  
*/

#ifndef (bg_distance)
#declare bg_distance = 1000000;
#end

#ifndef (sky_vect)
#declare sky_vect = y;
#end

#ifndef (aspect_ratio)
#declare aspect_ratio = <4/3,1,1>
#end

// *****************************************************************
// ** compute relative location of camera to light source
// ** compute relative location of camera to center
// *****************************************************************
#local lf_2ctr = -(cam_loc - lookat);

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

// matrix concept by John VanSickle
             
#local CamD = vnormalize(lookat-cam_loc);
#local CamR = vnormalize(vcross(sky_vect,CamD));
#local CamU = vnormalize(vcross(CamD,CamR));

  //box {
  //  <-0.5, -0.5, 0.0>, <0.5, 0.5, 0.001>
  plane {
    z,0
    texture {
      pigment { bg_pigment }
      finish { ambient 1 diffuse 0 reflection 0 phong 0 specular 0 }
      translate <-0.5, -0.5, 0.0>
      //rotate <180,0,0>
    }
    scale bg_distance*aspect_ratio

      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

    translate cam_loc + bg_distance * vnormalize(lf_2ctr)
    no_shadow hollow
  }


--------------------------------- END FILE -----------------------------


-------------------------- bgtest.pov ----------------------------


#declare cam_loc = <15,3,0>;
#declare lookat = <0,0,0>;
#declare sky_vect = y;                 // optional
  #declare right_vect = <4/3,0,0>;     // not used by background.inc
  #declare up_vect = <0,1,0>;          // not used by background.inc
#declare aspect_ratio = <vlength(right_vect), vlength(up_vect), 1>; // optional
#declare bg_distance = 2;              // optional

camera{
  right right_vect
  up up_vect

  location cam_loc
  look_at lookat
  sky sky_vect
}


#declare bg_pigment = pigment {
  image_map
  {
    png "povmap.png"
    interpolate 2    
  }
}                        

#declare bg_pigment2 = pigment {
  gradient y  // try gradient y & gradient x
}

#include "background.inc"


Post a reply to this message

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