Index  | Recent Threads  | List Attachments  | Help  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password

Sweet Home 3D Forum

No member browsing this thread
Thread Status: Active
Total posts in this thread: 2
[ Jump to Last Post ]
Post new Thread
Previous Thread This topic has been viewed 2798 times and has 1 reply Next Thread
Advanced Member
Member's Avatar

Joined: Mar 25, 2015
Post Count: 153
Status: Offline
Reply to this Post  Reply with Quote 
Update on POT/NPOT (powers-of-two/non-powers-of-two) texture issue

Emmanuel -

Today I ran into the most egregious example of POT texture degradation I've yet seen. Fortunately, in anticipation of a potential problem, at the same time I created proportional texture images for use in Sketchup, I also generated visually acceptable POT texture images with which I overwrote those used by SH3D. I wanted to post a quick discussion here in case others are troubled by otherwise inexplicable texture degradation; I've updated the applicable trouble tickets with a link to this thread.

The Issue
SH3D is built upon the Java3D library, among others. Prior to version 1.5, Java3D required each dimension of a texture image to be a power of two (POT). This was in support of older graphics cards running OpenGL 1.0, which could only accelerate POT textures. Although most cards manufactured in the past decade *can* support non-powers-of-two (NPOT) textures, older cards and budget cards based on older technology may still contain this limitation. Worse, while later versions of OpenGL and Java3D provide a mechanism by which an application can query the card's ability to handle NPOT textures, a significant number of transitional cards do not respond correctly. As a result, later versions of Java3D -- including Java3D 1.5.3, currently used by SH3D -- still default to having NPOT support disabled.

What this means is whenever SH3D imports a texture image where one or both dimensions are not a power of two, the image is resized so that each dimension is the nearest power of two. When the resulting image has dimensions the same as or larger than those of the original, there is little or no noticeable impact on the model's final appearance. However, Java3D resizes dimensions to the nearest power of two, which may result in a drastic downsizing of one or both dimensions, with accompanying loss of information and degradation of the final model.

Even though SH3D only uses Java3D to generate the 3D window and to create Q1 and Q2 images (that is, 3D 'photos' at the lowest two quality settings), it only retains a single instance of each texture image. As a result, Q3 and Q4 renders will reflect texture degradation due to resizing.

The problem is most pronounced in textures containing text -- for instance, textures representing signs or labels -- or containing grids or other repeating geometric elements.


I recently modeled an electronics component in Sketchup for use in SH3D. The front face of this object included two plates containing text: One identifying the manufacturer and model, and a second containing controls and settings. As Sketchup requires images imported as textures to be in the same proportions as they ultimately will be depicted,[1] I created the following two images for use in this model. (Note that MediaFire converts the original PNG to a JPG when displayed in this manner.):

These images are exported, unchanged, by Sketchup as part of an exported 3D model in Collada (.dae) format.

The first image measures 485 x 182; the second 406 x 43. As neither dimension of either image is a power of two, upon import into SH3D the images are resized to, respectively, 512 x 128 and 512 x 32. This represents 30% information loss, in the case of the control panel, and over 25% information loss for the logo and model ID, as so:

Having anticipated this problem, though, at the same time I generated the proportional images for use in Sketchup, I also generated two POT texture images whose dimensions were the next largest -- as opposed to the nearest -- power of two for the original dimension. (The POT control panel image measures 512 x 256, and the logo/model number image is 512 x 64.):

I then replaced the original, NPOT texture images within the exported 3D model with my upscaled POT images. SH3D imported these textures without resizing them.

As you can see from the following Q4 render, the effects of downsizing the texture image are quite apparent in the finished model. In the render, the model on the left was imported using my hand-converted POT texture images, while the model on the right uses SH3D's default POT resizing. The loss of vertical information causes the distorted or missing horizontal lines.

[View full-size]


First, it should be noted in most cases the automatic resizing of texture images will not be readily apparent in SH3D renders; only when the text contains information or a pattern lending itself to detection -- for instance, text or a repeating geometric design -- will a resized texture be noticeable, and then only when the image is significantly reduced along one or both dimensions. Accordingly, most of the time the most efficient approach to the issue will be simply not to worry about it unless and until it becomes obvious.

When texture degradation becomes too noticeable to ignore, it can be corrected by manually resizing the offending texture image to a power of two. This can be done using most image editing programs (Photoshop, GIMP, and so forth) by selecting 'Image [Re]Size,' ensuring 'Resample Image' (or equivalent) is enabled and 'Constrain Proportions' (or equivalent) disabled, and changing both horizontal and vertical dimensions, if not already a power of two, to the next-largest power of two. This manually created POT texture is then substituted for the corresponding texture in the object model as originally imported, the object re-imported into SH3D, and existing instances of the object replaced with the newly modified version.

Alternatively, it is possible to replace the degraded texture with a manually created POT texture from within SH3D itself; while I'm not sure exactly why this works, presumably this imported texture will be of use only within the designated model.

To update an existing texture with its manually resized POT equivalent, double-click the object in question to open the 'Modify furniture' window. Under 'Color and texture,' select 'Materials' and click 'Modify.' This opens the 'Furniture materials' window. In the list of materials under 'Model materials,' select the material in question, which should be defined as a texture. Click the texture button (which will display a small icon of the texture image currently in use) to open the 'Material texture' window, and then click the 'Import' button. Click 'Choose image' and browse to the folder in which you saved the manually resized texture image; select the texture image. Click 'Continue >', select the desired image category, and click 'Finish'. Important: Leave the image width and height set to SH3D's default calculation. Respond 'OK' when prompted until the 'Modify furniture' window is closed; the object should now be updated to use the alternative texture.

(Note the overriding texture is displayed correctly proportioned, even though the texture image as imported retains whatever distortion was introduced in resizing both dimensions to a power of two. If you apply the imported texture to any other object or surface, it will display this distortion; seemingly, because the original texture was mapped at something other than 1:1, the overriding texture is mapped so that it covers the same amount of surface as the texture it replaces. Again, I am not certain why this should be the case, as it is contrary to the way I understood SH3D to behave.)


P.S. As usual, I am having trouble getting all images to load from MediaFire. In the past, this issue has always resolved itself; however, if anyone else also has problems with broken images and links, please let me know, and I'll try to provide alternative access.
[Aug 18, 2016 12:53:45 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Advanced Member

Joined: May 12, 2013
Post Count: 1502
Status: Offline
Reply to this Post  Reply with Quote 
Re: Update on POT/NPOT (powers-of-two/non-powers-of-two) texture issue

Thanks for enlightenment, most useful elaboration of an issue that Puybaret made me aware of a while back (he takes the trouble to adjust textures of contributed library models) - and I shall never submit a NPOT texture again.

While this is unlikely to present problems for the average SH3D user, it is an important point for model and texture contributions. And on the same subject - good textures scaled to a reasonable size requires some attention playing with compression levels (jpg) and (POT) sizes. But it is quite amazing how good results you can get with cleverly made textures without bloating the final SH3D file.

[Aug 18, 2016 6:57:53 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

    Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads
© Copyright 2006-2018 eTeks - All rights reserved