View Full Version : Texture mapping onto a disk

jenny_wui

03-27-2013, 04:56 PM

I am trying to map a texture on a disk. Each coordinate on the disk is defined by (rscos(theta), rsin(theta), 0). I know texture value ranges from (0,0) to (1,1). How to map texture coordinates to vertices, i.e. how to calculate the (u,v) texture coordinates for the disk. Thanks.

tonyo_au

03-27-2013, 06:18 PM

when theta = 0, u = 1, v =0.5

when theta = 90, u = 0.5, v = 1

when theta = 180, u = 0, v = 0.5

when theta = 270, u = 0.5, v = 0

jenny_wui

03-27-2013, 07:27 PM

Thank you. So for inbetween values of theta, u,v, will be linearly interpolated. Is it?

Could you explain a bit about why you are assigning those values to u and v?

Thanks again in advance.

tonyo_au

03-28-2013, 06:25 AM

So for inbetween values of theta, u,v, will be linearly interpolated

No its a circle. So the the inbetween depend on the the coordinates of the triangles yo use to make up circle.

The u/v values can be calcuated from the ratio of the x/y of the triangle vertex to the x/y of the above values.

eg a vertex at theta = 45 is r * 0.7071, r * 0.7071

vertex values range from -1 * r to +1 * r and the correspondings textures coordinates go from 0 - 1

so the texture coordate for a point in the circle is (1 + cos(theta))/2,(1 + size(theta))/2

jenny_wui

03-28-2013, 03:45 PM

Thank you very much for the clarification. That meanstexture coordinate varies according to theta i.e. (1 + cos(theta))/2,(1 +sin(theta))/2).

Suppose, for each triangle in the disk, the coordinates are as follow:

glVertex3f( 0.0, 0.0, 0.0);

glVertex3f( x, y, 0.0);

glVertex3f(x1, y1, 0.0);

where x,y are rcos(theta), rsin(theta)

x1, y1 are rcos(theta_one), rsin(theta_one);

Now I am able to calculate the (u,v) coordinates at (x,y) and (x1,y1) from thevalues of theta.

But what about the texture coordinate at the origin i.e. (0.0, 0.0, 0.0)?

tonyo_au

03-28-2013, 06:55 PM

(0.5,0.5.) - the centre of the texture

jenny_wui

03-28-2013, 07:51 PM

Thank you so much for the clarification.

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.