Ask Your Question

Revision history [back]


I've used Tachyon some, but I don't know a way to give different colors to two sides of a surface. I suspect this functionality doesn't exist because at the most fundamental level the surfaces Tachyon makes are just 2-dimensional. Tachyon's Triangle object, in particular, is a 2-dimensional triangle. You could think of them as being just 1 pixel thick, and then your question would be how you can color two "sides" of a pixel with different colors.

But I think being able to color 2 sides of an orientable surface differently would be a great feature! I can think of a few ways to do this:

  1. Shading: This isn't really a solution but it is certainly the easiest way to (sort of) differentiate between different parts of the surface. The "diffuse" attribute is probably the useful one for this; if you're not familiar with what ambient, diffuse, and specular mean, take a look at Phong shading.

  2. Two surfaces: This is another relatively easy way to simulate a non-zero thickness: just draw two copies of the same surface very close to eachother. Whether or not this is feasible depends a lot on the surface you are interested in and how its parametrized. Also this might double the rendering time!

  3. Hack the Tachyon string: The answer you linked to shows how to get the Tachyon string for an object. You could write a program to search for triangles in that string and, for each triangle, add a second triangle pushed just a little in the (positive) normal direction, with a new color. Knowing which direction is "positive" might be tricky, and doing so consistently is equivalent to actually constructing an orientation on your surface. Again the feasibility of this approach depends a lot on the particular surface you're interested in.

  4. Make a ThickTriangle class, and modify the Sage source: This is definitely the most daunting and far-reaching approach, but depending on your background might be doable. Find where in the plotting process Sage is making Tachyon triangles, and add a new type of triangle which makes two triangles with different textures, separated by a given parameter. There are already two triangles (standard and "smooth"), and I see that the SmoothTriangles also require a normal direction. In fact, if Sage is producing SmoothTriangles from your parametric plot, then the tricky issue of choosing a "positive" normal direction may already be done for you!