-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add preliminary support for loose edges and points #717
Conversation
It would be nice if this was resolved and merged. |
it was ready to go when i submitted it, but it didn't get merged at the time, not sure why. it will take some doing to resolve the conflicts as i am not actively working on blender stuff at the moment, but i will try and make time for it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something I struggled with when I was writing this was how to develop one of the included addons while using stock blender and avoid getting conflicts. I think I ended up erasing the |
I'm using the steps in DEBUGGING.md. It seems like you do need to delete the original |
Hey, tried using this branch with 'Compression' option enabled - was met with following error:
It seems to occur even if 'Loose Vertices' and 'Loose Edges' are disabled. |
Note that the compression methods implemented in this addon do only support triangle meshes. But we should make sure that it safely ignores loose vertices and edges whether compression is enabled or not, yes. |
We'd be glad to support this feature, but for clarity (since it currently needs updates) I'll mark the PR as a draft. Please feel free to mark it as ready for review, or open another PR, whenever you like. :) |
Will do. Sorry, life situation changed since I made the original PR and I'm trying to make time to update it! |
Completely understand, no worries! When you have the time let us know, or any other users interested in this feature are welcome to build on your work and open a new PR too. Thanks for getting this started. 🙂 |
Exporting points and lines would be very useful. I had to do an obj-wavefront to gltf converter in my code, which is annoying if you want to have anything other than simple primitives with no great material. |
I'm looking forward to exporting lines, because if I can't export lines, I'll have to manually find the right place in the world to calculate the right dot matrix to draw a line (which is a disaster). |
Here is an up-to-date branch with loose geometry support in case it helps anyone. Look for the "Loose Geometry" options under "Geometry" on the export screen. I have not tested it extensively. |
Updated the patch to the changes that have happened in the meantime. I tracked my original implementation fairly closely, so I expect its not as idiomatic as it should be, specifically w.r.t #1023 which I haven't looked at. It works locally, and the CI tests pass, so that's something. Still a few things to do though:
Once I get those taken care of I will start a review. Happy for any guidance/feedback as always. @scurest I ended up updating my original code as that was the path of least resistance -- thanks though! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think you should consider using my branch as a base instead. In addition to being in line with #1120 (which succeeded #1023), it fixes several bugs, uses the FBX-compatible option names discussed above, doesn't export indices for POINT primitives, and adds a test.
Pointing out some issues anyway. I'll only comment on edges, but some of this applies to points too.
@scurest thank you for the detailed review. I think you're right, I will take a look at your branch as the base instead next! |
About Draco: I think it's only for mode=4? So this? diff --git a/addons/io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py b/addons/io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py
index 2bb79aa0..6a661334 100644
--- a/addons/io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py
+++ b/addons/io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py
@@ -200,6 +200,10 @@ def __compress_primitive(primitive, dll, export_settings):
'UnsignedInt': 4,
}
+ # Only compress triangle mode
+ if primitive.mode not in [None, 4]:
+ return
+
# Positions are the only attribute type required to be present.
if 'POSITION' not in attributes:
print_console('WARNING', 'Draco exporter: Primitive without positions encountered. Skipping.') Maybe @UX3D-eckerlein could confirm? (This PR will add primitives with mode=0 and mode=1.) |
That's correct, the |
backed up and used @scurest's changes. they work great and meet all my own use cases. all i did was tweak a few internal naming conventions. this is more or less ready to go but a few things come to mind. let me know if these are out of scope/make more sense in a separate PR.
alternatives that come to mind are
or
any preferences? other ideas? not an issue?
it means loose geometry gets a reasonable default, and if it's not what the user wanted they can break the loose geometry out into its own mesh and assign a different material. admittedly, the only thing that gets communicated is color, but it makes a difference in some cases. the image above is from a mock-up i have not pushed out, rendered in three.js (intentionally downsampled to highlight the effect). does this make sense? maybe behind another export option? is there a better way to deal with materials on loose geometry? |
edit: maybe we could put |
addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py
Outdated
Show resolved
Hide resolved
^Agreed on @scurest's suggested solutions to (1) and (2) above. |
addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py
Outdated
Show resolved
Hide resolved
Looking forwards to this! ❤️ |
This will be used by for Loose Edges/Loose Points.
Export a primitive with LINES for edges not part of a poly. The option name use_mesh_edges is for compatibility with FBX.
There's now a list of all exceptional option names (that don't start with export).
Exports a POINTS primitive (without indices) for verts not in an edge.
It would be nice to have a roundtrip test, but there's currently no way to say what options you want to use for exporting in a roundtrip test I think, so you can't turn on the Loose Edges/Points options.
Fixes bug when using Draco with loose geometry.
Tweak the option descriptions to mention this.
I've updated my branch with everything discussed so far. |
@scurest this looks great to me, thanks for taking care of this! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excited to have this functionality, and glad the implementation ended up being pretty concise.
@emackey any concerns with the material handling?
Has someone tested this with skinned points or lines? I don't think three.js even supports that, I'm not sure about Babylon.js or other engines...
If there are no concerns or other issues, I'll merge this in a few days.
Yes, it works reimporting back into Blender and in Babylon, but not in Three. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor wording suggestions for the export options. Are these OK?
We actually had a concern about how materials are [barely] specified for points & lines crop up in the Khronos PBR TSG just this week. But that didn't have an easy answer, so it shouldn't hold up this PR. I have no concerns about the mechanics of using the first material slot, so this should be good to go. |
So what happened? |
Co-authored-by: Ed Mackey <elm19087@gmail.com>
it was all @scurest in the end 🙏 very happy to see this merged and i look forward to using this feature in blender! |
This patch implements the enhancement discussed in #376.
POINTS
primitiveLINES
primitiveThis is a preliminary patch and some more work can be done in the future. Some things that come to mind:
LINES
primitives as they are indexedPOINTS
primitives are still indexed, which is likely wasteful. Addressing this would require a bigger patch to the exporter that I wanted to avoid without further guidance on the issueI am open to feedback and guidance on these and any other issues.
I've attached a test scene and three files exported by this patch:
lines.glb
is exported with "Loose Edges" checkedpoints.glb
is exported with "Loose Vertices" checkedpoints-and-lines.glb
is exported with both checkedscene.blend
is the source scene