Closed Blood-Machine closed 1 month ago
Hello, New version of Blender try to better manage how alpha are exported to glTF. You have to plug the alpha socket if you want to export alpha. BaseColor socket is for RGB only:
This seems to have exactly the same results(at least did for me when i tested it with a few different files, including the one uploaded here), export with plugging in alpha as not plugging in alpha Would it be possible to at least add a toggle to always include alpha ? Since i think it would be optimal to have it export alpha regardless of materials used, for most game assets and mass exporting for example.
Hello, In Blender 4.2 beta. Here are your VC data:
Here are the exported VC data on glTF, with the following setup:
==> Alpha are exported correctly.
glTF exporter does not manage float socket to RGB socket. So no RGB is detected on your VC at export. If you want to manage RGB+A VC, you need a setup like this:
So I don't think there is any bug here. But an enhancement can be made by detecting float => Color setup
Hi, thank you for explanation Oh, willl try switching to 4,2 then Since in 4.1 it just doesn't export alpha whatsoever as far as I can tell, at least nothing reads it
Though the enhancement would be immensely appreciated
Okay, tested it in 4.2, it exports alpha if the alpha channel is connected, it is broken in 4.1 for future reference For now will use a workaround with plugging and unplugging the alpha channel
Thanks very much for help
EDIT: Oh, sorry, I misunderstood the enhancement thing,thought meant that if float was detected like, in vertex value then it would be used. My actual need for application is to actually have the alpha channel as such (since using it for vertex colour masking for texture blending) Is there a way to just always export entire rgba for vertex colour, even in changing something in code or sth that I could do myself?
Might need a little further elaboration, since did a bit more testing, and Alpha vertex seems to only get exported if it's plugged directly into the alpha port, if there's even just a multiply it fails to be exported, so it still seems bugged.
This setup exports the alpha channel:
The multiply node is ignored. There is no multiply Vertex Color Factor in glTF specification.
We can't handle hundred of nodes and thousand of node links/combination, as we need to navigate in node programmatically, as there is no bake available in Blender node tree.
I apologise for wording that poorly The issue is not that the nodes are ignored, rather than they aren't. I uploaded the files I'm working with. You are correct, multiply node does get ignored(I misremembered which one I tried, sorry ;;), but any other operation, such as maximum, minimum, mix, etc, result in alpha not getting exported at all. Seems as if anything that's not a multiply operation essentially blocks it.
To clarify Intended behaviour: Alpha channel passes through "minimum" float operation node and into the alpha plug in the shader node editor, on export, this node gets ignored, and alpha channel for vertex gets exported Current Behaviour: lpha channel passes through "minimum" float operation node and into the alpha plug in the shader node editor, on export, alpha vertex channel is blank (edit: apologies posted wrong file for the vertex alpha cube previously)
For extra testing, I've tested a lot of operation nodes So far only multiply seems to actually lead to alpha getting exported, if it passes through add, substract, divide, multiply add, power, minimum, maximum ,mix and a few others, they don't get ignored, they simply don't result in any alpha getting exported. Multiply seems to be the only one getting ignored
SO.. how do you have a Base Color texture and Vertex Color if you have to have the vertex color connected to base color? Is Vertex Color ignored if not connected?
Is Vertex Color ignored if not connected?
See the documentation : https://docs.blender.org/manual/en/4.2/addons/import_export/scene_gltf2.html#data-mesh-vertex-color
SO.. how do you have a Base Color texture and Vertex Color if you have to have the vertex color connected to base color?
For example, with base color factor + texture + Vertex Color
Ty.. This is how Aspose3D sets up its vertex color export for export. Blender creates the rest.
Dim vcolor As New VertexElementVertexColor
ReDim normals(_group(item).nVertices_ - 1)
For i As UInt32 = 0 To _group(item).nVertices_ - 1
normals(i).X = _group(item).vertices(i).index_1
normals(i).Y = _group(item).vertices(i).index_2
normals(i).X = _group(item).vertices(i).index_3
normals(i).W = _group(item).vertices(i).index_4
Next
vcolor.SetData(normals)
m.AddElement(vcolor)
In SparpGLTF the only thing I can do is add it to the vertex like this. The vertex colors are not added in blender. I can't get an answer from anyone on why they are missing. they are not added. I have tested this in every app I have and online GLB viewers. Aspose works with BLender only but no other viewers or apps as it isn't generating legit GLB. I can find an answer to that problem either.
Dim vertices As New List(Of VertexBuilder(Of VertexPositionNormal, VertexColor1Texture1, VertexEmpty))()
For i As UInt32 = 0 To _group(item).nVertices_ - 1
Dim v As New VertexBuilder(Of VertexPositionNormal, VertexColor1Texture1, VertexEmpty)(
New VertexPositionNormal(
New Vector3(_group(item).vertices(i).x, _group(item).vertices(i).y, _group(item).vertices(i).z),
New Vector3(_group(item).vertices(i).nx, _group(item).vertices(i).ny, _group(item).vertices(i).nz)
),
New VertexColor1Texture1(
New Vector4(_group(item).vertices(i).r, _group(item).vertices(i).g, _group(item).vertices(i).b, _group(item).vertices(i).a),
New Vector2(_group(item).vertices(i).u, _group(item).vertices(i).v)
)
)
' Add the vertex to the list
vertices.Add(v)
Next
' Create mesh primitive face indices
For i As UInt32 = 1 To _group(item).nPrimitives_ - 1
prim.AddTriangle(
vertices(_group(item).indices(i).v1 - off),
vertices(_group(item).indices(i).v2 - off),
vertices(_group(item).indices(i).v3 - off)
)
Next
I can't get an answer from anyone on why they are missing
If you think something is wrong on Blender side, please create a new ticket with your test file
No.. Blender is awesome. This is a issue with SharpGLFT and I can't get any help from them. Thanks for edifying me a bit better.
Hello, As far as I understand, there is no bug on our side in Blender. Closing this ticket. Feel free to comment or open a new ticket if you think something is wrong in Blender glTF I/O
Describe the bug When exporting, no matter the settings, alpha channel for vertex paint/color attribute is exported as blank
To Reproduce Steps to reproduce the behavior: Visualise color attribute alpha with a shader Erase alpha on the default blender cube Export as glb/glTF Import the exported file Now it will have no vertex alpha, but other colors will be preserved
Expected behavior On importing, vertex alpha should be the same
.blend file/ .gltf (mandatory) attached a file with a cube with visualised vertex color exporting it results in a completely blank cube
Version
Additional context Add any other context about the problem here. vertexAlphaCube.zip