Stam-Loop subdivision surface modifier WIP

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Mikael Öhman
Posts: 4
Joined: Thu Jul 19, 2012 2:35 pm

Stam-Loop subdivision surface modifier WIP

Postby Mikael Öhman » Thu Jul 19, 2012 4:02 pm

Hi everyone. I just wanted to mention that I'm working on a Stam-Loop subsurf modifier. It's similar to Catmull-Clark but splits triangles into 4 smaller triangles (no center node), as opposed to 3 ugly quads.

Check out the research article by Stam and Loopfor some examples ... f/qtEG.pdf

I just more or less finished the actual subdivision and smoothing code, and its available at
which is at the point where it compiles fine, and I'm fairly sure its implemented more or less correctly. However, I haven't yet run a single test!
I wrote the code only to deal with 1 subdivision level at the time because;
  • Its a lot simpler. Doing different things with triangles and ngons really makes it hard to do anything else.
  • If its working with multires, then some sculpting is probably going on at each subdivision level, making a recursive implementation acceptable.
  • It could be expended upon later, when the basic stuff is working. It should be possible without recursion.

The code is inspired by CCGSubSurf.

Right now I'm digging through the code in subsurf_ccg, which is enormous. Since everything is pretty much undocumented, its a painstaking procedure.
I'm not even confident I will have the time to finish it.

If anyone feels like helping me out with this I would really appreciate it.

Mikael Öhman
Posts: 4
Joined: Thu Jul 19, 2012 2:35 pm

Postby Mikael Öhman » Wed Aug 08, 2012 4:14 pm

So the code is slowly starting to work. Still a bit of rendering stuff to do, and there seems to be some artefacts from the smoothing code, so the weight mask needs adjustment (just as stated in the article).

The major problems are how much the Catmull-Clark infects code that it shouldnt touch. CCG* stuff is everywhere i look. Its a disaster.

As an example, here is roughly what it is supposed to look like, CCG and Stam-Loop side by side on a 25% beveled cube (subdiv level 4 i believe).
(although, as I said, the smoothing on Stam-Loop isn't perfect yet).

Mikael Öhman
Posts: 4
Joined: Thu Jul 19, 2012 2:35 pm

Postby Mikael Öhman » Mon Aug 20, 2012 3:33 am

I took some time to rewrite my modifier so that it directly outputs the smoothed verts, which means
1. Lower memory usage
2. Less copying data back and forth
(in comparison to the catmull-clark code).
The code is written so that it can update only the modified part, like the vertex coordinates (from sculpting), vertex colors, uv coordinates, without modifiying anything else (although the modifier structure doesn't take advantage of that just yet).

The code is also now much shorter, roughly 1000 lines of code in total.
As much as possible is left as the default implementation in CDDerivedMesh.
I've designed the code to work well with updating the geometry. It also uses OpenMP, but for now it seems most time is spent rendering (I'm hoping VBO will optimize that by many orders of magnitude).

The MultiRes modifier is heavily specialized in the Catmull-Clark, so it might take some time to add this scheme to it, but for now, enjoy

Creases, vertex colors, UV-maps all work (although no smoothed UV-maps yet).

Here is another example where this subdivision scheme clearly beats Catmull-Clark;

Return to “Coding Blender”

Who is online

Users browsing this forum: No registered users and 1 guest