POV-Ray : Newsgroups : povray.newusers : Sky external Image? Server Time
1 Nov 2024 10:17:43 EDT (-0400)
  Sky external Image? (Message 1 to 8 of 8)  
From: Chrisir
Subject: Sky external Image?
Date: 14 Jul 2009 15:40:00
Message: <web.4a5cddf4e9c9822ba2f93e20@news.povray.org>
Hello all,

I'd like to use a image for my sky.

sky_sphere {
  pigment {
    image_map
        {
            jpeg "sky02.jpg"
            // [IMAGE_MAP_MODS...]
            // interpolate Type

        }
    // scale .2
  }

}

But it doesn't come right

Any help`?

The jpg is 1273 x 745  Pixels.

Do I have to scale it?

Thank you all!

Greetings,

Chris




#version 3.6;

#declare Photons=off;

// ==== Standard POV-Ray Includes ====
#include "colors.inc"      // Standard Color definitions
#include "textures.inc"    // Standard Texture definitions
#include "functions.inc"  // internal functions usable in user defined functions
#include "glass.inc"      // Glass


#declare Radiosity=off;   // oder on


// ----------------------------------------

light_source {
  <500,500,-500>       // light's position
  color rgb <1, 1, 1>  // light's color
}

light_source {
  <700,700,-500>       // light's position
  color rgb <1, 1, 1>  // light's color
}

light_source { <450, 650, 50>
        color rgb<1, 1, 1> }

// ----------------------------------------

camera {
    location <70, 5, 241>
    look_at <920, 260, 410>
  }


#declare Radiosity=off;

// ----------------------------------------

light_source {
  <500,500,-500>       // light's position
  color rgb <1, 1, 1>  // light's color
}

sky_sphere {
  pigment {
    image_map
        {
            jpeg "sky02.jpg"
            // [IMAGE_MAP_MODS...]
            // interpolate Type

        }
    // scale .2
  }

}

// ----------------------------------------

plane {
  y, 0
  texture {
    pigment {
      checker
      color rgb <1.0, 0.8, 0.6>
      color rgb <1.0, 0.0, 0.0>
      scale 25
    }
  }
}


Post a reply to this message

From: clipka
Subject: Re: Sky external Image?
Date: 14 Jul 2009 21:55:01
Message: <web.4a5d360641a4106c3964e90f0@news.povray.org>
"Chrisir" <nomail@nomail> wrote:
> I'd like to use a image for my sky.
>
> sky_sphere {
>   pigment {
>     image_map
>         {
>             jpeg "sky02.jpg"
>             // [IMAGE_MAP_MODS...]
>             // interpolate Type
>
>         }
>     // scale .2
>   }
>
> }
>
> But it doesn't come right

Do you want to use it as a *sky* (i.e. have the picture cover the whole sphere),
or as a *background* (i.e. have the picture fill exactly what is visible)?

For a *sky*, you need to add "map_type 1" to the "image_map" statement (for the
most common projection type, called "spherical" in POV-Ray; note that this will
cover the entire sphere, not just the upper hemisphere).

For using an image as a *background*, POV-Ray currently does not provide a
straightforward way. You will probably need to use a *very* large "box" object
instead of the sky sphere, with the image projected onto one side, and scaled,
rotated and translated so that this side exactly fits the camera view.


Post a reply to this message

From: Chrisir
Subject: Re: Sky external Image?
Date: 15 Jul 2009 12:45:00
Message: <web.4a5e060d41a4106c9480b1a20@news.povray.org>
Hello,

thank you very much for your very helpful reply.

I am afraid I want to use it as a *background*
(or to cover only the visible part of the sphere).

Do you have any code for a big box with image on
*one* side?

Thanks!

Greetings,

Christoph


Post a reply to this message

From: clipka
Subject: Re: Sky external Image?
Date: 15 Jul 2009 13:55:00
Message: <web.4a5e176841a4106ca95afc190@news.povray.org>
"Chrisir" <nomail@nomail> wrote:
> Do you have any code for a big box with image on
> *one* side?

Well, it doesn't seem to matter much how the other sides look, right? So I'd use
the following approach:

- Create a unit box (from <0,0,0> to <1,1,1>)
- Map the texture onto it using the default map_type (parallel projection)
- Translate the box by <-0.5,-0.5,-0.5> to be centered at <0,0,0>
- Scale the box non-uniformly by, say, 10000 and 10000*image_heigh/image_width
units, respectively
- Rotate the box to match the actual camera orientation (*)
- Translate the box to be centered at the actual camera location

(*) Ideally you use some suitable formulae here; if however you decide to tweak
the rotation manually, do the fine-tuning of the rotation parameters when you
have already implemented the final translation.


Post a reply to this message

From: Chrisir
Subject: Re: Sky external Image?
Date: 15 Jul 2009 17:25:00
Message: <web.4a5e484441a4106c9480b1a20@news.povray.org>
Hello,

Here is my code, but the image bit doesn't work...


#macro BigSkyBox ()

/*
- Create a unit box (from <0,0,0> to <1,1,1>)
- Map the texture onto it using the default map_type (parallel projection)
- Translate the box by <-0.5,-0.5,-0.5> to be centered at <0,0,0>
- Scale the box non-uniformly by, say, 10000 and 10000*image_heigh/image_width
units, respectively
- Rotate the box to match the actual camera orientation (*)
- Translate the box to be centered at the actual camera location

(*) Ideally you use some suitable formulae here; if however you decide to tweak
the rotation manually, do the fine-tuning of the rotation parameters when you
have already implemented the final translation.
*/

// create a box that extends between the 2 specified points
box {
  < 0,  0,  0>  // one corner position <X1 Y1 Z1>
  < 1,  1,  1>  // other corner position <X2 Y2 Z2>
  scale 1000 //  <22111.0,  11111.0,  11111.0> // <dX, dY, dZ>
  translate <-1600, 0, 220>  // <dX, dY, dZ>
  texture {
     material_map {
        jpeg "sky02.jpg" // the file to read (iff/tga/gif/png/jpeg/tiff/sys)
        map_type 0        // 0=planar, 1=spherical, 2=cylindrical, 5=torus
        interpolate 0     // 0=none, 1=linear, 2=bilinear, 4=normalized distance
        once           // for no repetitive tiling
        texture { pigment { } }  // texture for color index # 0
        texture { pigment { } }  // texture for color index # 1
        texture { pigment { } }  // texture for color index # 2
     } // material_map
     scale 100000
  }  // texture
}
#end // macro

BigSkyBox ()


Thanks again!

Chris


Post a reply to this message

From: Reactor
Subject: Re: Sky external Image?
Date: 15 Jul 2009 19:00:01
Message: <web.4a5e5e8141a4106c6a9471340@news.povray.org>
"Chrisir" <nomail@nomail> wrote:
> Hello,
>
> Here is my code, but the image bit doesn't work...
>
>
> #macro BigSkyBox ()


One thing I noticed with just quick look at your code is that the box is scaled
and translated before the texture is applied.  Since the image maps from
<0,0,0>, <1,1,0> (and extends infinitely along the z-axis), you should apply it
first, then remove that extra scaling statement from the texture block.
Furthermore, if you only want the image to display and do not want use
generated patterns, you should be using the image_map pigment, not
material_map.  The finish should also be set to
finish{ ambient 1 diffuse 0 } which makes the image fully lit and tells it to
ignore scene lights.

In any case, the method clipka recommended is a good general purpose way of
having the sky map always be more or less in the correct place.  However, it
may be fairly difficult to implement, depending on your math (trigonometry)
ability.  If you already know exactly where you want the camera to be, the
sky_sphere method is easier to implement:

sky_sphere
{
     pigment {
      image_map{
        jpeg "sky02.jpg" // the file to read (iff/tga/gif/png/jpeg/tiff/sys)
        map_type 0        // 0=planar, 1=spherical, 2=cylindrical, 5=torus
        interpolate 2     // 0=none, 1=linear, 2=bilinear, 4=normalized distance
        once            // for no repetitive tiling
         }
     translate <-0.5,-0.5,0>
     scale 4/3 // the aspect ratio of the image
     }
}


There are some important limitations, though.  If your camera's aspect ratio is
significantly different than the aspect ratio of the image, you will see a
black area where the image ends.  To counteract this, you can comment out the
once keyword so that the image tiles.  Alternatively, you can specify a
background color, which will show wherever the image doesn't cover.

Furthermore, since the above code is using planar mapping, the image only looks
correct if viewing angle is parallel or close to parallel with the z-axis.  If
the camera isn't, then the image will look distorted.  Alternatives include
using cylindrical mapping or rotating the image so that it faces the camera.

If you do want the background image to auto-magically be rotated to face the
camera, here is some starter code:

#declare camLocation  = <10, 5, -5>;
#declare camLookAt    = < 0, 5, 0>;

camera
{
    location camLocation
    look_at  camLookAt
}

background{ color rgb <1,0,1> } // color of any parts not covered by image

sky_sphere
{
     pigment {
         image_map{
        jpeg "sky02.jpg" // the file to read (iff/tga/gif/png/jpeg/tiff/sys)
        map_type 0       // 0=planar, 1=spherical, 2=cylindrical, 5=torus
        interpolate 2    // 0=none, 1=linear, 2=bilinear, 4=normalized distance
        once            // for no repetitive tiling
            }
     translate <-0.5,-0.5,0>
     rotate y*degrees(atan((camLocation - camLookAt).x/(camLocation -
camLookAt).z))
     // rotates image about the y axis so that it is facing the camera
     scale 4/3
     }
}


This will correctly rotate the image into view assuming that the viewing axis of
the camera is roughly parallel to the xz plane.  If you are looking up or down,
you will need another rotate statement to make the image rotate about the x
axis.


-Reactor


Post a reply to this message

From: Chrisir
Subject: Re: Sky external Image?
Date: 18 Jul 2009 08:20:00
Message: <web.4a61bd2841a4106c7610d2d10@news.povray.org>
Thank you all so much!

It is Solved.

I Propose a Background-Function similar to
plane.

Thanks!

Regards,

Christoph


Post a reply to this message

From: clipka
Subject: Re: Sky external Image?
Date: 18 Jul 2009 12:20:01
Message: <web.4a61f50841a4106cff56452c0@news.povray.org>
"Chrisir" <nomail@nomail> wrote:
> I Propose a Background-Function similar to
> plane.

See http://bugs.povray.org/task/27 ;)


Post a reply to this message

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