POV-Ray : Newsgroups : povray.newusers : Using an image file : Re: Using an image file Server Time
23 Apr 2024 15:58:58 EDT (-0400)
  Re: Using an image file  
From: Alain
Date: 10 Jul 2017 19:53:15
Message: <5964136b@news.povray.org>
Le 17-07-09 à 20:22, Sublyminal a écrit :
> Hey everyone, I'm new to povray, I am trying to use an image in my project and
> then working within the confines of this image to complete the project. How
> would I go about importing or using an image within povray? Thanks!
> 
> 

I'd start by assigning the image to an identifier:

#declare MyImage = "NameOfTheImage";
This assume that the image is located in the same folder as the scene, 
or any of the default location where POV-Ray normally look for files.

Then, apply it to some object, typically a box or a 4 sided polygon, 
here again, assign it to an identifier:
#declare ImageBox =
box{0, <1,1,0>
  pigment{image_map{png MyImage}}
  scale max_extent(MyImage) +z
// scale the image so that 1 pixel = 1 unit
  finish{emission 1 diffuse 0 ambient 0}
//optional so that it's visible without any light_source
}

Now, you can rotate, scale or move that box however you want.

If you apply an image to a plame, it will get tilled infinitely on the 
plane unless you use the "once" option.
The initial size of the image is always a square 1 unit wide and 1 unit 
high. Scaling it often makes things easier for most peoples.

If you want to know the colour of a given point of the image, you need 
to use eval_pigment() witch takes a pigment and a location and return a 
colour.
If you want to get a given channel, you add .red, .green or .blue.
If you want to get the brightness, you add .grey or .gray.
#declare GreyLevel = eval_pigment(MyImage, <XPos, YPos, 0>).grey;


Post a reply to this message

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