Effectiveness of Ptex method in the field of and Polygon Topology

Andrija Bernik Damir Vusić Robert Geček Department of Multimedia Department of Multimedia Department of Multimedia University North University North University North Varaždin, Croatia, Europe Varaždin, Croatia, Europe Varaždin, Croatia, Europe [email protected] [email protected] [email protected]

Abstract — This paper presents several texturing problems that computer resources and mapping automation.[2] The last of occur in complex polygon topology where the model is based on these properties does not agree with Kim et al[9] as far as the tris and ngons. It also shows an experiment and describes the storage efficiency of textures goes. They stated that the Ptex application of the Ptex system for mapping textures onto a 3D Method uses a wasteful packing strategy that increases the model. The topology parameterization using 3D Coat and its storage cost of the textures many times over their original auto-retopology tools are shown as well. A new topology model was tested using a texture checker inside Mudbox and VRay. size. Nevertheless, we have created a 3D model where Additionally, a comparison was made between Mantra and classical UV mapping isn’t efficient and introduced a Ptex VRay rendering systems, where specific difficulties had workflow with rendering specs. occurred when applying Ptex mapping. The aim of this experiment is to present how cache memory directly interferes II. DESIGN AND PARAMETERIZATION OF with texture filtering and rendering speeds. This paper MODEL TOPOLOGY concludes with the advantages and disadvantages observed in relevant literature and through an empirical approach to this A complex model was selected for the elaboration of the technology. textures in order to test the practical flexibility of Ptex (Fig.

Keywords — per-face-texturing, ngons, retopology, VRay and 1) and show possible problems that are common in the field Catmullrom filter of CG texturing. This is a part of the replica model of the Koruna Fortress (Fig. 2) which was modelled and analyzed I. INTRODUCTION entirely from scratch by Mario Kotlar (Croteam’s 3D and level artist). Even today’s state-of-the-art graphics hardware, in terms of hardware texture filtering, suffers from several aliasing artifacts that are visible in extreme conditions, such as grazing viewing angles, highly warped texture coordinates, or extreme perspectives.[1] This is one of the reasons that Ptex was initially introduced in 2008.[2] Ptex is an open source product written in C ++ which can easily store a large number of textures in a single file. This texture process is intended for industry branches that require extremely high- resolution (8k+) textures in projects. It converts traditional UV space to a specialized texel system.[3] As a result, only one Ptex file is required per channel per model, since Ptex Fig. 1. Displaying a polygon color quality inside the Meshlab program files have resolution independence across all faces.[4] The result of the above is a texturing system that doesn’t use UV In Fig. 1, the red polygons are those with the lowest maps for texturing or painting a 3D object.[5, 6] Ptex assigns quality, that is, polygons of the greatest elongation. When a separate texture per face, thus skipping the texture unwrap designing the model for 3D printing, it is important to achieve entirely. It must be kept in mind that textures must be power- the optimal number of polygons because this model is not of-two sized (though not necessarily square) and patch intended for sub-divisions but for printing on a 3D printer, so adjacency data must be provided.[6] It uses adjacency in this case it is important that it is non-manifold pointers to access neighboring tiles since it doesn’t pre-filter (waterproof). tile data. These pointers must be dereferenced when filtering on tile boundaries.[7] It is also worth mentioning that the Ptex system is designed for quad-based sub-division surfaces that do not require explicit parameterization.[8] The per-face textures of Ptex are aligned with the shading grids, which always results in horizontal or vertical directions of anisotropy.[1] It ensures four main properties, which are in turn are: photo-realistic quality, generality in terms of geometric model regardless of topology, efficiency in Fig. 2. Photographs of the Koruna fortress (Mali Ston, Dubrovnik, Croatia)

978-1-7281-2544-2/19/$31.00 ©2019 European Union 1

Fig. 3. Texture Checker on the left is shown in Mudbox and on the right in 3D Coat

This led to a topology that was expected to be problematic for Ptex. Problems have been shown to be higher than expected. Significant distortions of texture appeared in Mudbox and in 3D Coat as well (Fig. 3). A possible solution to this problem suggested converting elongated trunks into ngons. The result was a complex ngon system. It is known Fig. 5. Examination of poor topology drawing abilities that ngons are quite problematic to work with. Additionally, Mudbox probably does not process them in the correct Fig. 5 shows four divisions that, in turn, represent the manner described in the Ptex standard, as can be seen from following: the distortion form. If Mudbox uses sub-faces in the way it a) A common high resolution. It is noticeable that should, they should look different in the Ptex set-up stage. distortions are still present, However, Mudbox does not process ngons in the way it b) An extremely high resolution of 52 million texels should (via sub-folders), it seems that it divides them into the (roughly a resolution of 7,400 × 7,400 pixel in means of tris system. This could be related to the fact that Mudbox still traditional texture) is localized to 4.4% of the model’s surface uses UV folders to display Ptex in the viewport, which can area, as calculated using , which means that this be concluded from the way in which the polygons containing resolution would require 1.17 billion texels for the whole the minimum level of texels (they have seams) are displayed, model (similar to a traditional texture of 42,000 × 42,000 rather than from the fact that it creates temporary .tif files pixels). However, in practice with Ptex, the amount of while working which otherwise should not be needed. Also, required texels would be less than that, because the texture the fact remains that, during the opening of the .mud model resolution would be localized only in places on the model with Ptex texture, Baking UVs are written in the status line, where it is required. In spite of this, this resolution is still far which is an action that should not normally be needed unless too high for our testing (a mid-end, dual core) machine to UV maps are used.[10] work effectively, c) At extremely high resolution, the texture looks bright, even at considerable magnification, and d) When magnified, it can be seen that the topology still causes a disproportionate distribution of resolution and the occurrence of distortion in certain parts of the model.

Fig. 4. Mapping under different projecting angles. From left to right: Maya, From this experiment (Fig. 5), the conclusion is that a Mudbox (frontal projection) and Mudbox (projection at an angle) model with such topology is impossible or almost impossible Another 3D object topology test was to test the results of to texture with the Ptex method using the tools available. It tris, quads and ngons of different shapes. It turned out to be would be far simpler and more optimal to texture this model an important factor in projecting the texture while looking at using traditional UV mapping. The only solution left in this the polygon as straight as possible, i.e. at the correct (90°) case is to repair the model topology (Fig. 6) so that it can be angle (Fig. 4). It can be concluded that the optimal drawing textured by the Ptex method. To avoid manually repairing the of textures in Mudbox is possible only if the model has a model’s topology, which takes a lot of time, automated relatively good topology (that the polygons are as short as methods were investigated. they are elongated) or, if the topology is poor, at a high After many unsuccessful attempts to reparameter the resolution in textile textures is projected at the correct (90°) topology using Meshlab, success was achieved using 3D angle. The next thing to examine is the efficient use of high Coat and its Auto-Retopology tool.[11] The model with the resolution in texels and projection at the correct (90°) angle new topology was opened using Blender and, once a sub- to achieve satisfactory results (Fig. 4). division was made to increase the polygon density, the shrinkwrap modifier was used in order to reposition all the points of the new model in relation to the closest matching points on the surface of the original model. This further sharpened the new model and made it even more similar to the original model.[12]

2

Fig. 6. Comparison of old and new polygon topologies

The number of polygons in the process increased from 6,899 to 148,216, which is 21 times more. The number of polygons in this case is not so important, because it will not significantly increase the time required to plot. By comparing the old and new topology, seen in Fig. 6, one can notice the following: • Fig.s a) and b) represent the model before and after the change of topology. There is a visible level of change in Fig. 7. Distribution of the texel’s resolution level at a) minimum resolution x1, b) x4, c) x8 and d) x16 shape between the two models, which in this case is not only insignificant, but is already in its favor, because it is natural III. MAKING AND CUSTOMIZING PTEX for such a model (the ruin of the castle) to have less sharp and TEXTURE regular edges, and • Fig.s c) and d) show the wireframe before and after After splitting the resolution, the next step was to draw changing the topology. From this it can be seen that the the texture itself. The next series of Fig.s (8-9) shows a part elongation of the polygon has now drastically decreased, and of the texture creation process. the model now consists almost entirely of quads. Fig. 8 shows the level of detail that is allowed by the large In the case of real-time animation, it is possible to use the resolution area by adding detailed moss. original model as the ideal render proxy to optimize the number of polygons in the viewport, since Ptex is not intended for use in animation.[1, 6] A small, but negligible, amount of distortion is mainly present due to the fact that high resolution was not used in the texels. For parts of the models that are intended to be displayed in close proximity, the resolution in texels should be increased in order to obtain a greater sharpness and detail of the texture which, at the same time, will eliminate these small amounts of distortion. Ptex is a method for which no Fig. 8. Texture production process (1/2) using the Stencil Tool parameterization is required. Nevertheless, the option of manually determining the location of a larger and lesser texture resolution is enabled. It is not necessary to create a Ptex texture, but it is certainly recommended as it will result in an optimal and more detailed texture. In the follow-up this model was divided into five different resolution areas. The initial resolution of the model first decreased at the margins by one (Fig. 7.a). After that, a general interest area was selected where the resolution doubled (Fig. 7.b). The area of exceptional interest, which is closer to the camera, is intended to be further textured from the rest of the model and, for that reason, the resolution doubled twice (Fig. 7.c). Finally, an area of vast resolution was added that could be closest to the camera without having the issue of losing details (Fig. 7.d), as this is exactly one of Fig. 9. Texture production process (2/2) using the Stencil Tool the main advantages of the Ptex method.

3

The stencil tool is used to set the basic texture of stones In Fig. 11, the following divisions are visible: a) a basic and then dodge, burn and contrast tools provide the look resolution of 256 pixels, b) a resolution increased to 2,048 shown on the right. Finishing the texture by darkening and pixels, and c) a resolution increased to a maximum of 8,192 illuminating certain parts of the texture across the entire pixels. model is used to break the monotone repetition of the tile’s The 2.0 Viewport does not yet display the “true” Ptex seamless texture, and a) before, b) after c) and the size of the texture, but is banished into UV folders within its system. This area are shown in Fig. 10. is why even with the highest resolution of 8,192 pixels, it is not possible to see all the levels of detail drawn in Mudbox. Occasional displays are also displayed. None of this is a problem if you intend to use an external rendering engine such as VRay instead of a Viewport 2.0 renderer called Maya Hardware 2.0, which is almost always the case. To draw Ptex using VRay, you need to add a VRay Ptex node and map it to a color field such as Lambert or, in this case, VRayMtl. The path of the ptx texture is defined in the properties of the VRay Ptex node.[13]

Fig. 10. Finished texture

Fig. 10 shows the level of resolution that is provided by the huge resolution area. Certainly, the resolution can be further increased as much as needed, as a), b) and c) show the different levels of image magnification, in comparison to the previous level, to better demonstrate the local resolution that Ptex can provide. After the texture was completed, it was saved as .ptx (Ptex format) and loaded in Maya under the color texture of the Lambert Material to demonstrate Ptex texture display using the 2.0. Maya Viewport. It was also necessary to increase the value of bake resolution for unsupported textures > Color Textures to obtain the resolution needed in the viewport, which depends on the purpose for which the texture in the viewport is required (Fig. 11).

Fig. 12. Rendering using VRay filters

Fig. 12 contains divisions that in turn represent the following: a) A render with the initial settings, b) A render with a CatmullRom filter (also known as a sharpening filter), c) A render with a CatmullRom filter and the same texture as a bump map, d) A render from a closer proximity using a CatmullRom filter, e) A render from even greater proximity, using a CatmullRom filter, and f) A render proximity with a bump map and Lanczos filter.

It can be concluded that rendering with VRay had insufficient quality (Fig. 12), that is, the results were not of production quality. All renderers have a significant lack of resolution and sharpness of the texture, so much so it can be said that some parts of the texture are blurred (a), and this is in cases where polygons have a diagonally-stretched topology. Resolution of the problem of blurred texture was Fig. 11. View of Ptex texture in the Viewport 2.0 within Maya attempted with a CatmullRom filter, which was somewhat, but insufficiently helpful (b).

4

It is also noticeable that rendering duration is more than texture became extremely sharp (identical to its display in 10 times higher than it should be for a model of this Mudbox). Of course, texture filtering exists for a number of complexity and texture resolution. It turned out that the reasons, and it turned out that it is not the best idea to turn addition of a bump map did not have a significant impact on this option off every time. The shutdown of the texture the sharpness and detail of the texture, but it added an filtering resulted in texture graininess that does not work in a additional 7 minutes (overall 57 min) to the already too high real way, that is, it could be said that the texture is too sharp. rendering time, which was absolutely unacceptable (c). An even more important consequence of shutting down the When the camera approaches, it is evident that all Mudbox filter is the occurrence of a time aliasing, that is, an aliasing details are present at all levels of resolution, but the texture that is noticeable as an inconsistency between animation was still too dull (d and e). Adding a bump map made the frames. To demonstrate this aliasing speed, which cannot be rendering somewhat better from the vicinity (although the displayed with a picture, 100 frames of short animation of bump map in this case was probably a bit too strong and if it moving camera towards the castle were rendered. was left like that the difference would be more clear), but not Experimenting with different filters revealed that a good sufficiently so. It is interesting to note that the rendering time balance of texture sharpness and the amount of allowed with the camera's zooming was reduced up to 10 times, which filtering was accomplished with a Box filter width of 0.4, should not be the case. As far as other Ptex renderers, only which could be understood as a box filter with a level of 40% the Mantra Renderer (the Houdini Program Renderer) and of the usual application. (Fig. 13). This approach reduces the Stripes (the Mental Ray Plugin for Maya and 3ds Max) were timing to an almost imperceptible level as it is quite available for this test. Unexpectedly Stripes failed to run for acceptable. Aliasing speed becomes completely Maya or 3ds Max. inconspicuous when using motion blur, which is always the Stripes is a simple and free program and plugin, which case in production. It should be noted that the use of motion was in the alpha stage of development, so instability and blur significantly increases the duration of the rendering. unreliability were not surprising. When trying to render the Ptex texture in Houdini using Mantra, it turns out that it is necessary to reverse the order of the objects’ vertexes in order to display the texture correctly. Fortunately, Houdini possesses tools for this.[14] After rendering with Mantra almost identical problems as with VRay appeared, excluding the exceptionally long duration of the rendering. Render in Mantra also resulted in blurry texture, but it was at a normal speed. It took about 20-50 seconds for the rendering (depending on the distance of the camera), for which VRay needed 10 minutes. In Mantra, the distance of the camera did not affect the duration of the rendering, as it should be. The very fact that the same problems also occurred in Mantra leads to the conclusion that there may have been something wrong in the way the texture was prepared for export from Mudbox. It turns out that there are no additional export options in Mudbox, except for choosing the number of colors (8-bit integer, 16-bit integer, 16-bit float and 32-bit float). Fig. 13. On the left are renderings without texture filtering and on the right are final renders with a 0.4 Box Width Filter Looking for features in Maya, it's clear that some VRay- related Ptex preferences can be changed within the VRay Another interesting and very important thing to find is Ptex node. It turned out that earlier attempts to change filters that increasing the Cache Size (MB) variables in the VRay inside VRay were a failure, as these settings were related to Ptex node settings result in normalizing the rendering speed, filtering geometry. Here was the Filter Type option where it regardless of the distance of the camera. The basic value of a was possible to select a texture filter, extinguish it or select 1 MB cache size is, at a minimum, ridiculous, which leads to the width of the filters and the optional Blur parameter. the conclusion that they were probably left as a baseline by The Sharpness parameter is only offered if a bilinear is mistake. In real terms, the production of very complex selected for the filter type. The interpolation between the mathematical texture filtering algorithms is not ideal when mipmap levels parameter was turned off, and it turned out working with only 1 MB of RAM, because it results in an that its inclusion only exacerbated the blurred texture. There increased rendering duration (33 times more in this case and is also the reverse vertex order feature that has the same probably far more for more complex scenes). Increasing the functionality as the reverse node in Houdini, with the variable to 100 MB completely solves the problem of lack of exception that if the starting value is off, Mudbox memory for filtering, but in practice it is also useful to use compatibility should also be off, and in Houdini the same more values. When VRay has access to a sufficient amount values should be the inverse (i.e. on). The problem with the of RAM for filtering, then filtering only increases the lifespan need for inversion arises from the fact that the .obj format can of the render by a 5% (as opposed to ~ 3,200% when 1MB of be written in several ways, while some applications write RAM is available). The option to set the width of the filter, elements inside the format in a different order. which was of great help to VRay, does not exist in Mantra. When quenching texture filtering in the VRay Ptex node settings, the render became extremely fast, regardless of the distance of the camera (about 20 seconds per frame), and the

5

IV. DISCUSSION: SHORTCOMINGS AND For UV mapping, it is expected that this will not become PREDICTIONS redundant, primarily as there are cases that are too simple for Ptex or there is a specific need for the texture to be readable Texture mapping is a process of adding details to the 2D by a 2D drawing program. As far as the gaming industry is or 3D model surface. There are several types of map concerned, no predictions have been made about whether the projections which can be found throughout the literature such Ptex method will be upgraded, adapted and one day, used to as: planar, spherical, cylindrical and so on. Those maps can’t make games. Ptex is likely to be implemented over almost all solve the problem of extremely high resolutions which is why 3D CGI production tools over the next few years and will Ptex method was introduced.[15] The only drawback to the slowly become the primary method for mapping textures due Ptex method is that it is a relatively new system, which is why to its numerous advantages over the UV mapping method. it is not yet widely supported in all software tools. Some might also consider that, when using older versions of the REFERENCES Maya and VRay rendering engines, it is not possible to see textures in the viewport or set them so that they can be seen [1] P. Mavridis, and G. Papaioannou, “High-quality Elliptical Texture in the viewport using Viewport 2.0, as then they will not be Filtering on GPU”, In Symposium on Interactive 3D Graphics and Games, ACM, February 2011, pp. 23-30 rendered in VRay engine. The reason for this is the way [2] B. Burley, and D. Lacewell, “Ptex: Per-Face Texture Mapping for VRay renderer works, that is, the path of the texture must be Production Rendering”, In Forum 2008 Jun 1 (Vol. defined using a special VRay Ptex node, and when the texture 27, No. 4), Blackwell Publishing Ltd., pp. 1155-1164 is mapped through it, it is not visible in Viewport 2.0 [3] A. Bernik, and M. Kotlar, “Ptex System for Advanced Texture Mapping”, Journal for Printing Science and Graphic Communications (Viewport 1.0 can display Ptex only with third-party plugins (Acta Graphica), 29(1), 2018, pp. 15-24 that can be unreliable). It should be additionally assessed [4] L. Lanier, “Advanced Maya Texturing and Lighting”, John Wiley and whether the precise assumption is that there is a way in Maya Sons, 2015, pp. 252 to achieve the display of one shader in the viewport, and [5] Min-Zhi Chin, “Naga: Combining 2D and 3D Animation”, The Honors College, East Tennessee State University, 2013 another shader in the render, which would successfully solve [6] J. McDonald Jr, and B. Burley, “Per-face Texture Mapping for Real- this problem. time Rendering”, In ACM SIGGRAPH 2011 Studio Talks, ACM, pp. It is assumed that the same problems do not occur when 3, August 2011 using the PRMan renderer, because it has supported Ptex for [7] M. Nießner, and C. Loop, “Analytic Using Hardware Tessellation”, ACM Transactions on Graphics (TOG), 32(3), more than 5 years. Unfortunately, this could not be pp. 26, 2013 confirmed, because it was not possible to access the software [8] C. Koniaris, D. Cosker, X. Yang, and K. Mitchell, “Survey of Texture for the purposes of this experiment. Using the Ptex file from Mapping Techniques for Representing and Rendering Volumetric 3D Coat to render with Maya Viewport 2.0 or VRay resulted Mesostructure”, Journal of Computer Graphics Techniques, 2014 [9] S. Kim, K. Hillesland, and J. Hensley, “A Space-efficient and in a scattered texture, although it's possible that it works well Hardware-friendly Implementation of Ptex”, In SIGGRAPH Asia 2011 with other programs, such as Cinema 4D, PRMan, etc. It is Sketches, ACM, pp. 31, December 2011 probably just a temporary problem (i.e. a bug), but this is [10] S. Todorovic, N. Ahuja, “Texel-based Texture Segmentation”, In simply an overview of the current situation. Computer Vision, 2009 IEEE 12th International Conference, pp. 841- 848, September 2009 These shortcomings are only due to the fact that Ptex has [11] J. Javis “3D-Coat Online Documentation”, 3dcoat, 2014., available at: only recently become popular. Implementation of Ptex http://3dcoat.com/manual/retopo/248-autopo/, accessed July 4, 2019 started rapidly a few years ago, and it is expected that all [12] Blender 2.79 Manual: Shrinkwrap Modifier, available at: commonly-used programs will have full and integrated Ptex https://docs.blender.org/manual/en/latest/modeling/modifiers/deform/ shrinkwrap.html, accessed February 12, 2019 support. [13] Chaos Software Ltd: PTex Map and VRayPtex, available at: https://docs.chaosgroup.com/display/vray3maya/ptex+map+%7c+vra V. CONCLUSION yptex, accessed July 4, 2019 [14] Sidefx Hudini: Understanding Mantra Rendering, available at: http://www.sidefx.com/docs/houdini/render/understanding.html, Effective use of the Ptex method for users who are not accessed: July 4, 2019 part of the production industry is already possible, but this [15] H. Wang, Huamin. “Texture Mapping”, department of Computer requires the additional knowledge and experience shown in Science and Engineering. Ohio State University, available at: the experimental part of this paper. Ptex is a method for http://web.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013- spring/15-texture.pdf, accessed: September 2, 2019. which no parameterization is required. The problem is observed in situations where polygons are elongated, as this results in additional blurry texture at the time of the camera transition (timing aliasing). The problem of blurry polygons can be resolved by increasing the resolution of the model and the creation a new topology using some of the specialized tools (e.g. 3D Coat). Increasing the number of polygons does not have a significant impact on the length of the rendering time. On the other hand, the problem with blur can be resolved by blurring the camera (motion blur), but this results in a multiple increase in total rendering time. One curiosity to pay attention to, which contributes to the speed of rendering, is certainly the size of the cache memory, which depends on the program itself.

6