POV-Ray : Newsgroups : povray.general : rendering skyboxes Server Time
2 Nov 2024 07:23:55 EDT (-0400)
  rendering skyboxes (Message 1 to 7 of 7)  
From: Barron Gillon
Subject: rendering skyboxes
Date: 7 May 2004 23:47:07
Message: <409c583b$1@news.povray.org>
I have an OpenGL project, and I was wanting to use pov to render textures
for my skybox.  Dos anyone have any experience with this?  I've been messing
with the sphere camera and, surprisingly enough, its textures map very well
to a sphere.  But I want to map to a box.  I've been playing with the output
of the sphere camera and concluded that it is a dead end.  Does anyone have
any insight?  Your help would be greatly appreciated!


Post a reply to this message

From: Hughes, B 
Subject: Re: rendering skyboxes
Date: 8 May 2004 02:17:39
Message: <409c7b83@news.povray.org>
"Barron Gillon" <gil### [at] purdueedu> wrote in message
news:409c583b$1@news.povray.org...
> I have an OpenGL project, and I was wanting to use pov to render textures
> for my skybox.

http://astronomy.swin.edu.au/~pbourke/rendering/cuberender

I think that link will show a relevant way of rendering out the skybox
parts. Nothing in POV can automatically output a skybox, or unwrapped cube
(no internal feature to do so), but that method Paul Bourke has listed might
work okay.

Checking on it again myself, having not seen it in a very long time, I see
you'll need to look at files which are given links to. That web page dated
1991?! Hard to believe.
-- 
Bob H.
http://www.3digitaleyes.com


Post a reply to this message

From: Slime
Subject: Re: rendering skyboxes
Date: 8 May 2004 02:18:33
Message: <409c7bb9@news.povray.org>
> I have an OpenGL project, and I was wanting to use pov to render textures
> for my skybox.  Dos anyone have any experience with this?

This code is from a scene which I used to render a sky box for one of *my*
openGL programs:

camera {
 location 0
 right x
 up y
 direction z

 angle 90

 #if (frame_number = 0)
  look_at  x
 #else #if (frame_number = 1)
  look_at  -x
 #else #if (frame_number = 2)
  look_at  y
 #else #if (frame_number = 3)
  look_at  -y
 #else #if (frame_number = 4)
  look_at  z
 #else #if (frame_number = 5)
  look_at  -z
 #end #end #end #end #end #end
}

use it in an animation with 6 frames (0 through 5), and a square output
aspect ratio, and there are your 6 images which should be texture mapped to
squares surrounding the camera. You just have to rotate them right.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: John VanSickle
Subject: Re: rendering skyboxes
Date: 8 May 2004 20:21:55
Message: <409D79A0.E4ECEEAE@hotmail.com>
Barron Gillon wrote:
> 
> I have an OpenGL project, and I was wanting to use pov to render textures
> for my skybox.  Dos anyone have any experience with this?  I've been messing
> with the sphere camera and, surprisingly enough, its textures map very well
> to a sphere.  But I want to map to a box.  I've been playing with the output
> of the sphere camera and concluded that it is a dead end.  Does anyone have
> any insight?  Your help would be greatly appreciated!

Note for more ambitious developers:

Instead of one polygon for the directions x, -x, y, -y, z, and -z, you can
render 26 polygons (all combinations of -1, 0, and 1 in x, y, and z, except
for <0,0,0>).  The images (and the polygons) only need to be half the size
(in both width and height) of the ones used for the cubes.  This will involve
a slightly higher memory requirement (26 quarter-meg images instead of 6 one-
meg images), but the images will be higher quality (less "wide-angle"
distortion).  If you do not allow the user to look too near to straight up or
straight down, you can forget those two patches and have the exact same
amount of image data.

The camera statement for rendering all 26 views of a single scene would look
like this:

camera {
  direction z*(sqrt(2)+1)/2
  right x
  up y
  location 0
  #switch(frame_number)
    #case( 0) look_at <-1,-1,-1> #break
    #case( 1) look_at < 0,-1,-1> #break
    #case( 2) look_at < 1,-1,-1> #break
    #case( 3) look_at <-1, 0,-1> #break
    #case( 4) look_at < 0, 0,-1> #break
    #case( 5) look_at < 1, 0,-1> #break
    #case( 6) look_at <-1, 1,-1> #break
    #case( 7) look_at < 0, 1,-1> #break
    #case( 8) look_at < 1, 1,-1> #break
    #case( 9) look_at <-1,-1, 0> #break
    #case(10) sky x look_at < 0,-1, 0> #break
    #case(11) look_at < 1,-1, 0> #break
    #case(12) look_at <-1, 0, 0> #break
    #case(13) look_at < 1, 0, 0> #break
    #case(14) look_at <-1, 1, 0> #break
    #case(15) sky x look_at < 0, 1, 0> #break
    #case(16) look_at < 1, 1, 0> #break
    #case(17) look_at <-1,-1, 1> #break
    #case(18) look_at < 0,-1, 1> #break
    #case(19) look_at < 1,-1, 1> #break
    #case(20) look_at <-1, 0, 1> #break
    #case(21) look_at < 0, 0, 1> #break
    #case(22) look_at < 1, 0, 1> #break
    #case(23) look_at <-1, 1, 1> #break
    #case(24) look_at < 0, 1, 1> #break
    #case(25) look_at < 1, 1, 1> #break
  #end
}


Post a reply to this message

From: Slime
Subject: Re: rendering skyboxes
Date: 8 May 2004 23:28:30
Message: <409da55e@news.povray.org>
> Instead of one polygon for the directions x, -x, y, -y, z, and -z, you can
> render 26 polygons (all combinations of -1, 0, and 1 in x, y, and z,
except
> for <0,0,0>).

Interesting. How are these images to be mapped to polygons? I can't think of
a way which uses squares in all directions (except for methods which involve
allowing polygons to clip each other).

> the images will be higher quality (less "wide-angle"
> distortion).

How is that? If the camera is always perfectly centered in the sky box with
the simple model, there won't be any distortion, as far as I can tell.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: John VanSickle
Subject: Re: rendering skyboxes
Date: 9 May 2004 03:24:45
Message: <409DDCBA.D3A66A69@hotmail.com>
Slime wrote:
> 
> > Instead of one polygon for the directions x, -x, y, -y, z, and -z, you can
> > render 26 polygons (all combinations of -1, 0, and 1 in x, y, and z,
> except
> > for <0,0,0>).
> 
> Interesting. How are these images to be mapped to polygons? I can't think of
> a way which uses squares in all directions (except for methods which involve
> allowing polygons to clip each other).

The corners are done with triangles (and there is some wasted image space
around the triangles).  All the rest are squares.

> > the images will be higher quality (less "wide-angle"
> > distortion).
> 
> How is that? If the camera is always perfectly centered in the sky box with
> the simple model, there won't be any distortion, as far as I can tell.

The standard projection distorts the view near the edges of the image.  This
is because the angle between any two pixels is not constant across the image.
The effect is decreased when the camera angle is smaller.

In the example I gave, a 1024-pixel view across an angle of 90 degrees gives
an angle of roughly .112 degrees near the center of the image, but an angle
of roughly .056 between the pixels are the left and right ends of the range.
This a 2:1 ratio going from the center to the edges.  Granted, this stretched
look is recompressed when rendered in OpenGL, but it makes more sense to
reduce the stretching and squeezing, if possible, as it may produce unwanted
artifacting.

A 512-pixel view, across the angle of 45 degrees, gives an angle of roughly
.0927 degrees between pixels in the center of the image, and .0792 near the
edges, giving a ratio of about 1.171:1.  The potential for artifacting is
reduced.

Note that if the rendering does not require images to have dimensions that
are a power of two, then the quality of the cube map using 1024x1024 images
can be achieved by the higher-polygon method using 424x424 images, at a
significant savings in total image size (25%).

Regards,
John


Post a reply to this message

From: Barron Gillon
Subject: Re: rendering skyboxes
Date: 11 May 2004 17:54:35
Message: <40a14b9b$1@news.povray.org>
Thanks!  I didn't try this on my own, because I was sure it wouldn't work
well, but... it did.  Thanks again

"Slime" <fak### [at] emailaddress> wrote in message
news:409c7bb9@news.povray.org...
> > I have an OpenGL project, and I was wanting to use pov to render
textures
> > for my skybox.  Dos anyone have any experience with this?
>
> This code is from a scene which I used to render a sky box for one of *my*
> openGL programs:
>
> camera {
>  location 0
>  right x
>  up y
>  direction z
>
>  angle 90
>
>  #if (frame_number = 0)
>   look_at  x
>  #else #if (frame_number = 1)
>   look_at  -x
>  #else #if (frame_number = 2)
>   look_at  y
>  #else #if (frame_number = 3)
>   look_at  -y
>  #else #if (frame_number = 4)
>   look_at  z
>  #else #if (frame_number = 5)
>   look_at  -z
>  #end #end #end #end #end #end
> }
>
> use it in an animation with 6 frames (0 through 5), and a square output
> aspect ratio, and there are your 6 images which should be texture mapped
to
> squares surrounding the camera. You just have to rotate them right.
>
>  - Slime
>  [ http://www.slimeland.com/ ]
>
>


Post a reply to this message

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