kurt miller's homepage
( My development journal and homepage has moved to a new system here: kurtm.flipcode.com )

Texture Detail Using Colored Triangles 02 November 2002, 3:26AM

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:

maxarea: n/a, triangle count: 226

maxarea: 10.0, triangle count: 1950

maxarea: 1.0, triangle count: 19,278

maxarea: 0.1, triangle count: 190,026
The source mesh in the screenshot has 226 triangles before subdivision, and in the above screenshots, no textures are used. The subdivision in my tests was done brute-force, recursively, using the midpoint of each triangle. The basic algorithm looks like this in psuedo-code:

    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.






Complete List Of Journal Updates:
  • Auto-Terrain Texturing (15 November 2004, 12:27PM)
  • On Orientation Interfaces (14 November 2004, 7:30PM)
  • Basic Terrain Generation (10 November 2004, 4:39AM)
  • Engine Tool Interface (07 November 2004, 2:37AM)
  • Render Buffer Ranges (02 November 2004, 5:15AM)
  • wxWidgets GUI Toolkit (29 October 2004, 2:31AM)
  • Generic Rendering Interfaces (27 October 2004, 6:55PM)
  • Source Documentation with Doxygen (25 October 2004, 6:34PM)
  • Signs of Life? (25 October 2004, 5:14PM)
  • Key Value Scripts (08 November 2003, 4:32PM)
  • Octrees for Potential Colliders (01 November 2003, 4:09PM)
  • Flexporter and Game Levels (31 October 2003, 12:14PM)
  • New Project and More Updates (31 October 2003, 6:14AM)
  • HSL Color Space (07 May 2003, 6:14AM)
  • A Couple Graphics Books (02 December 2002, 5:12PM)
  • Texture Detail Using Colored Triangles (02 November 2002, 3:26AM)
  • Voxel Mesh Creation and Rendering (27 October 2002, 11:30AM)
  • Development Journal (25 October 2002, 10:57AM)



  • Site Contents Copyright (c) 2002-2004 Kurt Miller. Please do not reprint this jibberish anywhere.