|
kurt miller's homepage
( My development journal and homepage has moved to a new system here: kurtm.flipcode.com ) |
|||||||
I mentioned in my last journal update that I was thinking of trying an approach where the triangles of a mesh keep subdividing until each is under some area A, the purpose being to capture the texture detail in the triangle colors. I spent a little time tonight implementing it. Again, I should preface this by saying I just did this to experiment and have a bit of fun. I'm not really sure what its practical uses (if any) would be. In my tests, the source mesh is fit to a cube with dimensions of 100 units, and the subdividing function takes a maxarea parameter to split with. Here are a couple screenshots from the results, along with the maxarea and resulting triangle counts:
function create( source mesh, maxarea )
{
for each triangle (t) in the mesh
{
subdivide( t, maxarea )
}
}
function subdivide( triangle t, maxarea )
{
area = area(t);
midpoint = midpoint(t);
if(area > maxarea)
{
// triangles a,b,c are each built from two
// vertices of t and its midpoint;
subdivide( a, maxarea );
subdivide( b, maxarea );
subdivide( c, maxarea );
}
else
{
// using the midpoint of t and the original
// parent triangle, calculate the color of t
// using barycentric coordinates;
add_to_triangle_list(t);
}
}
The technique for coloring the triangles using barycentric coordinates and the source
texture is the exact same approach I described in my voxel journal entry.
As you can see the resulting triangle counts are pretty high, and the quality isn't exactly sparkling.
One cool thing though (other than getting rid of the textures), is that vertex lighting would
look a lot more like per-pixel given the number and size of the triangles. I haven't written
an optimized version of the renderer yet, so no demo this time, but if I do I'll be sure to post it.
|
|||||||
| Site Contents Copyright (c) 2002-2004 Kurt Miller. Please do not reprint this jibberish anywhere. |