Skydome mapping

19 replies to this topic

#1Alienizer

Member

• Members
• 435 posts

Posted 06 March 2012 - 05:21 AM

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!

#2geon

Senior Member

• Members
• 939 posts

Posted 06 March 2012 - 07:06 AM

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

#3Alienizer

Member

• Members
• 435 posts

Posted 06 March 2012 - 08:09 AM

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.

#4Stainless

Member

• Members
• 578 posts
• LocationSouthampton

Posted 06 March 2012 - 09:33 AM

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

#5Reedbeta

DevMaster Staff

• 5307 posts
• LocationBellevue, WA

Posted 06 March 2012 - 03:58 PM

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
reedbeta.com - developer blog, OpenGL demos, and other projects

#6geon

Senior Member

• Members
• 939 posts

Posted 06 March 2012 - 05:58 PM

Reedbeta, on 06 March 2012 - 03:58 PM, said:

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.

#7Alienizer

Member

• Members
• 435 posts

Posted 06 March 2012 - 06:17 PM

Reedbeta, on 06 March 2012 - 03:58 PM, said:

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?

#8Reedbeta

DevMaster Staff

• 5307 posts
• LocationBellevue, WA

Posted 07 March 2012 - 12:10 AM

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.
reedbeta.com - developer blog, OpenGL demos, and other projects

#9Alienizer

Member

• Members
• 435 posts

Posted 07 March 2012 - 12:50 AM

Reedbeta, on 07 March 2012 - 12:10 AM, said:

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.tutorials...-MidMorning.png

direct linking not allow, so here is the page...
http://www.tutorials...Sky_Dome_2.html

#10Alienizer

Member

• Members
• 435 posts

Posted 21 April 2012 - 03:01 AM

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!

#11Reedbeta

DevMaster Staff

• 5307 posts
• LocationBellevue, WA

Posted 21 April 2012 - 03:34 AM

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.
reedbeta.com - developer blog, OpenGL demos, and other projects

#12Alienizer

Member

• Members
• 435 posts

Posted 21 April 2012 - 03:46 AM

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

#13Alienizer

Member

• Members
• 435 posts

Posted 21 April 2012 - 04:06 AM

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?

#14Reedbeta

DevMaster Staff

• 5307 posts
• LocationBellevue, WA

Posted 21 April 2012 - 04:33 AM

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.
reedbeta.com - developer blog, OpenGL demos, and other projects

#15Alienizer

Member

• Members
• 435 posts

Posted 21 April 2012 - 08:03 AM

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

#16geon

Senior Member

• Members
• 939 posts

Posted 21 April 2012 - 02:49 PM

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

#17Alienizer

Member

• Members
• 435 posts

Posted 21 April 2012 - 04:18 PM

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

#18Reedbeta

DevMaster Staff

• 5307 posts
• LocationBellevue, WA

Posted 21 April 2012 - 08:00 PM

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.
reedbeta.com - developer blog, OpenGL demos, and other projects

#19geon

Senior Member

• Members
• 939 posts

Posted 21 April 2012 - 08:34 PM

Alienizer, on 21 April 2012 - 04:18 PM, said:

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.

#20Alienizer

Member

• Members
• 435 posts

Posted 21 April 2012 - 11:33 PM

ok thanks Geon

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users