[x3d-public] Tests for Blender->X3D exporter utilizing texture transformation and per-vertex colors

John Carlson yottzumm at gmail.com
Sun Dec 29 13:15:49 PST 2024


Report so far. This is to set a baseline for what we have currently.   I
set up the default exporter, probably without any texture pull request.

bash runimportmichalis.sh
Read blend: "C:\Users\jcarl\X3DJSONLD\blend\level.blend"
Info: starting X3D export to 'levelExportB.x3d'...
missing 'C:\\Users\\jcarl\\X3DJSONLD\\blend\\textures\\Pillar_02.jpg', not
copying
missing 'C:\\Users\\jcarl\\X3DJSONLD\\blend\\textures\\Soil01.png', not
copying
missing 'C:\\Users\\jcarl\\X3DJSONLD\\blend\\textures\\Planks_02.jpg', not
copying
Info: finished X3D export to 'levelExportB.x3d'

Read blend: "C:\Users\jcarl\X3DJSONLD\blend\multiple_textures.blend"
Info: starting X3D export to 'multiple_texturesExportB.x3d'...
missing 'C:\\Users\\jcarl\\X3DJSONLD\\blend\\textures\\leaf.png', not
copying
Info: finished X3D export to 'multiple_texturesExportB.x3d'

Read blend:
"C:\Users\jcarl\X3DJSONLD\blend\texture_transforms_on_base_texture.blend"
Info: starting X3D export to
'texture_transforms_on_base_textureExportB.x3d'...
missing 'C:\\Users\\jcarl\\X3DJSONLD\\blend\\textures\\base_texture.png',
not copying
Info: finished X3D export to 'texture_transforms_on_base_textureExportB.x3d'
GPUTexture: Blender Texture Not Loaded!
Saved session recovery to "C:\Users\jcarl\AppData\Local\Temp\quit.blend"

Blender quit

This was kind of expected with the standard exporter, and the way around
this was to export the textures oneself (not ideal!), so I grabbed the
images from x3d-tests:

$ cp `find ~/x3d-tests/blender_tests/texture_transform/ -name '*jpg'`
textures/
$ cp `find ~/x3d-tests/blender_tests/texture_transform/ -name '*png'`
textures/
$ cp textures/*png .
$ cp textures/*jpg .

[image: image.png]

[image: image.png]

[image: image.png]

My exporter produced one file at first (see later), without texture:

[image: image.png]

None of the exporters produced a TextureTransform.  There were errors in my
runs, including:

  File "C:\Users\jcarl\AppData\Roaming\Blender
Foundation\Blender\4.3\scripts\addons\io_scene_x3dv\blender\exp\x3dv_blender_export.py",
line 2667, in export_main
    children = b2x_object(None, obj_main, obj_main_children,
x3dmodel.Scene, image_textures, x3d_obj).children

 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jcarl\AppData\Roaming\Blender
Foundation\Blender\4.3\scripts\addons\io_scene_x3dv\blender\exp\x3dv_blender_export.py",
line 2392, in b2x_object
    shape = b2xShape(geometry=node)
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jcarl\AppData\Roaming\Blender
Foundation\Blender\4.3\scripts\addons\io_scene_x3dv\blender\exp\x3dv_blender_export.py",
line 2038, in b2xShape
    x3d_obj = Shape(appearance=Appearance(), geometry=geometry)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jcarl\AppData\Roaming\Blender
Foundation\Blender\4.3\scripts\addons\io_scene_x3dv\blender\com\x3dv.py",
line 83969, in __init__
    self.geometry = geometry
    ^^^^^^^^^^^^^
  File "C:\Users\jcarl\AppData\Roaming\Blender
Foundation\Blender\4.3\scripts\addons\io_scene_x3dv\blender\com\x3dv.py",
line 84047, in geometry
    raise X3DTypeError(str(geometry) + ' does not match required node type
(_X3DGeometryNode,ProtoInstance) and is invalid')
io_scene_x3dv.blender.com.x3dv.X3DTypeError:
Transform(DEF='TE_Text',USE=None) does not match required node type
(_X3DGeometryNode,ProtoInstance) and is invalid
Location: C:\Program Files\Blender Foundation\Blender
4.3\4.3\scripts\modules\bpy\ops.py:109

Saved session recovery to "C:\Users\jcarl\AppData\Local\Temp\quit.blend"
... truncated
Blender quit


This is saying that a Shape.geometry can't be set to a Transform!

This is due to Blender FONT being converted to a default X3D Transform
instead of a X3D Text node.  So I applied a patch:

            elif obj_main.type == "FONT":
                x3d_type_str = "Text"
                x3d_obj = b2xInstantiate(x3d_type_str, x3d_oid, x3d_name,
obj_main, x3d_matrix)


While the exports ran to completion, there were no textures evident in the
output, just white text and a white box.  I have to work on reducing
duplicates, but not removing useful stuff.

[image: image.png]

I'm going to take a break and see if I can figure out DEF/USE versus
similarly named objects. It seems like the default exporter produced some
files that I can look at.

In general, my exporter has a lot of problems with extra USE attributes
(*ExportB.x3d is the standard exporter):  The Material USE is particularly
pernicious.

$ grep USE
{level,multiple_textures,texture_transforms_on_base_texture}Export*.x3d
levelExport.x3d:          <Coordinate USE='CO_coords_ME_Cube_016'>
levelExport.x3d:          <Normal USE='NO_normals_ME_Cube_016'>
levelExport.x3d:          <TextureCoordinate USE='TX_Cube_016'>
levelExport.x3d:        <Material USE='MA_mat_soil'>
levelExport.x3d:        <Material USE='MA_mat_soil'>
levelExport.x3d:        <Material USE='MA_mat_pillar'>
levelExport.x3d:        <Coordinate USE='CO_coords_ME_Cube_016'>
levelExport.x3d:        <Normal USE='NO_normals_ME_Cube_016'>
levelExport.x3d:        <TextureCoordinate USE='TX_Cube_016'>
levelExportB.x3d:
<ImageTexture USE="IM_Soil01_png_001" />
levelExportB.x3d:
<Material USE="MA_mat_soil" />
levelExportB.x3d:
<Coordinate USE="coords_ME_Cube_016" />

multiple_texturesExport.x3d:        <Material USE='MA_Material_001'>
multiple_texturesExport.x3d:        <Material USE='MA_Material_006'>
multiple_texturesExport.x3d:        <Material USE='MA_Material_007'>
multiple_texturesExport.x3d:        <Material USE='MA_Material_008'>
multiple_texturesExportB.x3d:
    <ImageTexture USE="IM_leaf_png" />
multiple_texturesExportB.x3d:
    <ImageTexture USE="IM_leaf_png" />
multiple_texturesExportB.x3d:
    <ImageTexture USE="IM_leaf_png" />

texture_transforms_on_base_textureExport.x3d:        <Material
USE='MA_Material_001'>
texture_transforms_on_base_textureExport.x3d:        <Material
USE='MA_Material_002'>
texture_transforms_on_base_textureExport.x3d:        <Material
USE='MA_Material_003'>
texture_transforms_on_base_textureExport.x3d:        <Material
USE='MA_Material_004'>
texture_transforms_on_base_textureExport.x3d:        <Material
USE='MA_Material_005'>
texture_transforms_on_base_textureExportB.x3d:
                     <ImageTexture USE="IM_base_texture_png" />
texture_transforms_on_base_textureExportB.x3d:
                     <ImageTexture USE="IM_base_texture_png" />
texture_transforms_on_base_textureExportB.x3d:
                     <ImageTexture USE="IM_base_texture_png" />
texture_transforms_on_base_textureExportB.x3d:
                     <ImageTexture USE="IM_base_texture_png" />



Indeed there are no Material nodes with a DEF attribute!

$ grep '<'Material
{level,multiple_textures,texture_transforms_on_base_texture}Export.x3d
levelExport.x3d:        <Material USE='MA_mat_soil'>
levelExport.x3d:        <Material USE='MA_mat_soil'>
levelExport.x3d:        <Material USE='MA_mat_pillar'>
multiple_texturesExport.x3d:        <Material USE='MA_Material_001'>
multiple_texturesExport.x3d:        <Material USE='MA_Material_006'>
multiple_texturesExport.x3d:        <Material USE='MA_Material_007'>
multiple_texturesExport.x3d:        <Material USE='MA_Material_008'>
texture_transforms_on_base_textureExport.x3d:        <Material
USE='MA_Material_001'>
texture_transforms_on_base_textureExport.x3d:        <Material
USE='MA_Material_002'>
texture_transforms_on_base_textureExport.x3d:        <Material
USE='MA_Material_003'>
texture_transforms_on_base_textureExport.x3d:        <Material
USE='MA_Material_004'>
texture_transforms_on_base_textureExport.x3d:        <Material
USE='MA_Material_005'>



On Sat, Dec 28, 2024 at 5:16 PM Michalis Kamburelis <
michalis.kambi at gmail.com> wrote:

> John,
>
> My tests apply to texture transformations (not textures).
>
> And I didn't test animating anything -- as the current Blender -> X3D
> exporter doesn't export any animation at all from what I know. Small
> steps, let's add there first basic transformations (transforming
> Blender object's location/rotation/scale exported to X3D animating
> Transform.translation/rotation/scale would be my suggestions), then
> skinned animation, then think about less common use-cases (like
> animating texture transformations or texture coordinates).
>
> Regards,
> Michalis
>
> sob., 28 gru 2024 o 22:37 John Carlson via x3d-public
> <x3d-public at web3d.org> napisał(a):
> >
> > Great examples, Michalis.
> >
> > I note at least three things:
> >
> > 1.  There's no texture animation, but Joe's example has that.  I have
> not seen if your fps_game example has texture animation or not.
> >
> > 2.  My exporter exports textures (not animations).  I am looking forward
> to looking at what Vince and Cedric are doing, and if they don’t have
> animation yet, I will attempt to add it.
> >
> > 3.  I am starting to tie meshes to the empty type objects I am
> importing, if meshes are present.
> >
> > I’ll send a pic with what i have for Joe Skin export in a bit.
> >
> > John
> >
> > On Fri, Dec 27, 2024 at 7:23 PM Michalis Kamburelis via x3d-public <
> x3d-public at web3d.org> wrote:
> >>
> >> Vincent and all,
> >>
> >> ( Sorry it took me a while -- Christmas times are busy in offline
> >> activities :) )
> >>
> >> 1. I prepared the promised tests of texture transformation in Blender,
> >> to help implementing their handling in the Blender -> X3D exporter.
> >>
> >> They are inside the "blender_tests/texture_transform/" of my
> >> repository https://github.com/michaliskambi/x3d-tests/ . Browse them
> >> through here
> https://github.com/michaliskambi/x3d-tests/tree/master/blender_tests/texture_transform
> >> . To just download them, it's probably easiest to "git clone" the
> >> whole x3d-tests repo.
> >>
> >> The README inside (
> >>
> https://github.com/michaliskambi/x3d-tests/blob/master/blender_tests/texture_transform/README.md
> >> ) already describes everything. A short summary:
> >>
> >> - I tested transforming base, normal, metallic/roughness textures
> >> (same or differently).
> >>
> >> - I added a "real-life example" of using texture transformation (from
> >> Castle Game Engine "examples/fps_game" demo,
> >>
> https://github.com/castle-engine/castle-engine/tree/master/examples/fps_game
> >>  ).
> >>
> >> - I added glTF exporter outputs, screenshots from Blender, Castle
> >> Model Viewer -> hopefully this all makes it clear what is the desired
> >> output.
> >>
> >> - TODO: I planned to do, but did not do this: I wanted to create a
> >> "desired" X3D files, crafted by hand, to show how a proper X3D output
> >> should look like. Not done yet, simply because of lack of time. I
> >> don't want to keep you waiting, so I send you the tests as they are
> >> now. Ping me if you think you need these "desired" X3D files :)
> >>
> >> 2. Moreover, I added tests for per-vertex colors.
> >>
> >> This shows per-vertex colors generated using Blender's "Ambient
> >> Occlusion" (make areas e.g. behind ears nicely darker even without
> >> using real-time shadows) and how they can be multiplied with
> >> material(s) in glTF. This is a feature we talked about -- you
> >> mentioned you wanted to implement it by "premultiplying" the material
> >> * per-vertex color. Hopefully my tests will help make sure it's all
> >> correct :)
> >>
> >> They are in:
> >>
> >>
> https://github.com/michaliskambi/x3d-tests/tree/master/blender_tests/per_vertex_colors
> >>
> >> Again, I added glTF exporter outputs, screenshots from Blender, Castle
> >> Model Viewer -> showing what should happen.
> >>
> >> I hope these are useful! Let me know if anything in this is unclear.
> >>
> >> Regards,
> >> Michalis
> >>
> >> _______________________________________________
> >> x3d-public mailing list
> >> x3d-public at web3d.org
> >> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
> >
> > _______________________________________________
> > x3d-public mailing list
> > x3d-public at web3d.org
> > http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20241229/6ffc9b61/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 175775 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20241229/6ffc9b61/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 42307 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20241229/6ffc9b61/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 50606 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20241229/6ffc9b61/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 42528 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20241229/6ffc9b61/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 46830 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20241229/6ffc9b61/attachment-0009.png>


More information about the x3d-public mailing list