diff --git a/documentation/texturemapping.txt b/documentation/texturemapping.txt index c8392f99..9dd25ffd 100644 --- a/documentation/texturemapping.txt +++ b/documentation/texturemapping.txt @@ -85,12 +85,15 @@ Note that PolyVox currently stores that material identifier for the vertex as a Blending between materials -------------------------- -An additional complication when working with smooth voxel terrain is that it is usually desirable to blend smoothly when adjacent voxels have different materials. This situation does not occur with cubic meshes because the texture is considered to be per-face instead of per-vertex, and PolyVox enforces this by ensuring that all the vertices of a given quad have the same material. +An additional complication when working with smooth voxel terrain is that it is usually desirable to blend smoothly between adjacent voxels with different materials. This situation does not occur with cubic meshes because the texture is considered to be per-face instead of per-vertex, and PolyVox enforces this by ensuring that all the vertices of a given quad have the same material. -With a smooth mesh it is possible that each of the three vertices of any given triangle have different material identifiers (see figure below). If this is not explicitely handled then the graphics hardware will interpolate these material values across the face of the triangle. the is usually not desirable because if, for example, the three material identifiers are {1, 1, 8} then the interpolated values will pass through all identifiers between one and eight, which includes a number of completely unrelated materials. Fundermentally, the concept of interpolating between material identifiers does not make sense, because if we have 1='grass', 2='rock' and 3='sand' then it does not make sense to say rock is the average of grass and sand. +With a smooth mesh it is possible that each of the three vertices of any given triangle have different material identifiers (see figure below). If this is not explicitely handled then the graphics hardware will interpolate these material values across the face of the triangle. This is usually not desirable because if, for example, the three material identifiers are {1, 1, 8} then the interpolated values will pass through all identifiers between one and eight, which includes a number of completely unrelated materials. Fundamentally, the concept of interpolating between material identifiers does not make sense, because if we have 1='grass', 2='rock' and 3='sand' then it does not make sense to say rock is the average of grass and sand. -There are a couple approaches we can adopt to combat this problem. One approach is to attach an alpha value to each vertex so that certain corners of a triangle can be faded out. If a trangle has the same material value at each vertex then we also give it full alpha at each vertex and the triangle draws normally. +There are a couple approaches we can adopt to combat this problem. One approach is to attach an alpha value to each vertex so that corners of a triangle can optionally be faded out. If a triangle has the same material value at each vertex then we also give it full alpha at each vertex and the triangle draws normally, but if it has a differnt material for each vertex then we duplicate the triangle three times (once for each material). Each new triangle should then use the same material at each vertex, this material being one of those from the original triangle. The alpha values of the vertices of the new triangles are set such that when the three triangles are drawn on top of each other with additive alpha blending, the desired smoothly shaded triangle results. +One drawback of this approach is that the mesh needs to be drawn with alpha blending enabled, which is both costly and also allows previously drawn geometry to show through. Therefore, before any alpha blended geometry is drawn, you also need to draw the triangle solidly in black. This whole process is rather difficult to explain, but hopefully this diagram of the inputs and outputs makes it clearer: + +Both of these processes are a lot of work, and add costs such as increasing the amount of geometry being rendered, increasing the size of the vertex data, and adding the cost of alpha blending. However, it can be noted that most of the triangles in a given smooth mesh only use a single material, and so it may well be useful to actually split the input mesh into two parts. The first part would contain only Storage of textures =================== \ No newline at end of file