Watertight Tessellation: precise and fma

One important feature of Direct3D 11 and OpenGL 4, which I have seen very little written about, is the addition of a new precise qualifier. It’s no surprise there’s some confusion about the purpose and motivation for this new keyword. The Direct3D documentation is vague about it:

precise affects all results that contribute to the variable’s outcome by preventing the compiler from doing unsafe optimizations. For instance, to improve performance the compiler ingores the possibility of NaN and INF results for floating point variables from constant and stream inputs in order to do several optimizations. By using the precise keyword, these optimizations will be prohibited for all calculations affecting the result of the variable.

Besides the typos (ingores?), it’s not very clear what “unsafe optimizations” actually means, since only a single example is provided. On the other side, the OpenGL specification is a lot more “precise”:

The qualifier “precise” will ensure that operations contributing to a
variable’s value are performed in the order and with the precision
specified in the source code. Order of evaluation is determined by
operator precedence and parentheses, as described in Section 5.
Expressions must be evaluated with a precision consistent with the
operation; for example, multiplying two “float” values must produce a
single value with “float” precision. This effectively prohibits the
arbitrary use of fused multiply-add operations if the intermediate
multiply result is kept at a higher precision.

OpenGL makes it clear that precise causes operations to be performed in the exact order prescribed by the language rules. It also highlights that the precision of the operations must also be exactly as prescribed and not greater, which rules out the use of fused multiply-add if implemented according to the IEEE 754-2008 specification, to which most modern GPUs conform.

Continue reading →

Back Online

You may have noticed my blog has been down during the last few months. I had some trouble with the server and lost all my posts. Unfortunately I did not have backups so it took quite some effort to restore them. At least I’ve managed to recover most articles and some of the posts that I wrote last year.

I really didn’t bother to restore the ones in which I only whine about my back pain; I’d rather not remember that part of my life. Some articles still have missing images, and I may update them progressively.

In the meantime I’ve written a couple of articles for The Witness blog and in the future I’ll continue posting most of my technical articles there as well:

Last spring was fantastic. I went hiking almost every single weekend and felt in better shape than ever. I’ve started writing some notes about my hikes in an attempt to plan them better; I don’t think this stuff is very useful to anyone but me, but here it is anyway:

Nacho’s Hiking Notes

This summer I went to Spain and stayed there 5 weeks, much longer than usual. My grandmother died unexpectedly and it was good to be able to spend some more time with my family. When I got back I realized how lonely I am here in the US, how superficial are all my relationships.

I tried to stay in shape while abroad, but there’s nothing like the DAM workouts. I was flirting with lane 5 when I left and I’m now back to lane 3 again. The first two weeks have been excruciating, but I’m getting back into my routine and hopefully I’ll make my way up again.


A lot has been going on in the last few months.

Mariana is 14 weeks pregnant, so we are expecting to have another kid by the beginning of November. She has just finished her studies and has found herself a job at EMQ/FamiliesFirst. She works counseling problematic children and loves it so far, but she has a terrible schedule, her shift is on weekend nights, so we don’t get to see each other much over the weekends.

So, now Nachito and I have plenty of time to spend together. Spring is here and in Davis the weather is great during this time of the year, so we are spending most of our time outdoors. We have been working in our garden again, Nachito helps me spread compost and plant the starts, he loves playing with worms.

We have also been exploring the surrounding parks: Berryessa, Cold Canyon, Cache Creek, Capay Valley and various sections of the South Yuba river. The rivers in the foothills are still a bit too cold for swimming, but the creeks in the North Coast Range are just perfect on a hot day. Nachito loves climbing on rocks and he’s getting increasingly good at it.

I keep swimming, not for rehabilitation anymore, but for recreation and fitness. I’m now in better shape than I’ve ever been and I feel pretty good about it. However, my back is not entirely healed yet; I cannot sit for long periods of time. I still feel a mild pain after driving long hours, biking on a rugged road or going to the movies. So, I keep working on stand-up desk. At this point it feels very natural, I don’t get tired as I used to anymore. Sitting on a chair feels too constraining, they remove too many degrees of freedom, it just feels wrong.

The Witness is progressing well, although on my side things are going a bit slower than I hoped. I need to get my shit together and use my time more effectively. Part of the problem is that I have too many distractions at home, so I’ve finally rented an office and I’ll be moving in tomorrow. For the first time in my life I won’t have a computer at home, I’m going to stay like that for a while, but I’ve been thinking I should probably get a laptop.

The Witness

Jon has recently started a development blog about The Witness, the game that we have been working on during the last few months. So far there are a few posts about the technology and the aesthetics of the game and I’ll soon write a bit more about the global illumination implementation in some more detail. Keep an eye on it!


I’ve been biking around Davis since I bought my new road bike. It’s a very nice experience. There are many nice country roads around here (see this great map of the area) and the weather is always friendly. I really like biking towards the mountains, because I can easily see my progress. I’m now able to reach the foothills of the north coast range and next time I should be able to get to Lake Berryessa.

I love the feeling of being able to go almost anywhere just by the sheer strength of my legs. I’ve even been thinking about commuting to San Francisco by bike. I could easily go to Vallejo and take the Ferry to San Francisco, but a more ambitious route would be to go through the north bay, of course, I would do that on a Sunday, spend the night in the city and return by train.

New Job

Last Friday was my last day at NVIDIA. Next Monday I’ll start working with Jon Blow on The Witness. I’m excited to get back to the game industry and I’m hoping something really cool will come out of this.

In any case, I had a great time working at NVIDIA during the last 4+ years; I especially enjoyed the time I spent working on tessellation. I’ll definitely miss the great people that I had the chance to work with. Some of them are in the following picture of my last day at work:

In clockwise order: Aravind, James, Tianyun, Eric, Sarah, Ignacio (not me), Cem, Lars, Timothy, Philippe, Matthieu, Paulius and Tristan.

Continue reading →

Continuity Mapping for Multi-Chart Textures

Naty Hoffman references a paper from Siggraph Asia titled Continuity Mapping for Multi-Chart Textures.

The paper provides a solution to a problem that I’ve talked before, that multi-chart parameterizations introduce seams over meshes, and that these seams can produce severe artifacts in some use cases such as displacement mapping. While the solution that I propose removes the cracks in the mesh, it does not eliminate the seams entirely, in only eliminates the holes, so for that reason I still suggested that the use of seamless parameterization remains valuable.

The most interesting thing about the Continuity Mapping solution is that it does not require a re-parameterization of the mesh, allowing you to preserve the uv-map created by the modeler, which is sometimes useful. It’s cool that they reference my presentation at Siggraph 2008, although I first proposed that solution a few months before at Gamefest, and more detailed descriptions of the technique are available in my blog.

In general, I agree with Naty’s assessment that the technique is likely to be inefficient due to divergent branching. Although it may make sense for some applications, it’s unlikely it will be adopted for use in games. Naty describes some other issues, but one that I think is important as well is that it’s unclear how their sewing technique can handle tangent space normal maps. None of the examples in the paper appear to use normal maps, so I suspect the authors may be aware of the problem.

With tangent space normal maps each chart has a different tangent space. Tangent frames are defined at the vertices and interpolated over the triangles, and the tangent spaces do not agree along the seams of the charts.

Per texel normals are then stored with respect to the chart’s tangent space. You cannot interpolate normals that belong to different charts directly. Instead, you have to first transform them to the same space and do the interpolation afterward. That’s generally done in the pixel shader (although it would be more correct to do it before texture filtering). However, their sewing technique introduces new triangles over which the tangent space is simply not well defined since tangent frames at opposite sides of the seam could have completely arbitrary directions and their interpolation would likely result in degenerate frames.