Skip to content

Conversation

Lilaa3
Copy link
Collaborator

@Lilaa3 Lilaa3 commented Jun 29, 2024

This pr adds support for optionally exporting and importing f3d material data as glTF extensions, the objective is to create a standard that other tools can rely on (for example, tiny3d) instead of relying on the glTF addon's custom propreties toggle, along with implementing any needed hacks that broke exports previously. This pr is based on wiseguy's glTF64 but does not export the glTF64 extension.

Missing:

  • Importing
  • Emulate as much as possible within standard glTF2 extensions such as pbr metallic
  • Warnings for invalid materials
  • Schemas
  • Vertex colors (create a hack for a single COLOR_0 acessor, tricky in different ways depending on version)
  • Work around for texture gathering issues (node gather can´t handle f3d nodes)
  • Make sure code is up to standard before review

@Lilaa3 Lilaa3 mentioned this pull request Jun 29, 2024
Copy link
Contributor

@Dragorn421 Dragorn421 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typos

Lilaa3 and others added 6 commits June 26, 2025 17:37
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
@Lilaa3 Lilaa3 force-pushed the glTF_experimental branch from 74795d4 to 04f4f66 Compare June 26, 2025 17:25
@HailToDodongo
Copy link
Contributor

After testing it again, it seems to have some issues in newer blender versions.
in 4.3 vertex alpha seems to not be present even with the new flag.
And in 4.5 it has no color at all (and for some reason materials are not detected as being fast64 ones in the UI)

@Lilaa3
Copy link
Collaborator Author

Lilaa3 commented Jul 21, 2025

My check started from 4.4 instead of 4.3, i'll test 4.5 soon (I'm downloading it)

@Boxingbruin
Copy link

Boxingbruin commented Aug 6, 2025

Fix for vertex alpha channel appearing as greyscale instead of opacity after export in Blender 4.0.0

While testing vertex alpha in blender 4.0.0 I discovered that the glTF export add-on will export with the color attribute that is currently selected. If 'Alpha' is selected, it will export using 'Alpha' colors by default, not 'Col' colors causing greyscale alpha instead of opacity. To clear up confusion and fix this issue I wrote some code that will automatically set the selected render color to 'Col' before export.

I placed this function in gltf_extensions.py and called it at the top of glTF2_pre_export_callback. Make sure to filter for blender 4.0.0 specifically (and 4.0.1, 4.0.2 if needed - untested in those versions). Later versions use property names like render_color instead of an index.

def force_col_vertex_color_active():
    """
    Ensures 'Col' vertex color attribute is used for export by setting it as active and (if available) render color.
    Compatible with Blender 4.0.
    """
    for mesh in bpy.data.meshes:
        color_attrs = getattr(mesh, 'color_attributes', None)
        if not color_attrs:
            continue
        col_idx = None
        for i, ca in enumerate(color_attrs):
            if ca.name == "Col":
                col_idx = i
                break
        if col_idx is not None:
            color_attrs.active_color_index = col_idx
            if hasattr(color_attrs, "render_color_index"):
                color_attrs.render_color_index = col_idx
            print(f"[INFO] Set 'Col' as active/render color for mesh '{mesh.name}'")
        else:
            print(f"[WARN] Mesh '{mesh.name}' does not have a 'Col' vertex color attribute!")

@Lilaa3
Copy link
Collaborator Author

Lilaa3 commented Aug 6, 2025

@Boxingbruin

Fixed

@HailToDodongo
Copy link
Contributor

With the issue above fixed, is there anything left to get this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request f3d Has to do with the "f3d" code common to all games test please Ask that some other Fast64 dev tests the feature/...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants