POV-Ray : Newsgroups : povray.general : Rendering texture for use in SkySphere Server Time
5 Nov 2024 11:17:15 EST (-0500)
  Rendering texture for use in SkySphere (Message 1 to 10 of 10)  
From: Xilo Musimene
Subject: Rendering texture for use in SkySphere
Date: 14 May 2003 15:24:41
Message: <3EC297FA.9010509@hotpop.com>
Hi there,
   I was wondering what where the best ways I could render a nice 
SkySphere, what kind of camera, etc...


Say I want to draw a sky full of stars...  say my stars are sphere... 
say that I can place the spheres all around the origin to make a sphere 
of stars around it.

Now how could I capture this sphere from the origin to make a texture 
that I can use in an object like a skysphere later.

(Actually, I will use it out of povray, so I really need to render the 
texture)

Thanks,
   Xilo

-- 
Dedicated to audio/visual and interactive artwork.
http://www.geocities.com/simonlemieux/


Post a reply to this message

From: Warp
Subject: Re: Rendering texture for use in SkySphere
Date: 14 May 2003 15:39:55
Message: <3ec29b8b@news.povray.org>
Actually what you are trying to do is a (spherical) environment map,
which is a very basic technique.
  You can render such spherical environment map by specifying "spherical"
in your camera settings. Usually the optimal resolution for such map
is twice as wide as high (eg. 256x128 or whatever).
  After this you can use the image created like this as an image map
with spherical mapping (map_type 1 iirc).

  You can have a lot more than just stars there if you want. You can
have planets, entire worlds or whatever. The only requisite is that
none of the geometry in this "world" should be anywhere near the camera.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Xilo Musimene
Subject: Re: Rendering texture for use in SkySphere
Date: 14 May 2003 16:22:20
Message: <3EC2A57C.1050002@hotpop.com>
>   Actually what you are trying to do is a (spherical) environment map,
> which is a very basic technique.
>   You can render such spherical environment map by specifying "spherical"
> in your camera settings. Usually the optimal resolution for such map
> is twice as wide as high (eg. 256x128 or whatever).
>   After this you can use the image created like this as an image map
> with spherical mapping (map_type 1 iirc).
> 
>   You can have a lot more than just stars there if you want. You can
> have planets, entire worlds or whatever. The only requisite is that
> none of the geometry in this "world" should be anywhere near the camera.

Warp, you just made things perfectly clear to me!  I knew there was 
something simple but could find it...

I know I can have more than just stars and that's the point of using 
povray for my sky texture!

It's for use in a backgound sphere for a new opengl program I'm doing...

Now, I wonder how to map this texture on an OpenGL sphere...  Normally, 
I would have to do a cylindrical mapping on my sphere, but I can deform 
the texture to make it spherical...

I guess I should deform it with a sinus of some sort...  Anyway, should 
be easy by now...

Thanks a lot!
-- 
Dedicated to audio/visual and interactive artwork.
http://www.geocities.com/simonlemieux/


Post a reply to this message

From: Warp
Subject: Re: Rendering texture for use in SkySphere
Date: 14 May 2003 16:42:12
Message: <3ec2aa24@news.povray.org>
Xilo Musimene <xil### [at] hotpopcom> wrote:
> It's for use in a backgound sphere for a new opengl program I'm doing...

  You know what? I have done *exactly* this about a week ago for a
school project (ie. render an environment map with povray and use it
in a "sky sphere" in OpenGL).

> Now, I wonder how to map this texture on an OpenGL sphere...

  That's easy. Here is the code I used for my sky sphere.

  Firstly it's handiest to make a display list for the sky sphere:

    glNewList(SKY_ID, GL_COMPILE);
    {   
        glDisable(GL_LIGHTING);
        glDisable(GL_DEPTH_TEST);
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, SKY_ID);

        generateSkyDome();

        glEnable(GL_DEPTH_TEST);
    }
    glEndList();

  This assumed you have bound the environment map to the texture number
SKY_ID (I use enum constant for all display lists and textures; it makes
things a lot more clear).
  You can then display the sky sphere like this (note that this should be
executed *before* drawing anything else in the scene):

    // Sky (remove translation from transf matrix):
    GLdouble m[16];
    glGetDoublev(GL_MODELVIEW_MATRIX, m);
    m[12]=m[13]=m[14]=0;
    glPushMatrix();
    glLoadMatrixd(m);
    glCallList(SKY_ID);
    glPopMatrix();

  The idea is that the sky sphere is a unit sphere around the camera (in
the same way as in povray). Since it disables depth-testing during its
drawing, everything else will be drawn over it, giving the impression
that the sky sphere is infinitely away (this is why it's important that
the sky sphere is drawn before everything else).

  The generateSkyDome() function which is called above looks like this:

void generateSkyDome()
{
    const unsigned steps = 16;

    glColor3d(1,1,1);

    for(unsigned vInd = 0; vInd < steps; ++vInd)
    {
        double
            v1 = .001+.998*(double(vInd)/steps),
            v2 = .001+.998*(double(vInd+1)/steps);
        double
            vsin1 = std::sin(v1*M_PI),
            vsin2 = std::sin(v2*M_PI),
            vcos1 = std::cos(v1*M_PI),
            vcos2 = std::cos(v2*M_PI);
        double
            vTexCoord1 = double(vInd)/steps,
            vTexCoord2 = double(vInd+1)/steps;

        glBegin(GL_QUAD_STRIP);

        for(unsigned hInd = 0; hInd <= steps*2; ++hInd)
        {
            double
                hsin = std::sin(hInd*M_PI/steps + M_PI/2),
                hcos = std::cos(hInd*M_PI/steps + M_PI/2);

            glTexCoord2d(double(hInd)/(steps*2), vTexCoord1);
            glVertex3d(-hsin*vsin1, vcos1, hcos*vsin1);
            glTexCoord2d(double(hInd)/(steps*2), vTexCoord2);
            glVertex3d(-hsin*vsin2, vcos2, hcos*vsin2);
        }

        glEnd();
    }
}


-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Xilo Musimene
Subject: Re: Rendering texture for use in SkySphere
Date: 14 May 2003 20:07:24
Message: <3EC2DA3C.6060807@hotpop.com>
>   You know what? I have done *exactly* this about a week ago for a
> school project (ie. render an environment map with povray and use it
> in a "sky sphere" in OpenGL).

Good to see a fellow OpenGL devellopper! =)

>             glTexCoord2d(double(hInd)/(steps*2), vTexCoord1);
>             glVertex3d(-hsin*vsin1, vcos1, hcos*vsin1);

It seems to me that you build a sphere correctly, but map the image like 
if the sphere were a cylinder, there is no sin, cos, etc.. in your 
glTexCoord2d() statement...

I probably missed something somewhere; I a good programmer, but a poor 
analyst...

I will try to render a grid with povray and map the grid, this way I 
will clearly see any deformation!

Thanks Warp!
   Xilo

-- 
Dedicated to audio/visual and interactive artwork.
http://www.geocities.com/simonlemieux/


Post a reply to this message

From: Warp
Subject: Re: Rendering texture for use in SkySphere
Date: 14 May 2003 21:24:13
Message: <3ec2ec3d@news.povray.org>
Xilo Musimene <xil### [at] hotpopcom> wrote:
>>             glTexCoord2d(double(hInd)/(steps*2), vTexCoord1);

> It seems to me that you build a sphere correctly, but map the image like 
> if the sphere were a cylinder, there is no sin, cos, etc.. in your 
> glTexCoord2d() statement...

  It's as it should be. The spherical projection works this way. When
using the spherical projection, the image is evenly spaced on the surface
of the sphere in the longitudinal (ie. vertical) direction. Thus the
uv-coordinates have to be evenly spaced as well.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Xilo Musimene
Subject: Re: Rendering texture for use in SkySphere
Date: 14 May 2003 23:18:09
Message: <3EC306E9.2040905@hotpop.com>
>   It's as it should be. The spherical projection works this way. When
> using the spherical projection, the image is evenly spaced on the surface
> of the sphere in the longitudinal (ie. vertical) direction. Thus the
> uv-coordinates have to be evenly spaced as well.

You are probably right...  I'll try what I can and I'll post some 
results in povray.binary.images

Thanks,
   Xilo

-- 
Dedicated to audio/visual and interactive artwork.
http://www.geocities.com/simonlemieux/


Post a reply to this message

From: Rohan Bernett
Subject: Re: Rendering texture for use in SkySphere
Date: 15 May 2003 01:10:03
Message: <web.3ec320511591996c18ccf4f70@news.povray.org>
If you're going to render an image for a sky in another program (particulary
a polygon-based one), rather than using a sphere, you could use a skybox.
Just render 6 views of your scene looking n,s,e,w,u,d with a 90 degree
camera angle and as square images. Then just map them onto the surfaces of
a cube, place a camera in the centre of the cube, and there you go.

Rohan _e_ii


Post a reply to this message

From: Xilo Musimene
Subject: Re: Rendering texture for use in SkySphere
Date: 15 May 2003 06:16:25
Message: <3EC368FE.8050502@hotpop.com>
> If you're going to render an image for a sky in another program (particulary
> a polygon-based one), rather than using a sphere, you could use a skybox.
> Just render 6 views of your scene looking n,s,e,w,u,d with a 90 degree
> camera angle and as square images. Then just map them onto the surfaces of
> a cube, place a camera in the centre of the cube, and there you go.

Interesting, I think indeed there would be no visible deformation... 
and will take up much less polygons!  Thanks!


BTW, I'm currently doing the exact opposite:  I'm rendering a box in 
povray with the spherical camera and applying it to a sphere in opengl 
to see if it looks like a sphere stuffed in a box...

Will post images to p.b.images...

Thanks,
   Xilo

-- 
Dedicated to audio/visual and interactive artwork.
http://www.geocities.com/simonlemieux/


Post a reply to this message

From: Warp
Subject: Re: Rendering texture for use in SkySphere
Date: 15 May 2003 10:13:30
Message: <3ec3a08a@news.povray.org>
Xilo Musimene <xil### [at] hotpopcom> wrote:
> Will post images to p.b.images...

  It's strange that I don't see such deformations in my program.
  Perhaps I will post some images as well...

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

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