Advertisement

Subdividing a triangle.

Started by March 08, 2003 04:56 PM
5 comments, last by circuit 21 years, 11 months ago
I''m trying to build an engine that adds more detail to the (asteroid) models when they come close to the camera. I''m doing this by subdividing each triangle into 4 smaller triangles by interpolating vertices, normals and texture coordinates. It works fine, but how do I make the new surface curve acording to the smooth shading normals of the original triangle?
You are trying to add detail that simply isn''t there. The usual way of handling this problem is to have a model with high detail, and then remove detail as it get further from the camera.

One way of handling it is to have several levels of detail, and morph between the models depending on desired accuracy.
Another way is to model the object using parametric surfaces. This enables you to recreate the object at whatever detail level you want.

500x1


emptyhead
Watch out for advice from the successfull, they don''t want company
:wq!
Advertisement
Say you subdivide you triangle like so:

......X.....*.*....*...*...Y#####Y..*.#...#.*.*...#.#...*X*****Y*****X 

Where X is a vertex in the old triangle, and * is an edge in the old triangle, Y is a subdivided vertex, and # is new edges added. So we go from 1 triangle to 4.

Now, we have an interpolated normal for Y. Ok, so just push that vertex out by some value times your normal. You probably want this value to be of the form value = constant * (1-DOT(normal1,normal2)), where normal1 and normal2 are the normals you are interpolating between. Intuitively, this means that when the normals are pointing in the same direction, you push it out no space at all, and when they start to point apart, you start pushing it out.

DOn't forget to normalize your normals.

EDIT: spacing


[edited by - sjelkjd on March 8, 2003 6:33:21 PM]
emptyhead, if he couldn''t be bother doing proper LOD this way he''ll at least get improved lighting. And besides for an asteroid you could probably get away with adding some randomness to the new verticies for that extra detail.
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it's my very good honor to meet you and you may call me V.".....V
I''m using subdivided triangles for a world generator (er... planet-scale heightfield generator)

You have another problem if you choose this method... When you subdivide a triangle like this, you need to subdivide the neighboring triangles as well... otherwise your surface will have holes in it.

The deal is that if you divide a neighbor in four parts, you need to divide all of its neighbors as well... until EVERY triangle on the entire surface is divided... for my system, this is unacceptable -- I only want the triangles near the camera to have high subdivision.

I am developing a NASTY algorithm that deals with dividing these neighbors in half (instead of in four parts), that can undo the half-split and perform a full-split when required... It''s only based on the fact that my surface is a fractal that stores a small random seed in each vertex pair...

If you were using this for ANY other object than an asteroid, I wouldn''t even be posting this. But since I''ve seen that my system can accurately produce asteroids as well as the smoother planet shapes, you may be able to use this method.

500*1
quote:
Original post by Nypyren
...

I am developing a NASTY algorithm that deals with dividing these neighbors in half (instead of in four parts), that can undo the half-split and perform a full-split when required... It''s only based on the fact that my surface is a fractal that stores a small random seed in each vertex pair...

If you were using this for ANY other object than an asteroid, I wouldn''t even be posting this. But since I''ve seen that my system can accurately produce asteroids as well as the smoother planet shapes, you may be able to use this method.

500*1


If you haven''t alreadt, do a (google) search for ROAM. There are algorythms for this out there...
Advertisement
Yeah, but I feel extra cool when I re-invent them myself. Seeing how I have to implement it anyway in my very specific system, I'm just as well off.

[edited by - Nypyren on March 9, 2003 3:41:34 AM]

This topic is closed to new replies.

Advertisement