rendering a bezier patches

Started by
4 comments, last by Xeno 21 years, 2 months ago
hi , im trying to render a bezier patches , i mean , i had already generetaed the point for the patch , now im just trying to connect them with triangles , but i have some problems with the corners of the curve , look at this diagram:

this diagram represent the grid of a patch that forms something like a "hill" shape , (u know - what u get when the fours middle control point are a bit higher that the others) with triangles connecting the dots. lets start from the upper horizontal bezier curve , this is simpliy an horizontal line. it means that the Z values of the point on this line are the same. lets move to next horizontal curve, the bottom right point of the red rectangle will get a bit higher that the others because of the curve shape , so the two red triangles that build the red rectangle will be rendered in a slope. lets look at the blue triangle , this triangle be rendered without ANY slope (because all it point are on the curves that are just simple lines) , in the other side , the yellow triangle will be rendered in a slope because it lower left point is somewhere on the curve... the result is asymetric bezier patch... how can i solve it? [edited by - xeno on January 29, 2003 5:40:07 AM]

------------------------------- Goblineye Entertainment------------------------------

Advertisement
The problem is the direction of your splits. Running them all the same way requires a higher tesselation to look good. I''m pretty sure the split in the upper right corner is correct though. I think the overall surface will look better at a given tesselation if you flip the splits on the upper left and lower right 2x2 subgrids. I think given four heights the easiest way to decide a direction for the split is to average the heights and throw out the height furthest from the average. That leaves you a trangle which tells you which way to run the split.

Take what I say with a grain of salt though. I''m just throwing out ideas. I''m fairly certain the slits should roughly follow a contour line. You should be able to look at a grid of a rolling terrain with just the splits shown and pretty well tell where the hill tops are. I''m far less certain of just how to get that to happen.
Keys to success: Ability, ambition and opportunity.
i think that the average idea would work pretty well... , another question i have is how most of the people render it? do they just rise the tesselation?

[edited by - xeno on January 29, 2003 8:36:32 AM]

------------------------------- Goblineye Entertainment------------------------------

Personally I would use a 2x2 grid of patchs. Generally you use beziers to control the slope. You want a contineous surface from one to another. 2D is easier to visualize. If you hook a bezier to a line segment then the first control point is at one end of the line segment. The second one should be on the line that the line segment is on. With two beziers the 4th control point of one is also the first of the next. The third control point of the first one should be in a line with the second control point of the second bezier as well as the common control point. If you do that with a bezier patch and plane then all points on the patch lies in the plane. I think that is more your problem than the tesselation. You have a discontineous slope.

A 2x2 grid with 49 (15 are shared) control points may seem daunting. It can be controlled with three values though. The height, how flat on top and how steep the sides. You can view the control points as a 7x7 grid of points. You can draw lines connecting those points to form concentric squares. The outermost square is anchored in place and those control points never move. The other two squares only shrink and expand. The center control point determines the height of the hill as well as the elevation of the innermost square. The size of the innermost square determines how flat the top of the hill is. The elevation of the middle square is the same as the outermost square, but how close it is to the innermost square determines how steep the sides are.

The only problem is that I think this will give you a square hill. That is because the control points are in a square. So instead you lay them out in a circle. You need a grid so you just make the grid large enough to contain the circle. Anything outside the circle is flat. Well, you don''t actually pass through the middle control points so you have to lay those out so that the perimeter approximates a circle.

You can manipulate it with three basic parameters, but there are only certain relationships that actually must be maintained. As an example the center of the hill doesn''t have to be the center of the grid. If you draw a circle roughly connecting the control points those circles don''t have to have the same center and they don''t even have to be circles. The control points at the top of the hill only have to be in the same plane, but that plane doesn''t have to be parallel to the plane you are joining to. So you can give the designer three basic options for shaping a hill with advanced options available when they want them. You can also make the advanced options in the context of scuplting a hill so they never know it has anything to do with beziers much less control points. As an example click where you want the center or enter a slope and draw a line representing the direction that slope is in.

You can let them see what they are doing by providing a grey scale bitmap where the whiteness corresponds to the height. It would be a massive hill if each pixel mapped to a grid square. It lets you handle any size hill they attempt, makes it a reasonable size, lets you deal with a fixed size and give them enough detail to have a reasonable idea of what they are doing. You can then plug in differant generators that take the standard parameters, provides it''s own advanced options and just returns a bitmap to the standard dialog. You then have another function that lets the user paint that bitmap onto the terrain. It uses the size of the grid the hill is painted on to sample the bitmap to actually adjust the heights.

You may be picturing just plopping this thing down on a terrain. You don''t want to do it that way. Instead picture the terrain as elastic with this thing under it pushing up. That gives the user additional control. As an example on rolling terrain they might just use two or three hills pushed up varying degrees in differant places. It also lets you merge hills rather than one hill taking a big bite out of another.

Well, anyway, just a few ideas. To a large extent just thinking outloud. I got stuck on this awhile back and couldn''t figure out how the program I was cloning did it. Starting to get a lot better picture now. Still a few questions left though.
Keys to success: Ability, ambition and opportunity.
You just need more tessellation. For an example, see my bezier patches demo. I don''t see the problem you are talking about in that demo.

Firebird Entertainment
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
You might also consider creating a mirror image tesselation, e.g., split the quadrilaterals on the right-half-of-center on the opposite diagonal, so the patch is effectively mirrored left-to-right. If I read your post correctly, this would give you a symmetric patch without needing higher tesselation.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement