0
109 Mar 06, 2012 at 05:21

Hi,

Can someone please help me get the proper UV mapping for a skydome such as this one…

https://encrypted-tb…yt50Wu7hvQBuwMs

I’ve tried the following but isn’t looking right!

m = 2 * sqrt(map.x*map.x + map.y*map.y + (map.z+1.0)*(map.z+1.0));
U = ray.dir.x/m + 0.5;
V = ray.dir.y/m + 0.5;

Thanks!

#### 19 Replies

Please log in or register to post a reply.

0
101 Mar 06, 2012 at 07:06

A bit more context, please. What is map and ray?

0
109 Mar 06, 2012 at 08:09

Sorry! map as actually ray.dir, I forgot to modify it before posting! So it should be this…

vec3 ray.dir(x,y,z)…

m = 2 * sqrt( x\^2 + y\^2 + (z+1.0)\^2 );
U = x / m + 0.5;
V = y / m + 0.5;

Thanks.

0
151 Mar 06, 2012 at 09:33

That looks like a latitude/longitude style texture map.

If you convert the x,y,z, of the vert to latitude longitude and scale it to the range 0-1 it should work.

lat = atan2(z,y)
longitude = atan2(x,z)

At least that’s what I would try

0
167 Mar 06, 2012 at 15:58

That’s definitely not a lat-long map; it’s a “mirror-ball” map - a parallel projection of sphere reflecting the world. Anyway, the equations you posted are a little confused. Here is an article on the topic, and according to it the equations for using a mirror-ball map are:

m = sqrt(2.0 * (z + 1.0))
u = 0.5 * x/m + 0.5
v = 0.5 * y/m + 0.5

0
101 Mar 06, 2012 at 17:58

@Reedbeta

That’s definitely not a lat-long map; it’s a “mirror-ball” map

Is it really? The image looks lile it has the horizon at the edge of the circle. A mirror ball would have the horizon a bit in from the edge, where the angle of the balls surface is 45 deg. and at the edge, where the surface is parallell to the eye ray, the ground behind the ball would be visible.

0
109 Mar 06, 2012 at 18:17

@Reedbeta

That’s definitely not a lat-long map; it’s a “mirror-ball” map - a parallel projection of sphere reflecting the world. Anyway, the equations you posted are a little confused. Here is an article on the topic, and according to it the equations for using a mirror-ball map are: m = sqrt(2.0 * (z + 1.0))
u = 0.5 * x/m + 0.5
v = 0.5 * y/m + 0.5

This worked perfectly Reedbeta :)) Thank you

One more question. Is it possible to set the FOV for the skydome map separatetly from the rest of the model? What I mean is, viewing my model at FOV=35, the sky seems very close. Viewing it at FOV=75 looks much better, I can see the sun. But my model is also viewed at 75. So what I want to do is display the model at 35 but the skydome at 75. Is that possible?

0
167 Mar 07, 2012 at 00:10

Hmm, geon, you’re right - it looks more like a 180-degree fisheye or something than a true mirror-ball map, which contains the entire environment. Alienizer, that might be why you’re having a FOV problem - the map is supposed to be 180 degrees wide, but is being stretched over 360 degrees, hence looks bigger (closer) than it should be.

Alienizer, you might try using the fisheye equations from this article and see how well that works.

0
109 Mar 07, 2012 at 00:50

@Reedbeta

Hmm, geon, you’re right - it looks more like a 180-degree fisheye or something than a true mirror-ball map, which contains the entire environment. Alienizer, that might be why you’re having a FOV problem - the map is supposed to be 180 degrees wide, but is being stretched over 360 degrees, hence looks bigger (closer) than it should be. Alienizer, you might try using the fisheye equations from this article and see how well that works.

Actually, it’s a skydome. The shot was taken on the ground facing up (90 deg) to the sky, that’s why no ground is in the shot. The other equation did not work, but yours does!

It’s like this one…

http://www.barnabu.c…in-sketchup.JPG

Here is a big image of the skydome as oppose to the thumbnail I posted…

http://www.tutorialsforblender3d.com/Textures/Skys/SkyDome/SkyDome-Cloud-Medium-MidMorning.png

direct linking not allow, so here is the page…

0
109 Apr 21, 2012 at 03:01

None of the algo on this thread works for the following maps…

http://sw-in.narod.ru/hdrout.html

Any idea what the correct u,v mapping algo is for this one? Thanks!

0
167 Apr 21, 2012 at 03:34

Those look like mirror-ball maps, like I mentioned in post #5 in this thread. But these images are taken with the camera horizontal instead of vertical, so you might have to rotate your vectors by 90 degrees before calculating the texture map.

0
109 Apr 21, 2012 at 03:46

oh, you’re right, it works after rotation. Thanks Reedbeta

0
109 Apr 21, 2012 at 04:06

Using these kind of maps makes the back a funnel, which is expected I guess, and reflection such as a mirror in the model will look weird. Is there something i don’t know about this? or is it just the way it is?

0
167 Apr 21, 2012 at 04:33

With the mirror-ball maps, the part around the edge doesn’t have such good resolution, and you get a lot of texture distortion. Is that what you mean by “makes the back a funnel”? If so, that’s just the way it is with mirror-ball maps.

0
109 Apr 21, 2012 at 08:03

Yes, that’s what I meant. ok then. what kind of map is best to use for all round good resolution?

0
101 Apr 21, 2012 at 14:49

Use a qube map instead. There are a lot of them available and they are easy to make and use.

0
109 Apr 21, 2012 at 16:18

ok, but is that not accurate? I mean, the corners will look weird when rotating the cam?

0
167 Apr 21, 2012 at 20:00

There’s no map that has perfectly uniform texel shapes and sizes around the whole sphere. A skydome or cubemap will do pretty well, and you won’t notice the distortion if the map is high-resolution and authored well.

0
101 Apr 21, 2012 at 20:34

@Alienizer

ok, but is that not accurate? I mean, the corners will look weird when rotating the cam?

There is no problem I’m aware of. It is used very commonly ingames.

0
109 Apr 21, 2012 at 23:33

ok thanks Geon