# FP for texture mapping radial data?

I want to draw a long, thin triangle where one side has a 1d texture, the other side has a different 1d texture, and the interior is a bilinear interpolation of the two.

Right now I’m simply walking out along the triangle drawing quads for each sample. It works and is surprisingly quick but uses tons of memory. For example, one scene has 920 samples per 1d texture and I need to draw 600 triangles. Even after eliminating blank samples, it still needs 709,000 vertices.

I’m wondering if a fragment program could eliminate all these quads and associated memory usage. What I’d like to do is have a 2x1024 texture, put the samples for one side of the triangle in row 0 and the samples for the other side in row 1. I draw a triangle with texCoords of 0,0 - 1,0 - 1,1 then have my fragment program dork with fragment texture coordinates (x,y are the incoming texCoords to the FP):

x’ = x
y’ = y / x

I use these new coordinates to look up my color in the 2x1024 texture. Essentially, I’m trying to pinch a quad into a triangle while maintaining the quad’s interpolation.

Is this possible with a fragment program?

Thanks

I don’t quite get the problem. Couldn’t you simply draw one quad where two of the vertices are identical and let standard texture mapping fill out the space in between?
You should be a little careful about texture coordinates. If you want to be precise, use the centers of the corner texels and use a proper clapming mode (clamp_to_edge most likely).

Maybe I get it now. You have data at the edges of a radial cut through something and want to apply the mapping following a radial sweep about the pinpoint of the sliver triangle?
In that case I’d try a fragment program which calculates a normalized Euler distance to the center of rotation and use that for the u-coordinate and a normalized angular distance from one of the edges and use that as v-coordinate in a texture lookup.

[This message has been edited by Relic (edited 01-19-2004).]

A quad would degenerate into a single triangle (or a big triangle and a sliver). I don’t think I need to do an azimuth/range calculation since the texture coordinates for the triangle could be used. For example, with a triangle going from the center to the right, the top texture coordinates would go from (0,0)-(1,0). The bottom edge texCoords would go from (0,0)-(1,1). What I need to do is to blow out the bottom edge’s v coordinate by dividing by the u coordinate. That way the bottom edge’s texCoords will go from (0,1)-(1,1) with smooth interpolation between.

>>A quad would degenerate into a single triangle (or a big triangle and a sliver). <<

Yes, the positions would, but you have two different texture coordinates for a single point then! One edge would interpolate along one set of texture coordinates the other edge along the correct opposite. With perspective correct interpolation this should work, shouldn’t it.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.