POV-Ray : Newsgroups : povray.newusers : Using an image file Server Time
28 Mar 2024 17:07:19 EDT (-0400)
  Using an image file (Message 1 to 8 of 8)  
From: Sublyminal
Subject: Using an image file
Date: 9 Jul 2017 20:25:01
Message: <web.5962c8dbf4dab0ffe60ef2b10@news.povray.org>
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!


Post a reply to this message

From: omniverse
Subject: Re: Using an image file
Date: 10 Jul 2017 00:40:01
Message: <web.59630422bbe238b1865ad31e0@news.povray.org>
"Sublyminal" <nomail@nomail> wrote:
> 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?

plane {z,3 //higher number moves away
pigment {
image_map {
jpeg "file name" //or use any valid type like png
}
translate -0.5 //centers unit square
scale <width,height,1>
//set this to resolution or same ratio as image file
}
finish {diffuse 0 ambient 0 emission 1}
}

 Best advice would be to use the help search and look up image_map  but you
might be able to get something rendered using that above.


Post a reply to this message

From: Kenneth
Subject: Re: Using an image file
Date: 10 Jul 2017 01:45:00
Message: <web.5963131fbbe238b1883fb31c0@news.povray.org>
A simple example would be this code (assuming you already have a camera and some
lights in the scene). It uses the 'image_map' keyword...


#version 3.7;  // or 3.6, or whichever version of POV-Ray you are using

global_settings{assumed_gamma 1.0 max_trace_level 5}

---(camera here)---

-- light(s) here---

box{<0,0,0>, <1,1,0> // a box can be made zero-thickness if you want
    texture{
        pigment{
            image_map{jpeg "my_image.jpg" interpolate 2}
               }
        finish{ambient .2 emission 0 diffuse .8}
           }
        scale... // scales the full box object, not just the image.
// ANY image is 'squashed' or 'stretched' to completely fill the
// 1X1-unit box, by default, no matter what its resolution or aspect-ratio
// is-- so you will probably need to scale the box to the proper ratio.
        translate ... // ditto, wherever you want it to be in space
   }


Post a reply to this message

From: omniverse
Subject: Re: Using an image file
Date: 10 Jul 2017 02:55:01
Message: <web.596324a1bbe238b19c5d6c810@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> A simple example would be this code (assuming you already have a camera and some
> lights in the scene).

And about the camera... my example only uses a default camera which is located
at <0,0,0> pointing toward +z and I reread the question saying:
"use an image in my project and then working within the confines of this image
to complete the project"
therefore I wonder if screen.inc (or screen2.inc) would be something to try too,
even if it takes a little learning to use that.

I would be guessing here but 'confines of this image' sounds like you might be
wanting to create scene objects with that image as the only background, fully
shown yet without extra space around it.

One way is to surround the scene by putting it into a sky_sphere, which will not
show all of the image at once but act as an environment for reflections on
objects.

Another might be to use camera with 'orthographic' projection, therefore putting
the plane or box image map into the viewport of camera when using its resolution
or ratio and placing other scene elements between image and camera. Except that
would lack a perspective view.

So the method will depend a lot on what you're really trying to accomplish for
the end result.


Post a reply to this message

From: Stephen
Subject: Re: Using an image file
Date: 10 Jul 2017 06:54:09
Message: <59635cd1@news.povray.org>
On 7/10/2017 1:22 AM, Sublyminal wrote:
> 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!
>
>

What sort of image and what do you want to do with it?

You can do lots of sorts of things with images.

-- 

Regards
     Stephen


Post a reply to this message

From: Kenneth
Subject: Re: Using an image file
Date: 10 Jul 2017 07:40:01
Message: <web.59636534bbe238b1883fb31c0@news.povray.org>
"Sublyminal" <nomail@nomail> wrote:
>
> How would I go about importing or using an image within povray?

As far as 'importing' the image goes, you'll need to put your image into a
folder where POV-ray can recognize its location; that's not done automatically.
There are specific ways to 'inform' the program where your image resides-- like
opening the built-in 'POVRAY.INI' file (under the 'TOOLS' menu if you're running
the Windows version) and actually writing the full computer 'path' to the
image's folder, using 'Library_Path="....."  But that's probably a bit too
complex to learn and understand, if you're just starting out.

The easiest way to see quick results is just to place your image in the same
folder as your scene file. POV-Ray WILL automatically 'see' it there, and import
it into your scene, with no extra work required.

As you become proficient with the program, you'll find that putting *all* of
your various image_map images into a single folder will be a more logical
approach (in my opinion)-- in which case, learning how to use 'Library_Path'
will come in handy.


Post a reply to this message

From: Alain
Subject: Re: Using an image file
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

From: omniverse
Subject: Re: Using an image file
Date: 10 Jul 2017 23:10:00
Message: <web.59644174bbe238b19c5d6c810@news.povray.org>
Alain <kua### [at] videotronca> wrote:
> Le 17-07-09 à 20:22, Sublyminal a écrit :
> > Hey everyone, I'm new to povray
>
> 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 plane, it will get tiled infinitely on the
> plane unless you use the "once" option.

I completely missed before, yeah 'once' can be important. Good thing to have
people giving their different advice.

> 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;

If possible, OP might want to get a look at the Insert menu too, when a scene
file is started or already open, and dig down through Textures and
Materials>Textures>Texture Maps>Image Map among the other things Insert has such
as camera and lights.

Those can be a helpful, like the documentation/help but without the more
detailed descriptions. Better if you already understand the basics, but also
gives you an idea what to search for help on after seeing the many things
available.

Bob


Post a reply to this message

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