Calculating UV coordinates for a Bezier Patch

How can I generate the texture coordinates using constant steps in arclength for a Bezier Patch?

heh, that’s a whopper of a question!

You have to reparameterize in both U and V for length, and the problem is, that means remapping such that if u == 0, s == 0, but at u == 1, s != 1 (in most cases). This gives rise to the problem that you can only anchor the texture to one point on the surface, so unless you constrain the length (which can change), the texture will seem to “slide” around points far away from the anchor point.

But, that’s not the question you asked. You asked how to reparameterize, so I’ll give you the rundown of what I’ve found, though I’ve only done it for single Bezier splines, though I’m 100% sure this method can be extended to surface patches.

First off, d/l the paper here: http://www.visgraf.impa.br/sibgrapi96/trabs/abst/a14.html

That is really all i used, though it is quite formal and they omit some of their proof.

Secondly, I posted a question, myself, about the final part of this on www.gamedev.net. See, using the method presented in this paper is an approximation, so when the curve was very “curved”, the errors began to creep out. It may have been my implementation, but, i dunno. When I posted my question, also posted the outline of how I did it. The url of my other post is http://www.gamedev.net/community/forums/topic.asp?topic_id=48807, but I will include the text from the post (which should answer your question) here:

"I’m reparameterizing a cubic Bezier curve such that I can calculate points on it in terms of distance along the curve from the first control point.

Why bother with this? Well, for those who do not know, there are many reasons, a good one being that the velocity/acceleration of bodies traveling along an un-reparameterized bezier curve will not be linear, i.e. even though the parameter t may exhibit a known behavior, such as a particular velocity/acceleration, the distance of bodies travelling along the curve based on the parameter t may or may not be proportional to t at all times and they will thus tend to speed up or slow down at times based on their position in the curve. Heh, it sucks when that happens… Personally I am making a curved text renderer, which means drawing normal characters about a curve instead of a straight line. In order to properly space the characters along the curve, I must reparametrize the curve in terms of length.

It works great for short curves, and most of the way through long curves, but at the end of a long, highly curved curve, the parameterization starts to stretch and again become dependant on the un-arc-length-reparameterized curve.

Ok, here’s the high level overview w/o the specific algorithms used for the individual parts:
find s in terms of t*
invert this function, to describe t in terms of s*
find t for each character, based on the width of all previous characters.

  • = there is no closed form solution, so approximation is necessary

Specifics:
Finding s here is all calculus, and there is no closed form solution. s(t) is basically the integral, from 0 to t, of the magnitude of the derivative of the curve… It is way too hard to type in here, so if that english isn’t enough for you, then don’t worry about it, cuz this part isn’t that important. The important part is that the only way to find s in terms of t is to approximate this integral. The closest approximations I’ve found are using Simpson’s rule (found in HS and college calc texts), or Legendre-Gauss quadrature, both of which are prohibitively slow. After a google search I found a beautiful 1996 paper by Marcelo Walter and Alain Fournier here. Now this is some heavy duty real-time!

The basic premiss these guys use is to evaluate s(t) in a few discrete places, using the -slow- method, and, from these, construct a 2nd bezier curve (“a length curve”) to approximate the relationship between t and s(t). The length curve is forced to act like a true function (x = t, in all cases).

This is great because it reduces finding the length to any arbitrary point t to a closed form function s(t) where s(t) is the y of LengthCurve( t ).

Alright, so here you have a way to get the length at any point on the curve. This function needs to be inverted, so that t can be found in terms of s. Again, there is no analytical solution to this, so you have to use another approximation method (their paper said that the Newton-Raphson method would work best).

Ok, so, now it is possible to figure out t in terms of s, so all i have to do is draw a character, find it’s length along the curve, then find the t value for that next position. This works great at first, but starts to stretch out…

Things I figure are wrong: 1) there is too much error involved in the approximations, though the paper said < 8.3%, i believe.
2) my math is wrong
3) this method won’t work for all situations.
"

hope this helps!

–Succinct