Re: Tiling several textures on one model

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: GuitarBill (GuitarBill_at_cox_dot_net)
Date: 07/18/04


Date: Sat, 17 Jul 2004 17:37:53 -0700

For a sphere, your normals would be = vertex position normalized (assuming
sphere is centered on origin).

For SpacePod (http://www.spacepod-game.com) we mapped the earth with 13
256x256 textures, based on Fuller projection. I wish we had gone to 512x512,
which would have looked better... although still not enough for you (we are
basically constant distance from earth). This would have been about 13Mb.
I would tend to assume 384Mb is way too much - I would aim for 256Mb
absolute tops and preferably no more than 128 or even 64 (Note: 13 textures
at 1024x1024 would be 52Mb).
Using this method does mean mapping the textures semi-manually (certainly
quite a pain to get everthing to match up correctly).

If you are mapping cylindrically you are essentially wasting a lot of
texture memory - there will be much more detail at the poles than near the
equator. The geosphere/Fuller type projection gives more-or-less constant
texel size across the sphere.

Because its a sphere, you will presumably only ever see less than half the
sphere at any one time - an argument for not using a single texture, and
also for using some kind of pseudo-homogeneous mapping method (wherever you
look from you get similar memory/cache performance).

Bill

"RonHiler" <rhiler@rjcyberware.com> wrote in message
news:95e0fab7.0407171542.1a9bd38e@posting.google.com...
> Hi guys,
>
> Thank you so much for the advice. After further experimentation, it
> turns out I need a much bigger bitmap than I thought. We're zoomed
> WAY in on the world map, so anything less than 16384 x 8192 looks
> pixellated.
>
> So, it appears that I have to break up the bitmap (and hence the
> sphere mesh) anyway. As long as I was doing it anyway, I figured I
> might as well go down to 256x256 chunks.
>
> Actually breaking up the model was easier than I thought. In
> initialization, I created a 2D array of vertices like so:
>
> //set up the 2-unit sphere points
> for (int v=0; v<33; v++)
> {
> float Phi = ((2.0*((float)(v))-32.0)/2.0f)*(PI/32.0);
> for (int u=0; u<64; u++)
> {
> float Theta = (2.0*((float)(u))-64.0)*(PI/64.0);
> SpherePoints[u][v].p.x = 2 * cos(Phi) * sin(Theta);
> SpherePoints[u][v].p.y = -2 * sin(Phi);
> SpherePoints[u][v].p.z = 2 * cos(Phi) * cos(Theta);
> SpherePoints[u][v].n.x = 0.0f;
> SpherePoints[u][v].n.y = 0.0f;
> SpherePoints[u][v].n.z = 1.0f;
> }
> }
>
> It's a 2 unit sphere because that's the size of the x file mesh I was
> using before, so I thought I'd stick with the same size. Then I draw
> it with the following code, after setting all the usual stuff
> (material, texture, world matrix, and so on):
>
> for (unsigned int v=0; v<32; v++)
> {
> for (unsigned int u=0; u<64; u++)
> {
> if (u == 63)
> UPlusOne = 0;
> else
> UPlusOne = u+1;
> SpherePoints[u][v].tu = 0.0f;
> SpherePoints[u][v].tv = 0.0f;
> SpherePoints[u][v+1].tu = 0.0f;
> SpherePoints[u][v+1].tv = 1.0f;
> SpherePoints[UPlusOne][v].tu = 1.0f;
> SpherePoints[UPlusOne][v].tv = 0.0f;
> SpherePoints[UPlusOne][v+1].tu = 1.0f;
> SpherePoints[UPlusOne][v+1].tv = 1.0f;
> *Vertices++ = SpherePoints[u][v];
> *Vertices++ = SpherePoints[UPlusOne][v+1];
> *Vertices++ = SpherePoints[u][v+1];
> *Vertices++ = SpherePoints[u][v];
> *Vertices++ = SpherePoints[UPlusOne][v];
> *Vertices++ = SpherePoints[UPlusOne][v+1];
> NumTriangles +=2;
> Direct3D.IncrementTriangleCount(2);
> }
> }
>
> I could have used an index buffer (as Robert suggested) to accomplish
> the same thing, I realize, but this works fine. At the moment I am
> using a single 256x256 test texture, though I am aware I'm going to
> have to swap textures for every section.
>
> The only two things I'm a little worried about is that the texture
> swapping will cause undo delays (read: bad frame rate) and the amount
> of memory 2048 256x256 textures take up (384 MB at 24 bpp, yipes! I
> hope all my users have 512MB+ of memory installed).
>
> I haven't FULLY tested it yet, but preliminary results with a single
> bitmap give good framerates, and the sphere appears to be drawing
> correctly (have to double check on the poles though, and make sure I
> got the logic right).
>
> Any further advice? Oh, I don't have the normals in correctly (as you
> can see), what would be the easiest way to enter the proper values? I
> got a bit stuck trying to calculate them, so just gave up for the
> moment :)
>
> Ron



Relevant Pages

  • Re: Tiling several textures on one model
    ... > sphere is centered on origin). ... Everything else kind of revolves around this map. ... > texture memory - there will be much more detail at the poles than near the ... I'm using a Mollweide projection to store the map data (it runs 30.6 ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Newbie - Plotting and selecting points
    ... I'm using VC++/MFC and I don't know how the get the bitmaps from the ... should I be using some kind of texture map to do this? ... find the point of intersection of the user's picking ray with the sphere ... Of course if you want really big markers relative to the ...
    (comp.graphics.api.opengl)
  • Re: How do I tile a sphere ?
    ... Currently I load a rather large single texture of the earth and cover the ... I think I need to convert to a tiles approach where I divide the sphere ...
    (comp.graphics.api.opengl)
  • Re: Noob Needs Help With Texture
    ... > 2) Assigned a new Blinn material to the sphere ... > 3) For the color of the Blinn material, I chose to use the Marble texture ... > When I render it out, it seems the model is in fact turning but the texture ... to create a reference for the texture, under the Rendering menus, ...
    (comp.graphics.apps.alias)
  • Re: lighting problem on surface
    ... you are going off the ends of texture. ... Is this code with normals OK? ... k_s = specular reflection coefficient ...
    (comp.graphics.api.opengl)