RB: Sphere mapping?

Member
Posts: 40
Joined: 2002.04
Post: #1
Hi everyone,

I was wondering if it is possible to acheive a reflection map on objects using RB3D (quesa)? I'm not sure what the correct terminology is, but is it called a spheremap? All I want is a 2D texture shrinkrapped onto an object with the same orientation, no matter which way the object is facing. Can I acheive this by editing the 3DMF file, or do I need extra coding?

Sorry for the confusing question, but I'm sure someone out there will understand!
Thanks
Quote this message in a reply
w_reade
Unregistered
 
Post: #2
If you want a reflection map, you won't be able to just shrinkwrap it onto the model, you'll need to take into account the orientations of the faces. This would probably be pretty damn slow, but you could bounce a ray off each vertex from the camera and see where it ends up "at infinity", and then recalculate the u,v co-ordinates based on this. (see your environment map shrinkwrapped onto an infinitely large sphere surrounding your scene, and get the texture coordinates from where the reflected ray intersects the sphere)

Remember, if you use a square image, you'll probably get noticeable distortions at the top and bottom, I believe circular images are the way to go for nice-looking results. You may need two circular ones (one for northern, one for southern hemisphere) otherwise there'll be much more detail on one side.
Quote this message in a reply
Member
Posts: 40
Joined: 2002.04
Post: #3
Thanks for helping, but wow, that sounds extremely hard.

I cant understand ProjectBuilder / Cocoa, but is this method similar to the method used in the UseSphereMap example in the GLUTexamples folder?

Thanks
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
OpenGL has built-in support for generating texture coordinates for use with sphere maps.

I don't know whether that's exposed in any way, shape or form by Quesa, though.

If you look at the OpenGL specification, you should be able to find the mathematical formulae used to generate the sphere mapping texture coordinates, if that's useful to you.
Quote this message in a reply
Member
Posts: 351
Joined: 2002.04
Post: #5
If you can get a hold of it (or maybe you already have it) the QD3D SDK had a couple of pdfs written by Brian Greenstone. One of them was called "Cool tricks" or something like that and had a section on achieving sphere mapping in QD3D. That might be a help.
Quote this message in a reply
w_reade
Unregistered
 
Post: #6
Sphere mapping is all very well, and useful in certain circumstances, but it won't give you reflections on anything except a sphere.

it shouldn't be too tricky; let me try again.

I'm assuming that you have, at each vertex, a normal vector and a pair of texture co-ordinates.

Then, for each visible vertex, do the following:

1: get a vector pointing from the camera to the vertex.

2: reflect this vector in the plane defined by (perpendicular to) the vertex's normal.

3: convert the resulting vector into spherical polar co-ordinates (without worrying about its magnitude).

You'll end up with two numbers which represent, essentially, longitude and latitude - and so each one can be multiplied by some constant to give you u and v co-ordinates on a rectangular texture. Then just give your vertex the new texture coordinates, and render as normal.

u = longitude * textureWidth/TwoPi
v = (latitude + PiByTwo) * textureHeight/Pi

(assuming you're using radians)

Reflecting the vector shouldn't be too hard, and there must be any number of places on the web to tell you how to convert to spherical polar co-ordinates.

I hope this helps.

ps If you're programming in 3d it'd really help to learn some 3d vector maths, if you haven't already. It'll make things much easier.

pps watch out: those polygons which cross over the horizontal edge of the map may (will) look funny if you don't do some extra checks. This should get you started, thoughÖ
Quote this message in a reply
w_reade
Unregistered
 
Post: #7
ok, I just looked up the reflection formula, 'cos it was bothering me. Here's how to do it:

V = vector pointing from vertex to camera
N = normal vector at vertex
R = reflected vector

R = (2N.V)N - V

them convert R to spherical polar and you're away.

ps if you know 3d maths already, sorry to be patronising. pls forgiveGrin

[edit] I think V should be normalised. Presumably N is already.
Quote this message in a reply
Member
Posts: 92
Joined: 2002.04
Post: #8
Hello Cookie
Did you go to the Apple show last month in Adelaide?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #9
You talking to me?

No, Adelaide's a bit far & expensive, especially with a new computer in the house Wink

I haven't even been as far as Auckland for an Apple event...

I notice that there're a growing number of south-pacific-ers on this forum, though. I think so far I've counted five New Zealanders and four or five Australians. Maybe there's an opportunity there to have a south pacific Mac-Game-Dev meeting...
Quote this message in a reply
Member
Posts: 92
Joined: 2002.04
Post: #10
No not you OneSadCookie, your to much of a regular for me not to know were you are from. I just noticed that Cookie who started the thread was from Adelaide thats all.
Quote this message in a reply
Member
Posts: 351
Joined: 2002.04
Post: #11
Quote:Originally posted by OneSadCookie

I notice that there're a growing number of south-pacific-ers on this forum, though. I think so far I've counted five New Zealanders and four or five Australians. Maybe there's an opportunity there to have a south pacific Mac-Game-Dev meeting...

This is going a bit off topic now, but I had thought of a Mac-Game-Dev meeting for us Oceanics as well, but we seem a bit spread out, aside from the two Adelaideans on this thread.
Quote this message in a reply
Member
Posts: 40
Joined: 2002.04
Post: #12
Thanks to everyone for your help, especially to w_reade.

Thanks also to monte, I'll see if I can find it.

Baldock- unfortunately the Apple show was during the middle of my exam week; so I didnt have time to go. Did you go? What was it like?
Quote this message in a reply
Member
Posts: 92
Joined: 2002.04
Post: #13
Lucky for me the boss is a Apple/Mac fan so me and one of the other guys were allowed to knock off 1.5 hours early so we could go in to it. Wasn't to bad. Next time Apple have a developers night I'll have to remember to e-mail you, those nights are always a lot more interesting.
Quote this message in a reply
Post Reply