Sign in to follow this  
Disfunctional

UV coordinates for a plane?

Recommended Posts

haegarr    7372
Strictly seen: Not at all. The plane as is given is infinite with no special point or direction.

If you want to have u,v you need an origin and one direction (then the other direction can be computed from the first and the normal). Since the plane doesn't have those features, you need to either pick them more or less randomly or else abstain from u,v.

Share this post


Link to post
Share on other sites
haegarr    7372
The (u,v) tuple is nothing more than 2 co-ordinates in the 2D u,v co-ordinate system. A co-ordinate system needs an origin and as many non co-linear directions as dimensions are there. The plane has 2 dimensions but is given in 3D space. So, although the origin and u,v directions are given as 3D vectors, they need to be constrained to lie within the plane:
For the origin o
o . n - D == 0
(dependent on the definition of D you may need to use plus instead of minus above), and for the directions
u . n == 0
v . n == 0
where n denotes the plane's normal, and D the distance.

Usually u and v are choosen to be orthonormal (i.e. orthogonal and of unit length)
u . v == 0
so that
u := v x n can be used to compute u if v is already chosen.

Then any point p on the plane can be expressed by the (u,v) co-ordinate tuple because of
o + u * u + v * v == p
so that for any p the (u,v) tuple can be computed.

Share this post


Link to post
Share on other sites
haegarr    7372
There is in fact no single definition of "good" in this case, at least not until knowing what the purpose of finding (u,v) on an infinite plane is.

Mathematically simple is the point closest to the world origin, like
o := n * D
(maybe you need to use -D here).

Or do you prefer a point that is within the view frustum of a camera? I don't know.

Share this post


Link to post
Share on other sites
haegarr    7372
The given equations have nothing to do with tiles by itself. If you've implemented it and observe tiling, then you probably see the effect of how you've set-up texturing. By definition the entire texture is mapped in the range [0,1]x[0,1]. Now, the plane you use has infinite extension, so that the above range occurs infinitely often. For example, if you see (u,v) from (-1,-2) up to (3,4) then there are 3--1==4 tilings in u direction and 4--2==6 tilings in v direction.

You can influence this by choosing another scaling in (u,v).

Share this post


Link to post
Share on other sites
Disfunctional    100
So I have p and I would like for example calculate the v (coordinate).

o (origin coordinates) + u (coordinate) * u + v (coordinate) * v = p

Now I've a problem, I get a vector division? So can you show me how I can express u into p? (I am a little bit confused)

I assume p is the coordinate that I get when a ray from my raytracer hits the plane.

Share this post


Link to post
Share on other sites
haegarr    7372
Quote:
Original post by Disfunctional
So I have p and I would like for example calculate the v (coordinate).

o (origin coordinates) + u (coordinate) * u + v (coordinate) * v = p

Now I've a problem, I get a vector division? So can you show me how I can express u into p? (I am a little bit confused)
What you have here is a linear equation system with 3 equations:
ox + u * ux + v * vx = px
oy + u * uy + v * vy = py
oz + u * uz + v * vz = pz
where u and v are the unknown variables. So you have to apply a method os solving this system.

Quote:
Original post by Disfunctional
I assume p is the coordinate that I get when a ray from my raytracer hits the plane.
p means any point on the plane. So a hit of a ray is absolutely a valid example. I've mentioned the formula to show you the correspondence between (u,v) and the belonging 3D point p due to the co-ordinate system build using o, u, and v. You can use it in the case that you need to compute (u,v) for a given point. Maybe you don't have the need at all.

Share this post


Link to post
Share on other sites
haegarr    7372
Quote:
Original post by Disfunctional
So if I got this straight, I need to solve that system to get my formulas for u and v and I can just plug them into my ray tracer?
Exactly. As already mentioned above, you may consider some scaling.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this