As described in this thread, texture images included in models exported to Lightwave format are often resized. Images may be upscaled or downscaled, or images may be increased in one dimension and decreased in the other; for instance, in a recently exported object, a texture image originally 400 x 400 was increased to 512 x 512, while one originally 1300 x 400 was resized to 1024 x 512. (As best I can tell, image dimensions < 384 are resized to 128; dimensions >= 384 and <= 712 are resized to 512, and dimensions > 712 are resized to 1024 -- but I may very well be incorrect about the algorithm being used, as I've not yet identified where in the source this resizing takes place.)
The image quality may suffer during either up- or downscaling: Upscaling images often produces jaggies, while downscaled images may lose content detail.
I'm not sure whether this resizing takes place during object import or export, as to date I've only tested with object textures originally imported with objects. (My next test will be to import an object, apply a texture to it within SH3D with a dimension > 1024, export the resulting object, and determine if the exported texture image has been resized.) However, I am starting to suspect the resizing occurs on importation, as objects imported into the Furniture Library Editor and saved in an .SH3F file also include resized textures.
Procedure to test:
Workaround:
Uncertain. If resizing only occurs on export, and the user has access to the original texture image files, then the resized images can be replaced by appropriately named copies of the originals. (Note: Since SH3D exports all textures as .PNG files, if the original image is in a format other than PNG, the .MTL file must be edited to include the correct file extention in the applicable 'Kd' definition.)
This process can also be used to correct textures incorrectly resized by the Furniture Library editor, either by directly editing the .SH3F file using a Zip utility or by unzipping the .SH3F file, making changes as needed within the unzipped library, and recompressing the library. (In either case, one may need to change the library's extension from .SH3F to .ZIP before editing and back to .SH3F afterwards.)
If resizing occurs on import, the only potential workaround would be to import the object, modify its materials, and replace the resized textures with one imported directly into SH3D. (Note: In the case of textures intended to be used one-up at 100% -- for instance, a texture used to 'paint' a logo onto a nameplate, or one representing a gauge, control panel, or video display -- this requires the user know the intended size at which the texture will be shown; otherwise, the texture will either be truncated or repeated [tiled] on the object's surface.) At the moment, it's uncertain whether objects textured using this process are exported with correctly sized texture images.
OK, so my first take on the rules for scaling was wrong: a 1600 x 900 test image was rescaled to 2048 x 1024 on export. I'm also finding discernible, but only barely discernible, differences on side-by-side renders of objects using original and resized textures. (However, the problem that initially started me looking -- the resizing of a 400 x 400 image of black text on a yellow background to 512 x 512, which introduced significant jaggies -- was readily apparent in renders, so it doesn't appear I can simply ignore the resize in all cases. However, as yet another potential workaround, I'm experimenting with manually resizing the images to a multiple of 512 along each dimension.)
Further testing reveals that overwriting a downscaled texture in an imported object with the original, larger texture in SH3D seemingly does replace the smaller texture with the larger one. However, upon export to OBJ, the applied texture is resized.
After additional research, it appears this may be a hold-over from an older version of Java3D, which required texture images to have dimensions that were each a power of 2. Evidently this requirement was dropped as of version 1.5 of the library, but the model loaders may still incorporate the older algorithm. While in most cases the texture degradation that results from image resizing is minor, under some conditions it is noticeable. I've been hand-tweaking .sh3f files to incorporate the original image files -- which I now suspect ultimately made no difference, assuming SH3D insists upon enforcing the power-of-2 rule regardless of where the model originates.
After even more research, I've uncovered the following:
See this forum thread for more information.
Thanks for your detailed report.
As you suspected it, the issue comes from internal handling of textures by Java3D which converts by default all texture images to the nearest power of two size. TextureLoader constructor proposes an optional
ALLOW_NON_POWER_OF_TWOparameter, but I fear it might not work in some cases. Anyway, I changed OBJWriter class to make it save the original texture images when they exist, with the additional benefit that exporting goes faster.Please try the version 5.3 beta 12 or further that should fix this issue. Confirm also that rotation on textures works correctly in your case, because there were some important changes on this point too (note that textures at 45° will appear at their full scale on models with texture coordinates compared to previous version).
Last edit: Emmanuel Puybaret 2016-11-08
Version 5.3 was released yesterday.