[x3d-public] Blender support for ImageTexture export

vmarchetti at kshell.com vmarchetti at kshell.com
Sat Jan 29 18:39:22 PST 2022


Summary: This is an announcement of python scripts which restore the export of ImageTexture nodes in the X3D export of Blender models. This export capabilty was reported missing from the Blender 2.80 and later versions of Blender. The python scripts developed here have undergone preliminary testing for Blender 3.0.0; the latest public release. For those who have been missing this capability from Blender, you are invited to read the detailed description below, install the new python scripts in your Blender installation (at v 3.0 and beyond ); and report bugs to the Web3D Consortium Blender project; more generally whether these scripts meet the needs of your workflows in using image textures with X3D models edited in Blender.

-----------------------------------------

Detailed Description

These X3D import/export scripts may be tested by replacing the Python code for the Blender 3.0 installation with the python scripts from Consortium github project. You will first need to location these scripts in your Blender 3.0 installation. Typical locations are:

Windows: C:\Program Files\Blender Foundation\Blender 3.0\3.0\scripts\addons\io_scene_x3d
MacOS  : /Applications/Blender.app/Contents/Resources/3.0/scripts/addons/io_scene_x3d
Linux: (consult https://docs.blender.org/manual/en/latest/advanced/blender_directory_layout.html )

This folder should contain 3 Python source code files:
__init__.py
import_x3d.py
export_x3d.py
This folder may also contain a __pycache__ folder, which should be deleted if you do replace these scripts.

These files need to be replaced with the corresponding files from the image_texture_export branch of the Web3DConsortium/BlenderX3DSupport github project ( https://github.com/Web3DConsortium/BlenderX3DSupport ). The web-page for viewing this branch and directory is https://github.com/Web3DConsortium/BlenderX3DSupport/tree/image_texture_export/io_scene_x3d from which this source may be copied into the Blender installation.

This implementation exports an X3D TextureImage node when an image is defined in the "Base Color" node of a "Principled BSDF" node [see https://docs.blender.org/manual/en/latest/render/shader_nodes/shader/principled.html ] defined in a Blender material. The name of the image referenced in the Base Color node is assumed to represent the name of the image file (including extension) -- specifically the base name of the file, not including names of enclosing directories. When the ImageTexture node is written to the exported X3D file this name of the image will be one of the entries in the url field of the ImageTexture node. The url field will also contain additional entries based on the filesystem path of the image file in the local computer; these urls will not be portable and may represent a security or privacy danger. Using the basename of the image file as the url supports the deployment of the image texture files in the same directory as the X3D file which uses them.

The specification of the image texture in the node-based Blender material is supported by the X3D import script distributed with Blender 3.0 ; the user should be able to do the 'round trip' workflow
  X3D File A   ---> Blender import-->  [Blender application, editing] ---> Blender export --> X3D File B
without being concerned with the details of node-based materials.

This export implementation does not write the image file to the local file system as part of the export.

This export implementation does not support exporting a TextureTransform node in the Appearance node.

Potential Tests:
If you are interested in participating in evaluating this code, the simplest test case will be an X3D file that uses an image texture, both located in the same directory on your local computer. After replacing the 'factory-installed' scripts as described above, import the X3D file; then export the Blender model into the same folder as the original file (which should also contain the image file). The proof in the pudding will be your ability to load the exported X3D file in an X3D browser and see the rendered texture.

A test may be run using the "Hello World" example from the X3D Archives at web3d.org : https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorldIndex.html

An additional test case, with a larger image texture and more complex geometry, can be downloaded from https://spri-open-resources.s3.us-east-2.amazonaws.com/Morse_Vale_Telegraph_Key_X3D.zip


Useful additional testing would include:
-- Examples of X3D files which load multiple image files as textures.
-- Examples of X3D files which use the TextureTransform node.
-- Examples of files which repeat a texture in either the S or T axis, or both

Please report results of testing, bugs identified, and concrete proposals for changes in behavior to the issues section of the Web3DConsortium github project : https://github.com/Web3DConsortium/BlenderX3DSupport/issues/2

Vince Marchetti




More information about the x3d-public mailing list